Attention: bug in read.genalex --- strata mis-aligned with entirely non-typed individuals

25 views
Skip to first unread message

Zhian Kamvar

unread,
Sep 4, 2017, 3:50:20 PM9/4/17
to poppr, Hernán Dario Capador-Barreto
Brought up by Hernán Dario Capador-Barreto, there is a bug where the strata is not properly subset when non-typed individuals (those with all missing data) are removed, resulting in incorrect strata assignments from read.genalex with these type of data (see https://github.com/grunwaldlab/poppr/issues/147 for reference).

This will be fixed in the upcoming poppr version 2.5.0 (I will be sending an email announcement for the pre-release shortly). In the meantime, the fix for this issue is to re-assign the strata from the population before splitting it (example below).

library("poppr")
#> Loading required package: adegenet
#> Loading required package: ade4
#>
#>    /// adegenet 2.1.0 is loaded ////////////
#>
#>    > overview: '?adegenet'
#>    > tutorials/doc/questions: 'adegenetWeb()'
#>    > bug reports/feature requests: adegenetIssues()
#> This is poppr version 2.5.0. To get started, type package?poppr
#> OMP parallel support: available
missing_single
<- "13\t6\t1\t6
7_09_BB
Ind\tPop\tCHMFc4\tCHMFc5\tCHMFc12\tSEA\tSED\tSEE\tSEG\tSEI\tSEL\tSEN\tSEP\tSEQ\tSER
A004\t7_09_BB_A004\t224\t85\t163\t132\t133\t156\t144\t116\t143\t227\t257\t142\t145
A002\t7_09_BB_A002\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0
A011\t7_09_BB_A011\t224\t97\t159\t160\t133\t156\t126\t119\t147\t227\t257\t134\t149
A009\t7_09_BB_A009\t224\t97\t159\t160\t133\t156\t126\t119\t147\t227\t261\t134\t149
A006\t7_09_BB_A006\t224\t97\t159\t160\t133\t156\t126\t119\t147\t235\t261\t134\t149
A013\t7_09_BB_A013\t224\t97\t163\t160\t133\t156\t126\t119\t147\t235\t257\t134\t149"

dat
<- read.genalex(textConnection(missing_single), sep = "\t")
#> Warning in df2genind(gena, ind.names = ind.vec, pop = pop.vec, ploidy =
#> 1, : entirely non-type individual(s) deleted
strata
(dat)  # incorrect
#>               Pop
#> A004 7_09_BB_A004
#> A011 7_09_BB_A002
#> A009 7_09_BB_A011
#> A006 7_09_BB_A009
#> A013 7_09_BB_A006
data
.frame(pop(dat))  # correct
#>       pop.dat.
#> 1 7_09_BB_A004
#> 2 7_09_BB_A011
#> 3 7_09_BB_A009
#> 4 7_09_BB_A006
#> 5 7_09_BB_A013


# Temporary solution: reset the strata
strata
(dat) <- data.frame(Pop = pop(dat))
strata
(dat)
#>            Pop
#> 1 7_09_BB_A004
#> 2 7_09_BB_A011
#> 3 7_09_BB_A009
#> 4 7_09_BB_A006
#> 5 7_09_BB_A013


Best,
Zhian
Reply all
Reply to author
Forward
0 new messages