neurogenomics / MAGMA_Celltyping

Find causal cell-types underlying complex trait genetics
https://neurogenomics.github.io/MAGMA_Celltyping
71 stars 31 forks source link

Bug report:Error in if (is.null(N) | is.na(N)) { : argument is of length zero #128

Closed ZhengGongwei closed 1 year ago

ZhengGongwei commented 1 year ago

Bug description

When i ran the example demo,i got a bug: Error in if (is.null(N) | is.na(N)) { : argument is of length zero

Console output

path_formatted <- MAGMA.Celltyping::get_example_gwas( trait = "prospective_memory") Importing munged GWAS summary statistics: prospective_memory Loading required namespace: piggyback Loading required namespace: gh ℹ Downloading "prospective_memory.ukb.tsv.gz"... |======================================================================| 100% Saving decompressed copy of path_formatted ==> /tmp/Rtmp8nemvX/prospective_memory.ukb.tsv

genesOutPath <- MAGMA.Celltyping::map_snps_to_genes( path_formatted = path_formatted, genome_build = "GRCh37") Installed MAGMA version: v1.10 Skipping MAGMA installation. The desired_version of MAGMA is currently installed: v1.10 Using: MAGMA.Celltyping Using existing genome_ref found in storage_dir.

Session info

[1] backports_1.4.1 AnnotationHub_3.6.0 [3] BiocFileCache_2.6.0 plyr_1.8.7 [5] googleAuthR_2.0.0 lazyeval_0.2.2 [7] splines_4.2.1 orthogene_1.4.0 [9] ewceData_1.6.0 BiocParallel_1.32.0 [11] GenomeInfoDb_1.34.0 ggplot2_3.3.6 [13] digest_0.6.30 yulab.utils_0.0.5 [15] htmltools_0.5.3 RNOmni_1.0.1 [17] fansi_1.0.3 magrittr_2.0.3 [19] memoise_2.0.1 BSgenome_1.66.0 [21] limma_3.54.0 Biostrings_2.66.0 [23] matrixStats_0.62.0 R.utils_2.12.1 [25] prettyunits_1.1.1 colorspace_2.0-3 [27] blob_1.2.3 rappdirs_0.3.3 [29] gitcreds_0.1.1 crayon_1.5.2 [31] RCurl_1.98-1.6 jsonlite_1.8.3 [33] lme4_1.1-31 VariantAnnotation_1.44.0 [35] ape_5.6-2 glue_1.6.2 [37] gtable_0.3.1 gargle_1.2.1 [39] zlibbioc_1.44.0 XVector_0.38.0 [41] HGNChelper_0.8.1 DelayedArray_0.24.0 [43] car_3.1-1 SingleCellExperiment_1.20.0 [45] BiocGenerics_0.44.0 abind_1.4-5 [47] scales_1.2.1 DBI_1.1.3 [49] rstatix_0.7.0 Rcpp_1.0.9 [51] viridisLite_0.4.1 xtable_1.8-4 [53] progress_1.2.2 gridGraphics_0.5-1 [55] tidytree_0.4.1 bit_4.0.4 [57] stats4_4.2.1 htmlwidgets_1.5.4 [59] httr_1.4.4 ellipsis_0.3.2 [61] pkgconfig_2.0.3 XML_3.99-0.9 [63] R.methodsS3_1.8.2 dbplyr_2.2.1 [65] utf8_1.2.2 ggplotify_0.1.0 [67] tidyselect_1.2.0 rlang_1.0.6 [69] reshape2_1.4.4 later_1.3.0 [71] AnnotationDbi_1.60.0 munsell_0.5.0 [73] BiocVersion_3.16.0 tools_4.2.1 [75] cachem_1.0.6 cli_3.4.1 [77] generics_0.1.3 RSQLite_2.2.18 [79] ExperimentHub_2.6.0 MungeSumstats_1.6.0 [81] broom_1.0.1 stringr_1.4.1 [83] fastmap_1.1.0 ggdendro_0.1.23 [85] yaml_2.3.6 ggtree_3.6.0 [87] babelgene_22.9 bit64_4.0.5 [89] fs_1.5.2 purrr_0.3.5 [91] gh_1.3.0 KEGGREST_1.38.0 [93] gprofiler2_0.2.1 nlme_3.1-160 [95] mime_0.12 R.oo_1.25.0 [97] grr_0.9.5 aplot_0.1.8 [99] xml2_1.3.3 biomaRt_2.54.0 [101] compiler_4.2.1 plotly_4.10.0 [103] filelock_1.0.2 curl_4.3.3 [105] png_0.1-7 interactiveDisplayBase_1.36.0 [107] ggsignif_0.6.4 treeio_1.22.0 [109] tibble_3.1.8 EWCE_1.6.0 [111] homologene_1.4.68.19.3.27 stringi_1.7.8 [113] GenomicFeatures_1.50.1 lattice_0.20-45 [115] Matrix_1.5-1 nloptr_2.0.3 [117] vctrs_0.5.0 pillar_1.8.1 [119] lifecycle_1.0.3 BiocManager_1.30.19 [121] data.table_1.14.4 bitops_1.0-7 [123] httpuv_1.6.6 patchwork_1.1.2 [125] rtracklayer_1.58.0 GenomicRanges_1.50.0 [127] R6_2.5.1 BiocIO_1.8.0 [129] promises_1.2.0.1 gridExtra_2.3 [131] IRanges_2.32.0 codetools_0.2-18 [133] boot_1.3-28 MASS_7.3-58.1 [135] assertthat_0.2.1 SummarizedExperiment_1.28.0 [137] rjson_0.2.21 GenomicAlignments_1.34.0 [139] Rsamtools_2.14.0 S4Vectors_0.36.0 [141] GenomeInfoDbData_1.2.9 parallel_4.2.1 [143] hms_1.1.2 grid_4.2.1 [145] ggfun_0.0.7 minqa_1.2.5 [147] tidyr_1.2.1 MatrixGenerics_1.10.0 [149] carData_3.0-5 ggpubr_0.4.0 [151] piggyback_0.1.4 lubridate_1.8.0 [153] Biobase_2.58.0 shiny_1.7.3 [155] restfulr_0.0.15


I want to know how to fix it.
Many thinks!
bschilder commented 1 year ago

Thanks for reporting this @ZhengGongwei. Could you describe how this was resolved?

ZhengGongwei commented 1 year ago

Thanks for reporting this @ZhengGongwei. Could you describe how this was resolved?

I neglected to specify the N value.

genesOutPath <- MAGMA.Celltyping::map_snps_to_genes( path_formatted = path_formatted, genome_build = "GRCh37",N=XXX) works fine.Thanks!

bschilder commented 1 year ago

Hmm, ok for some reason map_snps_to_genes is not detecting the "N" col in the example GWAS (which is indeed there). Let me fix that (reopening to remind myself).

Screenshot 2022-11-08 at 13 22 51

bschilder commented 1 year ago

Ok, so it turns out this was a very simple fix. Just had to make this line use a || instead of | so that the is.na only gets evaluated when N is not NULL https://github.com/neurogenomics/MAGMA_Celltyping/blob/ae0fa8455f3136dea27119cacece3692c98e2e8f/R/check_n.R#L4