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

Sexy markers: error operator is invalid for atomic vectors #118

Closed MboiTui closed 3 years ago

MboiTui commented 3 years ago

Describe the bug When I run the sexy_markers function interactively, if I answer 'n' (i.e. no) the step asking Do you want to continue filtering using long distance ld ? (y/n):, it returns the following error:

Do you want to continue filtering using long distance ld ? (y/n): n

Computation time, overall: 10 sec ############################# completed filter_ld ##############################

Sex-ratio (F/M): 0.82 Error: $ operator is invalid for atomic vectors

To Reproduce I am running the sexy_markers function interactively. The input is a vcf file produced by vcf tools. I checked that the strata file was read in properly with summary_strata.

Steps 1. command sexy_markers(data="path/to/input/vcf.vcf", strata="path/to/input/strata.tsv")

i do not blacklist individual samples i filter short ld with 1 mac when asked if i want to continue filtering using long distance ld, I answer "n" error message below is returned 2. complete error message Error: $ operator is invalid for atomic vectors 3. devtools::session_info() ─ Session info ───────────────────────────────────────────────────────────────────────────────────────── setting value
version R version 4.0.3 (2020-10-10) os macOS High Sierra 10.13.6
system x86_64, darwin17.0
ui RStudio
language (EN)
collate en_AU.UTF-8
ctype en_AU.UTF-8
tz Australia/Brisbane
date 2021-02-04

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────── package version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2)
backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2)
BiocGenerics 0.34.0 2020-04-27 [1] Bioconductor
Biostrings 2.56.0 2020-04-27 [1] Bioconductor
bitops 1.0-6 2013-08-17 [1] CRAN (R 4.0.2)
callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.2)
cli 2.1.0 2020-10-12 [1] CRAN (R 4.0.2)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.2)
conquer 1.0.2 2020-08-27 [1] CRAN (R 4.0.2)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.2)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.1)
data.table 1.13.0 2020-07-24 [1] CRAN (R 4.0.2)
desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.2)
devtools
2.3.2 2020-09-18 [1] CRAN (R 4.0.2)
digest 0.6.26 2020-10-17 [1] CRAN (R 4.0.3)
dplyr 1.0.2 2020-08-18 [1] CRAN (R 4.0.2)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.1)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.2)
farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.2)
fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
gdsfmt 1.24.1 2020-06-16 [1] Bioconductor
generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.2)
GenomeInfoDb 1.24.2 2020-06-15 [1] Bioconductor
GenomeInfoDbData 1.2.3 2020-10-19 [1] Bioconductor
GenomicRanges 1.40.0 2020-04-27 [1] Bioconductor
ggplot2 3.3.2 2020-06-19 [1] CRAN (R 4.0.2)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.2)
hms 0.5.3 2020-01-08 [1] CRAN (R 4.0.2)
htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2)
IRanges 2.22.2 2020-05-21 [1] Bioconductor
knitr 1.30 2020-09-22 [1] CRAN (R 4.0.2)
labeling 0.3 2014-08-23 [1] CRAN (R 4.0.2)
lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.3)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.2)
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.2)
Matrix 1.2-18 2019-11-27 [1] CRAN (R 4.0.3)
MatrixModels 0.4-1 2015-08-22 [1] CRAN (R 4.0.2)
matrixStats 0.57.0 2020-09-25 [1] CRAN (R 4.0.2)
memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.2)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.2)
pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2)
pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.2)
processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.2)
ps 1.4.0 2020-10-07 [1] CRAN (R 4.0.2)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.2)
quantreg 5.74 2020-10-18 [1] CRAN (R 4.0.2)
R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.2)
radiator 1.1.9 2021-02-04 [1] Github (thierrygosselin/radiator@5c6b865) Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2)
RCurl 1.98-1.2 2020-04-18 [1] CRAN (R 4.0.2)
readr 1.4.0 2020-10-05 [1] CRAN (R 4.0.2)
remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2)
rlang 0.4.8 2020-10-08 [1] CRAN (R 4.0.2)
rmarkdown 2.4 2020-09-30 [1] CRAN (R 4.0.3)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.2)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.2)
S4Vectors 0.26.1 2020-05-16 [1] Bioconductor
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.2)
SeqArray 1.28.1 2020-06-16 [1] Bioconductor
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2)
SparseM 1.78 2019-12-13 [1] CRAN (R 4.0.2)
stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.2)
tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.2)
tidyr 1.1.2 2020-08-27 [1] CRAN (R 4.0.2)
tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.2)
tinytex 0.26 2020-09-22 [1] CRAN (R 4.0.2)
usethis
1.6.3 2020-09-17 [1] CRAN (R 4.0.2)
vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2)
withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2)
xfun 0.18 2020-09-29 [1] CRAN (R 4.0.2)
XVector 0.28.0 2020-04-27 [1] Bioconductor
yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.2)
zlibbioc 1.34.0 2020-04-27 [1] Bioconductor

[1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

4. sample data example.vcf.zip

MboiTui commented 3 years ago

5. Further information If i instead filter for long distance ld, the same error is returned after the completion of filter_ld Error = 'Error: $ operator is invalid for atomic vectors'

thierrygosselin commented 3 years ago

I'm unable to reproduce the error you're getting with my data. Your's in incomplet if I want to run the same code, I'll need the strata file you used.

Re-open the issue if this is still relevant for you

jcaccavo commented 1 year ago

I am having this same issue, both when filtering for long distance ld and when not.

Sex-ratio (F/M): 1.53
Error in SeqArray::seqGetData(data, "annotation/format/DP")$data : 
  $ operator is invalid for atomic vectors

Computation time, overall: 6581 sec
############################ completed sexy_markers ############################

Similarly, I am running the sexy_markers function interactively. The input is a vcf file produced by Stacks. I checked that the strata file was read in properly with summary_strata.

You can download the original .csv file I used to create the strata file here.

I prepared this .csv file for use as the strata file, and checked its validity, as follows:

strata_sex <- "dmawsoni_sex.csv" strata_sex <- readr::read_csv(strata_sex)

# Rows: 109 Columns: 2                                                                                                                 
# ── Column specification ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
# Delimiter: ","
# chr (2): INDIVIDUALS, STRATA
# 
# ℹ Use `spec()` to retrieve the full column specification for this data.
# ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

pop.levels_sex <- c("M","F","U") strata_sex$STRATA <- factor(strata_sex$STRATA, levels = pop.levels_sex) strata_sex <- strata_sex[order(strata_sex$STRATA),] radiator::summary_strata(strata_sex)

# Number of strata: 3
# Number of individuals: 109
# 
# Number of ind/strata:
#   M = 44
# F = 64
# U = 1
# 
# Number of duplicate id: 0

I then ran sexy_markers as follows with a vcf file available for download from here, and which was checked as follows: detect_genomic_format(data = "3_subarea_p3_p1r0.6_populations.snps.vcf") # [1] "vcf.file"

dm_sex <- radiator::sexy_markers(data = "3_subarea_p3_p1r0.6_populations.snps.vcf",
                                 strata = strata_sex)

I am happy to provide further information as needed. Thanks in advance for your help! The R session info is below. sessionInfo()

R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] radiator_1.2.5 adegenet_2.1.9 ade4_1.7-20   

loaded via a namespace (and not attached):
 [1] pkgload_1.3.2       bit64_4.0.5         vroom_1.6.1         splines_4.2.2       shiny_1.7.4         assertthat_0.2.1   
 [7] BiocManager_1.30.19 remotes_2.4.2       sessioninfo_1.2.2   pillar_1.8.1        lattice_0.20-45     glue_1.6.2         
[13] digest_0.6.31       promises_1.2.0.1    colorspace_2.1-0    htmltools_0.5.4     httpuv_1.6.8        Matrix_1.5-3       
[19] plyr_1.8.8          pkgconfig_2.0.3     devtools_2.4.5      purrr_1.0.1         xtable_1.8-4        scales_1.2.1       
[25] processx_3.8.0      later_1.3.0         tzdb_0.3.0          tibble_3.1.8        mgcv_1.8-41         generics_0.1.3     
[31] ggplot2_3.4.0       usethis_2.1.6       ellipsis_0.3.2      withr_2.5.0         cachem_1.0.6        cli_3.6.0          
[37] magrittr_2.0.3      crayon_1.5.2        mime_0.12           memoise_2.0.1       ps_1.7.2            fs_1.6.0           
[43] fansi_1.0.4         nlme_3.1-161        MASS_7.3-58.2       pkgbuild_1.4.0      vegan_2.6-4         profvis_0.3.7      
[49] tools_4.2.2         prettyunits_1.1.1   hms_1.1.2           lifecycle_1.0.3     stringr_1.5.0       munsell_0.5.0      
[55] cluster_2.1.4       callr_3.7.3         compiler_4.2.2      rlang_1.0.6         grid_4.2.2          rstudioapi_0.14    
[61] htmlwidgets_1.6.1   igraph_1.3.5        miniUI_0.1.1.1      gtable_0.3.1        DBI_1.1.3           reshape2_1.4.4     
[67] R6_2.5.1            dplyr_1.0.10        bit_4.0.5           fastmap_1.1.0       seqinr_4.2-23       utf8_1.2.2         
[73] permute_0.9-7       readr_2.1.3         ape_5.6-2           stringi_1.7.12      parallel_4.2.2      Rcpp_1.0.10        
[79] vctrs_0.5.2         tidyselect_1.2.0    urlchecker_1.0.1