RajLabMSSM / echolocatoR

Automated statistical and functional fine-mapping pipeline with extensive API access to datasets.
https://rajlabmssm.github.io/echolocatoR
MIT License
30 stars 11 forks source link

Error when running `finemap_loci` twice in a row #97

Closed bschilder closed 1 year ago

bschilder commented 1 year ago

1. Bug description

finemap_loci hits errors when run twice in a row.

Console output

# Paste console output here (e.g. from R/python/command line)

Expected behaviour

Import prior results.

2. Reproducible example

Code

topSNPs <- echodata::topSNPs_Nalls2019
fullSS_path <- echodata::example_fullSS(dataset = "Nalls2019")

### Run 1 ####
res <- echolocatoR::finemap_loci(
  fullSS_path = fullSS_path,
  topSNPs = topSNPs,
  loci = c("BST1","MEX3C"),
  finemap_methods = c("ABF","FINEMAP","SUSIE"),
  dataset_name = "Nalls23andMe_2019",
  fullSS_genome_build = "hg19",
  bp_distance = 10000,
  munged = TRUE)

#### Run 2 ####

res <- echolocatoR::finemap_loci(
  fullSS_path = fullSS_path,
  topSNPs = topSNPs,
  loci = c("BST1","MEX3C"),
  finemap_methods = c("ABF","FINEMAP","SUSIE"),
  dataset_name = "Nalls23andMe_2019",
  fullSS_genome_build = "hg19",
  bp_distance = 10000,
  munged = TRUE)

3. Session info

``` R Under development (unstable) (2022-03-03 r81847) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.4 LTS Matrix products: default BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] echolocatoR_2.0.0 survival_3.3-1 loaded via a namespace (and not attached): [1] rappdirs_0.3.3 rtracklayer_1.57.0 GGally_2.1.2 R.methodsS3_1.8.2 [5] tidyr_1.2.0 echoLD_0.99.5 ggplot2_3.3.6 bit64_4.0.5 [9] knitr_1.40 irlba_2.3.5 DelayedArray_0.23.1 R.utils_2.12.0 [13] data.table_1.14.2 rpart_4.1.16 KEGGREST_1.37.3 RCurl_1.98-1.8 [17] AnnotationFilter_1.21.0 generics_0.1.3 BiocGenerics_0.43.1 GenomicFeatures_1.49.6 [21] callr_3.7.2 usethis_2.1.6 RSQLite_2.2.16 proxy_0.4-27 [25] bit_4.0.4 tzdb_0.3.0 xml2_1.3.3 httpuv_1.6.5 [29] SummarizedExperiment_1.27.2 assertthat_0.2.1 viridis_0.6.2 xfun_0.32 [33] hms_1.1.2 promises_1.2.0.1 fansi_1.0.3 restfulr_0.0.15 [37] progress_1.2.2 dbplyr_2.2.1 readxl_1.4.1 Rgraphviz_2.41.1 [41] igraph_1.3.4 DBI_1.1.3 htmlwidgets_1.5.4 reshape_0.8.9 [45] downloadR_0.99.3 stats4_4.2.0 purrr_0.3.4 ellipsis_0.3.2 [49] dplyr_1.0.9 backports_1.4.1 biomaRt_2.53.2 deldir_1.0-6 [53] MatrixGenerics_1.9.1 vctrs_0.4.1 Biobase_2.57.1 remotes_2.4.2 [57] ensembldb_2.21.4 cachem_1.0.6 BSgenome_1.65.2 checkmate_2.1.0 [61] GenomicAlignments_1.33.1 prettyunits_1.1.1 cluster_2.1.4 ape_5.6-2 [65] dir.expiry_1.5.0 lazyeval_0.2.2 crayon_1.5.1 basilisk.utils_1.9.1 [69] crul_1.2.0 pkgconfig_2.0.3 GenomeInfoDb_1.33.5 nlme_3.1-159 [73] pkgload_1.3.0 ProtGenerics_1.29.0 XGR_1.1.8 nnet_7.3-17 [77] devtools_2.4.4 rlang_1.0.4 lifecycle_1.0.1 miniUI_0.1.1.1 [81] filelock_1.0.2 httpcode_0.3.0 BiocFileCache_2.5.0 echotabix_0.99.7 [85] dichromat_2.0-0.1 cellranger_1.1.0 coloc_5.2.0 matrixStats_0.62.0 [89] graph_1.75.0 Matrix_1.4-0 osfr_0.2.8 boot_1.3-28 [93] base64enc_0.1-3 processx_3.7.0 png_0.1-7 viridisLite_0.4.1 [97] rjson_0.2.21 rootSolve_1.8.2.3 bitops_1.0-7 R.oo_1.25.0 [101] ggnetwork_0.5.10 Biostrings_2.65.3 blob_1.2.3 mixsqp_0.3-43 [105] stringr_1.4.1 echoplot_0.99.2 dnet_1.1.7 readr_2.1.2 [109] jpeg_0.1-9 S4Vectors_0.35.1 echodata_0.99.11 scales_1.2.1 [113] memoise_2.0.1 magrittr_2.0.3 plyr_1.8.7 hexbin_1.28.2 [117] zlibbioc_1.43.0 compiler_4.2.0 echoconda_0.99.6 BiocIO_1.7.1 [121] RColorBrewer_1.1-3 Rsamtools_2.13.4 cli_3.3.0 urlchecker_1.0.1 [125] XVector_0.37.1 echoannot_0.99.7 patchwork_1.1.2 ps_1.7.1 [129] htmlTable_2.4.1 Formula_1.2-4 MASS_7.3-58.1 tidyselect_1.1.2 [133] stringi_1.7.8 yaml_2.3.5 supraHex_1.35.0 latticeExtra_0.6-30 [137] ggrepel_0.9.1 grid_4.2.0 VariantAnnotation_1.43.3 tools_4.2.0 [141] lmom_2.9 parallel_4.2.0 rstudioapi_0.14 foreign_0.8-82 [145] piggyback_0.1.4 gridExtra_2.3 gld_2.6.5 farver_2.1.1 [149] digest_0.6.29 snpStats_1.47.1 BiocManager_1.30.18 shiny_1.7.2 [153] Rcpp_1.0.9 GenomicRanges_1.49.1 later_1.3.0 OrganismDbi_1.39.1 [157] httr_1.4.4 AnnotationDbi_1.59.1 RCircos_1.2.2 ggbio_1.45.0 [161] biovizBase_1.45.0 colorspace_2.0-3 brio_1.1.3 XML_3.99-0.10 [165] fs_1.5.2 reticulate_1.25 IRanges_2.31.2 splines_4.2.0 [169] RBGL_1.73.0 expm_0.999-6 echofinemap_0.99.2 basilisk_1.9.2 [173] Exact_3.1 sessioninfo_1.2.2 xtable_1.8-4 jsonlite_1.8.0 [177] testthat_3.1.4 susieR_0.12.19 R6_2.5.1 profvis_0.3.7 [181] Hmisc_4.7-1 pillar_1.8.1 htmltools_0.5.3 mime_0.12 [185] glue_1.6.2 fastmap_1.1.0 DT_0.24 BiocParallel_1.31.12 [189] class_7.3-20 codetools_0.2-18 pkgbuild_1.3.1 mvtnorm_1.1-3 [193] utf8_1.2.2 lattice_0.20-45 tibble_3.1.8 curl_4.3.2 [197] DescTools_0.99.45 zip_2.2.0 openxlsx_4.2.5 interp_1.1-3 [201] munsell_0.5.0 e1071_1.7-11 GenomeInfoDbData_1.2.8 reshape2_1.4.4 [205] gtable_0.3.0 ```
bschilder commented 1 year ago

Solution

In extract_snp_subset, reorder preexisting file priority:

 #### Priority 1: Check if multi-finemap results exists ####
  if (file.exists(multi_path) & isFALSE(force_new_subset)){
    messager("+ Importing pre-existing file:",multi_path, v=verbose)
    echodata::check_if_empty(multi_path)
    query <- data.table::fread(multi_path)
    return(query)

    #### Priority 2: Check is subset exists ####
  } else if(file.exists(subset_path) & isFALSE(force_new_subset)){
      messager("+ Importing pre-existing file:",subset_path, v=verbose)
      echodata::check_if_empty(subset_path)
      query <- data.table::fread(subset_path)
      return(query)

  } else {
    #### Priority 3: Convert and query ####
bschilder commented 1 year ago

Also force_new_finemap= was set to TRUE by default. Have set back to FALSE.