broadinstitute / infercnv

Inferring CNV from Single-Cell RNA-Seq
Other
557 stars 164 forks source link

STEP 15 error when using NULL reference #461

Closed tbrunetti closed 2 years ago

tbrunetti commented 2 years ago

I am using infercnv using NULL as the reference on a single sample. I have tried to change my code several ways (i.e. setting analysis_mode="subclusters" and also using the default setting for the analysis_mode)

Oddly enough, I can get this to work if I have a reference set...

This is how I am generating the object and running it:

infercnv_obj = CreateInfercnvObject(raw_counts_matrix= combined_matrix,
                                    annotations_file= cell_idents,
                                    delim="\t",
                                    gene_order_file=gene_df,
                                    ref_group_names= NULL)

infercnv_obj = infercnv::run(infercnv_obj,
                             cutoff=0.1,  # use 1 for smart-seq, 0.1 for 10x-genomics
                             out_dir=outdir,  # dir is auto-created for storing outputs
                             cluster_by_groups=T,   # cluster
                             denoise=T,
                             #analysis_mode="subclusters",
                             num_threads = 10,
                             output_format = "pdf",
                             HMM=TRUE, resume_mode= F)

No matter, how I try to change it, I continue to get this error and I have tried it on different samples as well. How should I troubleshoot this:

        STEP 15: computing tumor subclusters via leiden

INFO [2022-09-18 22:09:41] define_signif_tumor_subclusters(p_val=0.1
INFO [2022-09-18 22:09:41] define_signif_tumor_subclusters(), tumor: d5
Calculating gene variances
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error in `$<-.data.frame`(`*tmp*`, "variance.expected", value = 0) : 
  replacement has 1 row, data has 0
Calls: <Anonymous> ... FindVariableFeatures.default -> $<- -> $<-.data.frame
Execution halted

Here is my sessioninfo:R version 4.1.1 (2021-08-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS: /home/tonya/R-4.1.1/lib/libRblas.so LAPACK: /home/tonya/R-4.1.1/lib/libRlapack.so

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] 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 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] dplyr_1.0.9 remotes_2.4.2 [3] infercnv_1.13.0 profvis_0.3.7 [5] SummarizedExperiment_1.24.0 MatrixGenerics_1.6.0 [7] matrixStats_0.62.0 data.table_1.14.2 [9] Matrix_1.3-4 EnsDb.Hsapiens.v86_2.99.0 [11] ensembldb_2.18.4 AnnotationFilter_1.18.0 [13] GenomicFeatures_1.46.5 AnnotationDbi_1.56.2 [15] Biobase_2.54.0 GenomicRanges_1.46.1 [17] GenomeInfoDb_1.30.1 IRanges_2.28.0 [19] S4Vectors_0.32.4 BiocGenerics_0.40.0 [21] sp_1.5-0 SeuratObject_4.1.0 [23] Seurat_4.1.1 bmcite.SeuratData_0.3.0 [25] SeuratData_0.2.2

loaded via a namespace (and not attached): [1] utf8_1.2.2 reticulate_1.25 [3] tidyselect_1.1.2 RSQLite_2.2.16 [5] htmlwidgets_1.5.4 grid_4.1.1 [7] BiocParallel_1.28.3 Rtsne_0.16 [9] munsell_0.5.0 codetools_0.2-18 [11] ica_1.0-3 future_1.27.0 [13] miniUI_0.1.1.1 argparse_2.1.6 [15] spatstat.random_2.2-0 colorspace_2.0-3 [17] progressr_0.10.1 filelock_1.0.2 [19] SingleCellExperiment_1.16.0 ROCR_1.0-11 [21] tensor_1.5 listenv_0.8.0 [23] GenomeInfoDbData_1.2.7 polyclip_1.10-0 [25] bit64_4.0.5 TH.data_1.1-1 [27] coda_0.19-4 parallelly_1.32.1 [29] vctrs_0.4.1 generics_0.1.3 [31] lambda.r_1.2.4 BiocFileCache_2.2.1 [33] fastcluster_1.2.3 R6_2.5.1 [35] doParallel_1.0.17 locfit_1.5-9.6 [37] bitops_1.0-7 spatstat.utils_2.3-1 [39] cachem_1.0.6 DelayedArray_0.20.0 [41] assertthat_0.2.1 promises_1.2.0.1 [43] BiocIO_1.4.0 scales_1.2.1 [45] multcomp_1.4-20 rgeos_0.5-9 [47] gtable_0.3.0 globals_0.16.0 [49] goftest_1.2-3 sandwich_3.0-2 [51] rlang_1.0.4 splines_4.1.1 [53] rtracklayer_1.54.0 lazyeval_0.2.2 [55] rjags_4-13 spatstat.geom_2.4-0 [57] yaml_2.3.5 reshape2_1.4.4 [59] abind_1.4-5 httpuv_1.6.5 [61] tools_4.1.1 ggplot2_3.3.6 [63] gplots_3.1.3 ellipsis_0.3.2 [65] spatstat.core_2.4-4 RColorBrewer_1.1-3 [67] phyclust_0.1-30 ggridges_0.5.3 [69] Rcpp_1.0.9 plyr_1.8.7 [71] progress_1.2.2 zlibbioc_1.40.0 [73] purrr_0.3.4 RCurl_1.98-1.8 [75] prettyunits_1.1.1 rpart_4.1-15 [77] deldir_1.0-6 pbapply_1.5-0 [79] cowplot_1.1.1 zoo_1.8-10 [81] ggrepel_0.9.1 cluster_2.1.2 [83] magrittr_2.0.3 futile.options_1.0.1 [85] scattermore_0.8 lmtest_0.9-40 [87] RANN_2.6.1 mvtnorm_1.1-3 [89] parallelDist_0.2.6 ProtGenerics_1.26.0 [91] fitdistrplus_1.1-8 hms_1.1.2 [93] patchwork_1.1.2 mime_0.12 [95] xtable_1.8-4 XML_3.99-0.10 [97] gridExtra_2.3 compiler_4.1.1 [99] biomaRt_2.50.3 tibble_3.1.8 [101] KernSmooth_2.23-20 crayon_1.5.1 [103] htmltools_0.5.3 mgcv_1.8-36 [105] later_1.3.0 libcoin_1.0-9 [107] tidyr_1.2.0 RcppParallel_5.1.5 [109] DBI_1.1.3 formatR_1.12 [111] dbplyr_2.2.1 MASS_7.3-54 [113] rappdirs_0.3.3 cli_3.3.0 [115] parallel_4.1.1 igraph_1.3.4 [117] pkgconfig_2.0.3 GenomicAlignments_1.30.0 [119] coin_1.4-2 plotly_4.10.0 [121] spatstat.sparse_2.1-1 xml2_1.3.3 [123] foreach_1.5.2 XVector_0.34.0 [125] stringr_1.4.1 digest_0.6.29 [127] sctransform_0.3.4 RcppAnnoy_0.0.19 [129] spatstat.data_2.2-0 Biostrings_2.62.0 [131] leiden_0.4.2 edgeR_3.36.0 [133] uwot_0.1.14 restfulr_0.0.15 [135] curl_4.3.2 gtools_3.9.3 [137] modeltools_0.2-23 shiny_1.7.2 [139] Rsamtools_2.10.0 rjson_0.2.21 [141] lifecycle_1.0.1 nlme_3.1-152 [143] jsonlite_1.8.0 futile.logger_1.4.3 [145] limma_3.50.3 viridisLite_0.4.1 [147] fansi_1.0.3 pillar_1.8.1 [149] lattice_0.20-44 KEGGREST_1.34.0 [151] fastmap_1.1.0 httr_1.4.4 [153] survival_3.2-11 glue_1.6.2 [155] png_0.1-7 iterators_1.0.14 [157] bit_4.0.4 stringi_1.7.8 [159] blob_1.2.3 caTools_1.18.2 [161] memoise_2.0.1 ape_5.6-2 [163] irlba_2.3.5 future.apply_1.9.0

KaWingLee9 commented 2 years ago

Hi. I have met the same problem with you. I think maybe the problem maybe the version of infercnv. I successfully ran the script when I use the version 1.6.0. I downloaded the package in https://anaconda.org/bioconda/bioconductor-infercnv/files, and use 'conda install --use-local' for installation.

tbrunetti commented 2 years ago

Thanks for the tip @kelvinlee760948065 ! What version of infercnv did it fail for you? This would be a pretty significant downgrade from my current version

GeorgescuC commented 2 years ago

Hi @tbrunetti @kelvinlee760948065 ,

Thanks for reporting the issue. The issue was that the z-score filtering used to mask genes that have too much variation even in references (such as MHC genes) before running the subclustering needs references that don't exist when they are set to NULL and that case was not handled, resulting in all genes being masked instead. The issue should be fixed in the latest commit if you can update your install of infercnv from the master branch.

Regards, Christophe.

tbrunetti commented 2 years ago

@GeorgescuC thank you for the response and for the quick fix! I will test it out and let you know :+1: much appreciated!

tbrunetti commented 2 years ago

@GeorgescuC Confirmed this resolves my issue. Thanks!

lifan18 commented 2 years ago

Hi @GeorgescuC, thank you for your updates! I was using 10X dataset and got the same error by setting "ref_group_names=NULL".

Calculating gene variances
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error in `$<-.data.frame`(`*tmp*`, "variance.expected", value = 0) :
  replacement has 1 row, data has 0
Calls: <Anonymous> ... FindVariableFeatures.default -> $<- -> $<-.data.frame
Execution halted

Although, I replaced the new "inferCNV_tumor_subclusters.R" file following your updates, this error still happens.

May you have any suggestion for this case?

Thank you very much!