Issue converting 2 column allele data to 1 column using pegas::alleles2loci or genetics::makeGenotypes: switches order of alleles
0
0
Entering edit mode
3.7 years ago

Hi,

I'm noticing something odd when I combine my 2 column allelic microsatellite dataset in R to 1 column with a separator (i.e. from locus1a: 100, locus1b: 90 to locus1: 100/90).

I've tried pegas::alleles2loci() and genetics::makeGenotypes() and noticed with both functions that for come loci in some rows, the order of the alleles switches when applying the functions, but it is not consistent (i.e. from locus1a: 100, locus1b: 90 to locus1: 90/10). I can't find any other help or documentation on why this occurs, can anyone help?

Code below:

library(strataG)
library(pegas)
library(genetics)

msat <- readGenData("./R_tarandus_Kluetsch_2017_microsats.csv")

str(msat)

'data.frame':   591 obs. of  20 variables:
 $ indiv_id: chr  "30554" "30555" "30559" "30560" ...
 $ pop     : chr  "BAN" "BAN" "BAN" "BAN" ...
 $ BM848a  : chr  "364" "362" "372" "386" ...
 $ BM848b  : chr  "386" "372" "386" "386" ...

etc

head(msat)

indiv_id pop BM848a BM848b BM888a BM888b MAP2Ca MAP2Cb RT24a RT24b RT30a RT30b RT5a RT5b RT6a RT6b RT7a RT7b RT9a RT9b
1    30554 BAN    364    386    164    174     89    105   209   209   187   193   98  114  110  124  218  218  116  124

msat_loci <- pegas::alleles2loci(msat, ploidy = 2, rownames = 1, population = 2)
msat_gen <- genetics::makeGenotypes(msat, convert=list(3:4,5:6,7:8,9:10,11:12,13:14,15:16,17:18,19:20))
head(msat_gen)

  indiv_id pop BM848a/BM848b BM888a/BM888b MAP2Ca/MAP2Cb RT24a/RT24b RT30a/RT30b RT5a/RT5b RT6a/RT6b RT7a/RT7b RT9a/RT9b
1    30554 BAN       386/364       174/164        105/89     209/209     193/187    114/98   110/124   218/218   116/124


sessionInfo()

 R version 3.5.1 (2018-07-02)
 Platform: x86_64-w64-mingw32/x64 (64-bit)
 Running under: Windows 10 x64 (build 14393)

 Matrix products: default

 locale:
   [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
 [4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

 attached base packages:
   [1] stats     graphics  grDevices utils     datasets  methods   base     

 other attached packages:
  [1] genetics_1.3.8.1.2  mvtnorm_1.1-0       MASS_7.3-50         gtools_3.8.2        gdata_2.18.0        combinat_0.0-8     
 [7] HardyWeinberg_1.6.3 Rsolnp_1.16         mice_3.8.0          genepop_1.1.7       tidyr_1.0.2         purrr_0.3.4        
 [13] stringr_1.4.0       reshape_0.8.8       diffdf_1.0.4        kableExtra_1.1.0    dplyr_0.8.5         haplotypes_1.1.2   
[19] pegas_0.13          adegenet_2.1.2      ade4_1.7-15         ape_5.3             strataG_2.4.905    

 loaded via a namespace (and not attached):
   [1] colorspace_1.4-1      seqinr_3.6-1          deldir_0.1-25         ellipsis_0.3.0        class_7.3-14         
 [6] PopGenome_2.7.5       rstudioapi_0.11       spatstat.data_1.4-3   fansi_0.4.1           xml2_1.3.2           
 [11] codetools_0.2-15      splines_3.5.1         knitr_1.28            polyclip_1.10-0       swfscMisc_1.3        
 [16] broom_0.5.6           cluster_2.0.7-1       apex_1.0.4            shiny_1.4.0.2         readr_1.3.1          
 [21] compiler_3.5.1        httr_1.4.1            backports_1.1.6       assertthat_0.2.1      Matrix_1.2-14        
 [26] fastmap_1.0.1         cli_2.0.2             later_1.0.0           htmltools_0.4.0       tools_3.5.1          
 [31] igraph_1.2.5          coda_0.19-3           gtable_0.3.0          glue_1.4.0            reshape2_1.4.4       
 [36] maps_3.3.0            gmodels_2.18.1        tinytex_0.23          fastmatch_1.1-0       Rcpp_1.0.4.6         
 [41] spatstat_1.63-3       statnet.common_4.3.0  raster_3.1-5          vctrs_0.2.4           spdep_1.1-3          
 [46] nlme_3.1-137          xfun_0.14             network_1.16.0        rvest_0.3.5           mime_0.9             
 [51] mapdata_2.3.0         lifecycle_0.2.0       phangorn_2.5.5        goftest_1.2-2         LearnBayes_2.15.1    
 [56] scales_1.1.1          hms_0.5.3             promises_1.1.0        spatstat.utils_1.17-0 parallel_3.5.1       
 [61] expm_0.999-4          yaml_2.2.1            ggplot2_3.3.1         rpart_4.1-13          stringi_1.4.6        
 [66] plotrix_3.7-8         e1071_1.7-3           permute_0.9-5         boot_1.3-20           truncnorm_1.0-8      
 [71] spData_0.3.5          rlang_0.4.5           pkgconfig_2.0.3       evaluate_0.14         lattice_0.20-35      
 [76] tensor_1.5            sf_0.9-2              bit_1.1-15.2          tidyselect_1.0.0      plyr_1.8.6           
 [81] magrittr_1.5          R6_2.4.1              generics_0.0.2        sna_2.5               DBI_1.1.0            
 [86] pillar_1.4.4          mgcv_1.8-24           units_0.6-6           abind_1.4-5           sp_1.4-1             
 [91] tibble_3.0.1          crayon_1.3.4          KernSmooth_2.23-15    rmarkdown_2.2         grid_3.5.1           
 [96] data.table_1.12.8     vegan_2.5-6           digest_0.6.25         classInt_0.4-3        webshot_0.5.2        
 [101] xtable_1.8-4          ff_2.2-14.2           httpuv_1.5.2          munsell_0.5.0         viridisLite_0.3.0    
 [106] quadprog_1.5-8
R pegas alleles2loci makeGenotypes microsatellite • 639 views
ADD COMMENT

Login before adding your answer.

Traffic: 2743 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6