keeping MLGs with psex>0.05 for diversity_ci

10 views
Skip to first unread message

Sofie V

unread,
Apr 26, 2024, 5:08:52 AMApr 26
to poppr
Hi!
I would like to use the function diversity_ci and calculate CF and B as described in the poppr Rdocumentation. But I would like to consider individuals in an MLG with p-sex >0.05 as separate genotypes and not as one MLG. Is there is a way to maintain these repeated genotypes to calculate these diversity indices?
I realize I can manually add a strata level specifying the MLG's as explained here: https://groups.google.com/g/poppr/c/JyQd1FOTc2U/m/7AKBRLlJumIJ 
But I don't see how this can be helpful in applying diversity_stats or _ci
Any advice is greatly appreciated! 
Many thanks in advance, 
Sofie

Zhian Kamvar

unread,
Apr 26, 2024, 2:14:00 PMApr 26
to Sofie V, poppr
Hello,

You can use the custom MLLs in order to do this. Here's the documentation: https://grunwaldlab.github.io/poppr/articles/mlg.html#custom-custom

The trick with using p-sex is that you have to manually separate out and label the genotypes above the threshold, which can be done using the make.unique() function from R. Here's an example using the P. ramorum data within poppr:

library("poppr")

# EXAMPLE DATA SETUP -----
data(Pram)
mll(Pram) <- "original"

# NOTE: the data has 98 MLGs
Pram
#>
#> This is a genclone object
#> -------------------------
#> Genotype information:
#>
#>     98 original multilocus genotypes
#>    729 diploid individuals
#>      5 codominant loci
#>
#> Population information:
#>
#>      3 strata - SOURCE, YEAR, STATE
#>      9 populations defined -
#> Nursery_CA, Nursery_OR, JHallCr_OR, ..., Winchuck_OR, ChetcoMain_OR, PistolRSF_OR

# Calculating p-sex and correcting zero-value alleles by 1/(2*rrmlg) with no
# population structure assumed.
Pram_psex <- psex(Pram, by_pop = FALSE, d = "rrmlg", mul = 1/2, method = "multiple")


# retrieve the original mlls as a character vector
mlls <- as.character(mll(Pram))
# create a threshold for individuality
thresholds <- Pram_psex >= 0.05
# append a "p" to all of these MLGs and append a number like
# 22p.4 is the fifth genotype likely sexually derived which is
# identical to MLG 22.
mlls[thresholds] <- make.unique(paste0(mlls[thresholds], "p"))
mll.custom(Pram) <- mlls

# Now the data has 225 MLLs
Pram
#>
#> This is a genclone object
#> -------------------------
#> Genotype information:
#>
#>    225 custom multilocus genotypes
#>    729 diploid individuals
#>      5 codominant loci
#>
#> Population information:
#>
#>      3 strata - SOURCE, YEAR, STATE
#>      9 populations defined -
#> Nursery_CA, Nursery_OR, JHallCr_OR, ..., Winchuck_OR, ChetcoMain_OR, PistolRSF_OR

I hope that helps.

Zhian

--
You received this message because you are subscribed to the Google Groups "poppr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to poppr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/poppr/f5b0202d-a41b-4f74-a167-006af00acb42n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages