Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix readgenalex numeric inds #202

Merged
merged 5 commits into from
May 2, 2019
Merged

Conversation

zkamvar
Copy link
Member

@zkamvar zkamvar commented Apr 29, 2019

This fixes a weird bug inread.genalex() where the strata would be mal-formed if the user imported data with a duplication in the sample names AND the sample names had at least one numeric name that was within the range of the samples prepended by zeroes.

yes, I know it's weird, but it's the truth:

library('poppr')
#> Loading required package: adegenet
#> Loading required package: ade4
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
#> Registered S3 method overwritten by 'spdep':
#>   method   from
#>   plot.mst ape
#> 
#>    /// adegenet 2.1.1 is loaded ////////////
#> 
#>    > overview: '?adegenet'
#>    > tutorials/doc/questions: 'adegenetWeb()' 
#>    > bug reports/feature requests: adegenetIssues()
#> Registered S3 method overwritten by 'pegas':
#>   method      from
#>   print.amova ade4
#> This is poppr version 2.8.2. To get started, type package?poppr
#> OMP parallel support: available
yd <- "13   6   1   6                                           
            7_09_BB                                         
Ind Pop CHMFc4  CHMFc5  CHMFc12 SEA SED SEE SEG SEI SEL SEN SEP SEQ SER
4   7_09_BB 224 85  163 132 133 156 144 116 143 227 257 142 145
2   7_09_BB 224 97  159 156 129 156 144 113 143 231 261 136 153
2   7_09_BB 224 97  159 160 133 156 126 119 147 227 257 134 149
9   7_09_BB 224 97  159 160 133 156 126 119 147 227 261 134 149
6   7_09_BB 224 97  159 160 133 156 126 119 147 235 261 134 149
3   7_09_BB 224 97  163 160 133 156 126 119 147 235 257 134 149"

gen <- read.genalex(textConnection(yd), sep = "\t")
#> Warning in df2genind(gena, ind.names = ind.vec, pop = pop.vec, ploidy =
#> 1, : duplicate labels detected for some individuals; using generic labels
strata(gen)
#>       Pop
#> 1    <NA>
#> 2 7_09_BB
#> 3 7_09_BB
#> 4 7_09_BB
#> 5    <NA>
#> 6 7_09_BB
pop(gen)
#> [1] 7_09_BB 7_09_BB 7_09_BB 7_09_BB 7_09_BB 7_09_BB
#> Levels: 7_09_BB

Created on 2019-04-29 by the reprex package (v0.2.1)

An issue was brought up by 刁永朝 where he was missing six populations
when he attempted to do aboot.

It turned out that he had a duplicated sample name in his data and
identified some of his samples with numbers that were within the range
of samples he had. Adegenet will rename samples with numbers and I
foolishly checked if any of the sample names were present in the genind
object, not thinking that numeric names will match up.

This fix changes the test to see if the intersection between the genind
object and the original names provides the names in the genind object.
If they are not equal, then the integer names were used.
@zkamvar zkamvar merged commit 084ee5e into master May 2, 2019
@zkamvar zkamvar deleted the fix-readgenalex-numeric-inds branch May 2, 2019 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant