grunwaldlab / poppr

🌶 An R package for genetic analysis of populations with mixed (clonal/sexual) reproduction
https://grunwaldlab.github.io/poppr
68 stars 26 forks source link

IS there a way to make a table indicated the multilocus genotypes for each isolate? where is that info stored? #253

Closed vcastroagudin closed 2 years ago

vcastroagudin commented 2 years ago

Please place an "x" in all the boxes that apply


Please include a brief description of the problem with a code example: I checked the manual and vignette for a command that would do this but I could find it. IS the multilocus info stored in the original object (data file) can it be extracted as a table?


THANK YOU very much, IN ADVANCE!

zkamvar commented 2 years ago

Hello,

It depends on what you are looking for. If you want a genotype table that gives you the allele calles, you want the {adegenet} function, genind2df() if you want the ID of the assigned MLG, then you need to use the mll() (multilocus lineage) function. If, however, you want to know what isolates are associated with a single MLG, then you want mlg.id()

library(poppr)
library(tibble)
data(Aeut)
Aeut <- as.genclone(Aeut)
tibble(genind2df(Aeut)) # genotype table
#> # A tibble: 187 × 57
#>    pop     L01   L02   L03   L04   L05   L06   L07   L08   L09   L10   L11   L12
#>    <fct> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int> <int>
#>  1 Athe…     1     0     1     0     1     0     0     1     1     0     1     1
#>  2 Athe…     1     0     1     0     0     0     0     1     1     1     1     1
#>  3 Athe…     1     0     1     0     0     0     0     0     1     0     1     1
#>  4 Athe…     1     0     1     0     0     0     0     0     1     0     1     1
#>  5 Athe…     1     0     1     0     0     0     0     0     1     0     1     1
#>  6 Athe…     1     0     1     0     0     0     0     0     1     1     1     1
#>  7 Athe…     1     0     1     0     0     0     0     0     1     0     1     1
#>  8 Athe…     1     0     1     0     0     0     0     0     1     0     1     1
#>  9 Athe…     1     0     1     0     0     0     0     0     1     0     1     1
#> 10 Athe…     1     1     0     0     0     0     0     0     1     0     1     0
#> # … with 177 more rows, and 44 more variables: L13 <int>, L14 <int>, L15 <int>,
#> #   L16 <int>, L17 <int>, L18 <int>, L19 <int>, L20 <int>, L21 <int>,
#> #   L22 <int>, L23 <int>, L24 <int>, L25 <int>, L26 <int>, L27 <int>,
#> #   L28 <int>, L29 <int>, L30 <int>, L31 <int>, L32 <int>, L33 <int>,
#> #   L34 <int>, L35 <int>, L36 <int>, L37 <int>, L38 <int>, L39 <int>,
#> #   L40 <int>, L41 <int>, L42 <int>, L43 <int>, L44 <int>, L45 <int>,
#> #   L46 <int>, L47 <int>, L48 <int>, L49 <int>, L50 <int>, L51 <int>, …
tibble(isolate = indNames(Aeut), MLG = mll(Aeut)) # table of MLG id for each isolate
#> # A tibble: 187 × 2
#>    isolate   MLG
#>    <chr>   <int>
#>  1 001        63
#>  2 002        53
#>  3 003        17
#>  4 004        16
#>  5 005        26
#>  6 006        42
#>  7 007         8
#>  8 008        17
#>  9 009        16
#> 10 010        93
#> # … with 177 more rows
mlg.id(Aeut)["59"] # List of isolates for each MLG
#> $`59`
#> [1] "057" "159"

Created on 2022-05-23 by the reprex package (v2.0.1)