thierrygosselin / radiator

RADseq Data Exploration, Manipulation and Visualization using R
https://thierrygosselin.github.io/radiator/
GNU General Public License v3.0
58 stars 23 forks source link

genlight.R script does not work with current version of R #185

Closed bmillerlab closed 4 months ago

bmillerlab commented 4 months ago

Hello, I suspect the list of conflicts would go on if the script would run past this first error:

Error in markers %<>% dplyr::mutate(REF = stringi::stri_sub(str = nuc.data, : could not find function "%<>%" In addition: Warning message: as_integer() is deprecated as of rlang 0.4.0 Please use vctrs::vec_cast() instead.

I am using Rstudio 4.3.3 on a MacOS.

I really would like to use radiator for linkage disequilibrium calculations but I can't get my genlight into the correct format. I finally found out I needed to set up the tidy_genlight() script but now it won't run b/c of conflicts.

Any suggestions on how to get this working? I don't actually write code since I slid into this awkward position of having to use software now that my BIG NGS datasets generated through my actual molecular biology skills are not useful any other way.

THANKS!

devtools::session_info() ─ Session info ──────────────────────────────────────────────────────────────── setting value version R version 4.3.3 (2024-02-29) os macOS Sonoma 14.4.1 system x86_64, darwin20 ui RStudio language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz America/Los_Angeles date 2024-04-23 rstudio 2023.12.1+402 Ocean Storm (desktop) pandoc NA

─ Packages ──────────────────────────────────────────────────────────────────── ! package version date (UTC) lib source abind 1.4-5 2016-07-21 [1] CRAN (R 4.3.0) ade4 1.7-22 2023-02-06 [1] CRAN (R 4.3.0) adegenet 2.1.10 2023-01-26 [1] CRAN (R 4.3.0) ape 5.8 2024-04-11 [1] CRAN (R 4.3.2) backports 1.4.1 2021-12-13 [1] CRAN (R 4.3.0) base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.3.0) BiocGenerics 0.48.1 2023-11-01 [1] Bioconductor BiocManager 1.30.22 2023-08-08 [1] CRAN (R 4.3.0) Biostrings 2.70.3 2024-03-13 [1] Bioconductor 3.18 (R 4.3.3) bitops 1.0-7 2021-04-24 [1] CRAN (R 4.3.0) broom 1.0.5 2023-06-09 [1] CRAN (R 4.3.0) cachem 1.0.8 2023-05-01 [1] CRAN (R 4.3.0) calibrate 1.7.7 2020-06-19 [1] CRAN (R 4.3.0) callr 3.7.6 2024-03-25 [1] CRAN (R 4.3.2) car 3.1-2 2023-03-30 [1] CRAN (R 4.3.0) carData 3.0-5 2022-01-06 [1] CRAN (R 4.3.0) cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.0) cluster 2.1.6 2023-12-01 [1] CRAN (R 4.3.3) codetools 0.2-20 2024-03-31 [1] CRAN (R 4.3.2) colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.3.0) combinat 0.0-8 2012-10-29 [1] CRAN (R 4.3.0) crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.0) crosstalk 1.2.1 2023-11-23 [1] CRAN (R 4.3.0) curl 5.2.1 2024-03-01 [1] CRAN (R 4.3.2) dartR 2.9.7 2023-06-07 [1] CRAN (R 4.3.0) dartR.data 1.0.2 2022-11-16 [1] CRAN (R 4.3.0) data.table 1.15.4 2024-03-30 [1] CRAN (R 4.3.2) desc 1.4.3 2023-12-10 [1] CRAN (R 4.3.0) devtools 2.4.5 2022-10-11 [1] CRAN (R 4.3.0) digest 0.6.35 2024-03-11 [1] CRAN (R 4.3.2) directlabels 2024.1.21 2024-01-24 [1] CRAN (R 4.3.2) dismo 1.3-14 2023-05-21 [1] CRAN (R 4.3.0) doParallel 1.0.17 2022-02-07 [1] CRAN (R 4.3.0) dotCall64 1.1-1 2023-11-28 [1] CRAN (R 4.3.0) dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.3.0) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.3.0) fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.0) farver 2.1.1 2022-07-06 [1] CRAN (R 4.3.0) fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) fields 15.2 2023-08-17 [1] CRAN (R 4.3.0) forcats 1.0.0 2023-01-29 [1] CRAN (R 4.3.0) foreach 1.5.2 2022-02-02 [1] CRAN (R 4.3.0) fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.0) gap 1.5-3 2023-08-26 [1] CRAN (R 4.3.0) gap.datasets 0.0.6 2023-08-25 [1] CRAN (R 4.3.0) gdata 3.0.0 2023-10-16 [1] CRAN (R 4.3.0) gdistance 1.6.4 2023-06-19 [1] CRAN (R 4.3.0) gdsfmt 1.38.0 2023-10-24 [1] Bioconductor generics 0.1.3 2022-07-05 [1] CRAN (R 4.3.0) genetics 1.3.8.1.3 2021-03-01 [1] CRAN (R 4.3.0) GenomeInfoDb 1.38.8 2024-03-15 [1] Bioconductor 3.18 (R 4.3.3) GenomeInfoDbData 1.2.11 2024-03-16 [1] Bioconductor GenomicRanges 1.54.1 2023-10-29 [1] Bioconductor GGally 2.2.1 2024-02-14 [1] CRAN (R 4.3.2) V ggplot2 3.5.0 2024-04-23 [1] CRAN (R 4.3.2) (on disk 3.5.1) ggpubr 0.6.0 2023-02-10 [1] CRAN (R 4.3.0) ggsignif 0.6.4 2022-10-13 [1] CRAN (R 4.3.0) ggstats 0.6.0 2024-04-05 [1] CRAN (R 4.3.2) glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.0) gridExtra 2.3 2017-09-09 [1] CRAN (R 4.3.0) V gtable 0.3.4 2024-04-22 [1] CRAN (R 4.3.2) (on disk 0.3.5) gtools 3.9.5 2023-11-20 [1] CRAN (R 4.3.0) hms 1.1.3 2023-03-21 [1] CRAN (R 4.3.0) htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.3.2) htmlwidgets 1.6.4 2023-12-06 [1] CRAN (R 4.3.0) httpuv 1.6.15 2024-03-26 [1] CRAN (R 4.3.2) httr 1.4.7 2023-08-15 [1] CRAN (R 4.3.0) igraph 2.0.3 2024-03-13 [1] CRAN (R 4.3.2) impute 1.76.0 2023-10-24 [1] Bioconductor IRanges 2.36.0 2023-10-24 [1] Bioconductor iterators 1.0.14 2022-02-05 [1] CRAN (R 4.3.0) jsonlite 1.8.8 2023-12-04 [1] CRAN (R 4.3.0) knitr 1.45 2023-10-30 [1] CRAN (R 4.3.0) labeling 0.4.3 2023-08-29 [1] CRAN (R 4.3.0) later 1.3.2 2023-12-06 [1] CRAN (R 4.3.0) lattice 0.22-6 2024-03-20 [1] CRAN (R 4.3.2) lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.3.0) LDlinkR 1.4.0 2024-04-10 [1] CRAN (R 4.3.2) lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.0) lubridate 1.9.3 2023-09-27 [1] CRAN (R 4.3.0) magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) maps 3.4.2 2023-12-15 [1] CRAN (R 4.3.0) MASS 7.3-60.0.1 2024-01-13 [1] CRAN (R 4.3.3) Matrix 1.6-5 2024-01-11 [1] CRAN (R 4.3.3) matrixcalc 1.0-6 2022-09-14 [1] CRAN (R 4.3.0) memoise 2.0.1 2021-11-26 [1] CRAN (R 4.3.0) mgcv 1.9-1 2023-12-21 [1] CRAN (R 4.3.3) mime 0.12 2021-09-28 [1] CRAN (R 4.3.0) miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.3.0) mmod 1.3.3 2017-04-06 [1] CRAN (R 4.3.0) munsell 0.5.1 2024-04-01 [1] CRAN (R 4.3.2) mvtnorm 1.2-4 2023-11-27 [1] CRAN (R 4.3.0) nlme 3.1-164 2023-11-27 [1] CRAN (R 4.3.3) patchwork 1.2.0 2024-01-08 [1] CRAN (R 4.3.0) pegas 1.3 2023-12-13 [1] CRAN (R 4.3.0) permute 0.9-7 2022-01-27 [1] CRAN (R 4.3.0) pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0) pinfsc50 1.3.0 2023-12-05 [1] CRAN (R 4.3.0) pkgbuild 1.4.4 2024-03-17 [1] CRAN (R 4.3.2) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0) pkgload 1.3.4 2024-01-16 [1] CRAN (R 4.3.0) plotly 4.10.4 2024-01-13 [1] CRAN (R 4.3.0) plyr 1.8.9 2023-10-02 [1] CRAN (R 4.3.0) png 0.1-8 2022-11-29 [1] CRAN (R 4.3.0) PopGenReport 3.1 2023-10-11 [1] CRAN (R 4.3.0) processx 3.8.4 2024-03-16 [1] CRAN (R 4.3.2) profvis 0.3.8 2023-05-02 [1] CRAN (R 4.3.0) promises 1.3.0 2024-04-05 [1] CRAN (R 4.3.2) ps 1.7.6 2024-01-18 [1] CRAN (R 4.3.0) purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.0) quadprog 1.5-8 2019-11-20 [1] CRAN (R 4.3.0) R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0) R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.2) R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.0) R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) radiator 1.3.1 2024-04-24 [1] Github (thierrygosselin/radiator@899436d) raster 3.6-26 2023-10-14 [1] CRAN (R 4.3.0) rbibutils 2.2.16 2023-10-25 [1] CRAN (R 4.3.0) RColorBrewer 1.1-3 2022-04-03 [1] CRAN (R 4.3.0) Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.3.0) RCurl 1.98-1.14 2024-01-09 [1] CRAN (R 4.3.0) Rdpack 2.6 2023-11-08 [1] CRAN (R 4.3.0) readr 2.1.5 2024-01-10 [1] CRAN (R 4.3.0) remotes 2.5.0 2024-03-17 [1] CRAN (R 4.3.2) reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.3.0) rgl 1.3.1 2024-03-05 [1] CRAN (R 4.3.2) RgoogleMaps 1.5.1 2023-11-06 [1] CRAN (R 4.3.0) rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.0) rstatix 0.7.2 2023-02-01 [1] CRAN (R 4.3.0) rstudioapi 0.16.0 2024-03-24 [1] CRAN (R 4.3.2) S4Vectors 0.40.2 2023-11-23 [1] Bioconductor scales 1.3.0 2023-11-28 [1] CRAN (R 4.3.0) SeqArray 1.40.1 2023-06-11 [1] Bioconductor seqinr 4.2-36 2023-12-08 [1] CRAN (R 4.3.0) sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) shiny 1.8.1.1 2024-04-02 [1] CRAN (R 4.3.2) SNPfiltR 1.0.1 2023-03-17 [1] CRAN (R 4.3.0) snpReady 0.9.6 2018-04-11 [1] CRAN (R 4.3.0) SNPRelate 1.36.1 2024-02-26 [1] Bioconductor 3.18 (R 4.3.2) snpStats 1.52.0 2023-10-24 [1] Bioconductor sp 2.1-3 2024-01-30 [1] CRAN (R 4.3.2) spam 2.10-0 2023-10-23 [1] CRAN (R 4.3.0) StAMPP 1.6.3 2021-08-08 [1] CRAN (R 4.3.0) stringi 1.8.3 2023-12-11 [1] CRAN (R 4.3.0) stringr 1.5.1 2023-11-14 [1] CRAN (R 4.3.0) survival 3.5-8 2024-02-14 [1] CRAN (R 4.3.3) terra 1.7-71 2024-01-31 [1] CRAN (R 4.3.2) tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0) tidyr 1.3.1 2024-01-24 [1] CRAN (R 4.3.2) tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.3.2) tidyverse 2.0.0 2023-02-22 [1] CRAN (R 4.3.0) timechange 0.3.0 2024-01-18 [1] CRAN (R 4.3.0) tzdb 0.4.0 2023-05-12 [1] CRAN (R 4.3.0) urlchecker 1.0.1 2021-11-30 [1] CRAN (R 4.3.0) usethis 2.2.3 2024-02-19 [1] CRAN (R 4.3.2) utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.0) vcfR 1.15.0 2023-12-08 [1] CRAN (R 4.3.0) vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.0) vegan 2.6-4 2022-10-11 [1] CRAN (R 4.3.0) viridisLite 0.4.2 2023-05-02 [1] CRAN (R 4.3.0) withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.0) xfun 0.43 2024-03-25 [1] CRAN (R 4.3.2) xtable 1.8-4 2019-04-21 [1] CRAN (R 4.3.0) XVector 0.42.0 2023-10-24 [1] Bioconductor yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.0) zlibbioc 1.48.2 2024-03-13 [1] Bioconductor 3.18 (R 4.3.3)

[1] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library

V ── Loaded and on-disk version mismatch.

thierrygosselin commented 4 months ago

I cannot help you if I cannot reproduce the problem.

I can fix the Warning message with rlang but the rest is impossible for me to reproduce and help you. You don't even mention what is the function you are using to get this problem : Error in markers %<>% dplyr::mutate(REF = stringi::stri_sub(str = nuc.data, :

Consequently, when reporting an issue, make sure to include:

Describe the bug A clear and concise description of what the bug is.

To Reproduce Include the steps to reproduce the behavior:

thierrygosselin commented 4 months ago

The could not find function "%<>%"

This function %<>% is from package magrittr, it's the compound assignment pipe operator and the package should be installed when you first installed radiator, if not already in your arsenal of tools.

devtools::session_info() results show that you have the latest version of it on your computer

All my script using genlight objects works, so my guess is that the problem stem from something inside your genlight object...

send it by email and include how it was generated.

bmillerlab commented 4 months ago

Hello, I can send you part of the information you requested, but I know how to send just the genlight file. I could send the full .RData file. Would that be OK?

For the rest:

Describe the bug A clear and concise description of what the bug is. I copied the tidy_genlight script to my rstudio session and used it to make the function "tidy_genlight". The first time I ran it I got this error - Error in radiator_packages_dep(package = "adegenet") : could not find function "radiator_packages_dep"

So I went back and hashtagged the line 69- radiator_packages_dep(package = "adegenet")

Then that error went away when I ran the command again and I got the new error- Error in markers %<>% dplyr::mutate(REF = stringi::stri_sub(str = nuc.data, : could not find function "%<>%"

To Reproduce Include the steps to reproduce the behavior:

the exact command (function, arguments, values) used - "gl" is my genlight which I produced using dartR version 2.9.7.

tidygl <- tidy_genlight( gl, tidy = TRUE, gds = TRUE, write = FALSE, verbose = FALSE, parallel.core = parallel::detectCores() - 1 )

the complete error message you're getting

Error in markers %<>% dplyr::mutate(REF = stringi::stri_sub(str = nuc.data, : could not find function "%<>%"

the output of devtools::session_info -see my message above

complete data required to reproduce the problem, a subset of it. The data remains confidential.

I'm not sure how to send a genlight object by email, I will do that if told how. I tried to google how to do it, but could not find anything that helped me figure that out really, just saw that people apparently do send them.

I can say that I worked on my vcf using bcftools and plink and then used bioalcidaejdk to convert it to a matrix that I read into rstudio using SNPready. After working on it with that software I got it into Rstudio using Matrix and data.table and converted it to a genlight using dartR. Since then I have been using it with dartR, adegenet, and other R programs.

Thank you for the help.

thierrygosselin commented 4 months ago

How to save a genlight object:

`saveRDS(object = your.genlight.obj, file = "the.filename")

thierrygosselin commented 4 months ago

So just so that I understand how the genlight was generated from NGS data:

That is a lot of steps where things will go wrong...

Here is a couple of suggestion to make your life easier with NGS datasets:

thierrygosselin commented 4 months ago

You're using radiator the wrong way, and my guess is that you are probably making errors in the other R packages and software above as well.

When you have a function available inside a package copy and modify the script to work on it is fine, but should be done when you know what to do in R, you're obviously a beginner in R, so first... welcome!

The road will be bumpy but worth it. Look at my suggestions in the last post it will make it easier for you.

Good reading to start learning R for science: R for datas science

I suggest you work on a subsample of you VCF file to get to know your dataset and the programs you'll be using. Get some outside help (PhD, PostDoc).

?tidy_genlight

Will load the documentation in RStudio.

Start a new season in R Studio, no object in the environment. Delete / uninstall radiator, and install it again.

library(radiator)
# this will load radiator and the required packages.
# when you do this and run my functions, all the errors you are getting will disapear
# Then you do this: 

tidygl <- tidy_genlight(
gl,
tidy = TRUE,
gds = TRUE,
write = TRUE,
verbose = TRUE,
parallel.core = parallel::detectCores() - 1
)

Quick question: why use radiator ?

thierrygosselin commented 4 months ago

Re-open if experiencing a problem with what I shown