Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, : NA/NaN/Inf in foreign function call (arg 2) #8509

Closed
IrinaVKuznetsova opened this issue Feb 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@IrinaVKuznetsova
Copy link

IrinaVKuznetsova commented Feb 21, 2024

The input raw count matrix has negative values. The core of the problem was introduced by the cell bender v0.3.0-v0.3.1
discussion broadinstitute/CellBender#306

Hi,

I am using Seurat 5, parsing h5 files generated with Cell Bender and creating a Seurat object with count matrices ( 8 samples - 8 count matrices) , which are stored as layers in Seurat 5. When I run FindVariableFeatures() function I am getting an error, which is inconsistent it occurs for different samples. So sometimes it raises for sample S25 another time it manages S25, but occurs in another sample S45, or L55 etc.

Never had this error before, and also checked:
#2387 suggested solution doesn't help as I Normalise data and also do DefaultAssay(object = cell_bender_seurat_filt) <- "RNA"

cell_bender_seurat
An object of class Seurat
36601 features across 48313 samples within 1 assay
Active assay: RNA (36601 features, 0 variable features)
16 layers present: counts.L25, counts.S25, counts.L39, counts.S39, counts.L45, counts.S45, counts.L55, counts.S55,

table([email protected]$orig.ident)
L25 L39 L45 L55 S25 S39 S45 S55
8108 6323 7189 5514 2100 6180 8620 4279 # sum=48313

code:
# parse cell bender h5
cell_bender_merged <- Read_CellBender_h5_Multi_Directory(
    base_path = PATH,
    custom_name = "_feature_bc_matrix_filtered.h5",                #25L_cellbender_feature_bc_matrix_filtered.h5
    sample_names = c("l25", "s25", "l39", "s39", "l45", "s45", "l55", "s55"), 
    merge = FALSE)
# create a list
cell_bender_list = list(L25=cell_bender_merged$l25, S25=cell_bender_merged$s25, 
                        L39=cell_bender_merged$l39, S39=cell_bender_merged$s39,
                        L45=cell_bender_merged$l45, S45=cell_bender_merged$s45, 
                        L55=cell_bender_merged$l55, S55=cell_bender_merged$s55)
# create a Seurat object
cell_bender_seurat <- CreateSeuratObject( counts = cell_bender_list,
                                          names.field = 2,              
                                          names.delim = '_' )
# filter
cell_bender_seurat_filt =subset(cell_bender_seurat, subset= nFeature_RNA > gene_thr_min & nFeature_RNA < gene_thr_max  & percent.mt < mito_thr & percent.ribo < ribo_thr)

cell_bender_seurat_filt<- NormalizeData(object = cell_bender_seurat_filt, normalization.method = "LogNormalize", scale.factor = 10000)
cell_bender_seurat_filt
An object of class Seurat
36601 features across 48313 samples within 1 assay
Active assay: RNA (36601 features, 0 variable features)
 16 layers present: counts.L25, counts.S25, counts.L39, counts.S39, counts.L45, counts.S45, counts.L55, counts.S55, data.L25, data.S25, data.L39, data.S39, data.L45, data.S45, data.L55, data.S55

DefaultAssay(object = cell_bender_seurat_filt) <- "RNA"
cell_bender_seurat_filt<- FindVariableFeatures(cell_bender_seurat_filt, selection.method = "vst", nfeatures = 1000)



Sample S25:
Error in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  NA/NaN/Inf in foreign function call (arg 2)


or

Sample: S45
Error in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  :
  NA/NaN/Inf in foreign function call (arg 2)
In addition: Warning messages:
1: In eval(predvars, data, env) : NaNs produced
2: In hvf.info$variance.expected[not.const] <- 10^fit$fitted :
  number of items to replace is not a multiple of replacement length
3: In eval(predvars, data, env) : NaNs produced

sessionInfo()
R version 4.3.2 (2023-10-31)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS/LAPACK: /data/0_Tools/miniforge3/envs/PDX_manuscript23_v2/lib/libopenblasp-r0.3.26.so; LAPACK version 3.12.0

locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

time zone: Etc/UTC
tzcode source: system (glibc)

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

other attached packages:
[1] patchwork_1.2.0 scCustomize_2.0.1
[3] hdf5r_1.3.9 djvdj_0.1.0
[5] SeuratWrappers_0.3.4 R.utils_2.12.3
[7] R.oo_1.26.0 R.methodsS3_1.8.2
[9] devtools_2.4.5 usethis_2.2.2
[11] scater_1.30.1 scuttle_1.12.0
[13] scDblFinder_1.16.0 SingleCellExperiment_1.24.0
[15] SummarizedExperiment_1.32.0 Biobase_2.62.0
[17] GenomicRanges_1.54.1 GenomeInfoDb_1.38.6
[19] IRanges_2.36.0 S4Vectors_0.40.2
[21] BiocGenerics_0.48.1 MatrixGenerics_1.14.0
[23] matrixStats_1.2.0 Matrix_1.6-5
[25] lubridate_1.9.3 forcats_1.0.0
[27] stringr_1.5.1 dplyr_1.1.4
[29] purrr_1.0.2 readr_2.1.5
[31] tidyr_1.3.1 tibble_3.2.1
[33] ggplot2_3.4.4 tidyverse_2.0.0
[35] WriteXLS_6.5.0 Seurat_5.0.1
[37] SeuratObject_5.0.1 sp_2.1-3
[39] pheatmap_1.0.12 remotes_2.4.2.1

loaded via a namespace (and not attached):
[1] fs_1.6.3 spatstat.sparse_3.0-3
[3] bitops_1.0-7 httr_1.4.7
[5] RColorBrewer_1.1-3 profvis_0.3.8
[7] tools_4.3.2 sctransform_0.4.1
[9] utf8_1.2.4 R6_2.5.1
[11] lazyeval_0.2.2 uwot_0.1.16
[13] urlchecker_1.0.1 withr_3.0.0
[15] gridExtra_2.3 progressr_0.14.0
[17] cli_3.6.2 spatstat.explore_3.2-6
[19] fastDummies_1.7.3 spatstat.data_3.0-4
[21] ggridges_0.5.6 pbapply_1.7-2
[23] Rsamtools_2.18.0 parallelly_1.37.0
[25] sessioninfo_1.2.2 limma_3.58.1
[27] shape_1.4.6 generics_0.1.3
[29] BiocIO_1.12.0 ica_1.0-3
[31] spatstat.random_3.2-2 ggbeeswarm_0.7.2
[33] fansi_1.0.6 abind_1.4-5
[35] lifecycle_1.0.4 yaml_2.3.8
[37] edgeR_4.0.15 snakecase_0.11.1
[39] SparseArray_1.2.4 Rtsne_0.17
[41] paletteer_1.6.0 grid_4.3.2
[43] promises_1.2.1 dqrng_0.3.2
[45] crayon_1.5.2 miniUI_0.1.1.1
[47] lattice_0.22-5 beachmat_2.18.1
[49] cowplot_1.1.3 pillar_1.9.0
[51] metapod_1.10.1 rjson_0.2.21
[53] xgboost_2.0.3.1 future.apply_1.11.1
[55] codetools_0.2-19 leiden_0.4.3.1
[57] glue_1.7.0 data.table_1.15.0
[59] vctrs_0.6.5 png_0.1-8
[61] spam_2.10-0 gtable_0.3.4
[63] rematch2_2.1.2 cachem_1.0.8
[65] S4Arrays_1.2.0 mime_0.12
[67] survival_3.5-8 statmod_1.5.0
[69] bluster_1.12.0 ellipsis_0.3.2
[71] fitdistrplus_1.1-11 ROCR_1.0-11
[73] nlme_3.1-164 bit64_4.0.5
[75] RcppAnnoy_0.0.22 irlba_2.3.5.1
[77] vipor_0.4.7 KernSmooth_2.23-22
[79] colorspace_2.1-0 ggrastr_1.0.2
[81] tidyselect_1.2.0 bit_4.0.5
[83] compiler_4.3.2 BiocNeighbors_1.20.2
[85] DelayedArray_0.28.0 plotly_4.10.4
[87] rtracklayer_1.62.0 scales_1.3.0
[89] lmtest_0.9-40 digest_0.6.34
[91] goftest_1.2-3 spatstat.utils_3.0-4
[93] XVector_0.42.0 htmltools_0.5.7
[95] pkgconfig_2.0.3 sparseMatrixStats_1.14.0
[97] fastmap_1.1.1 GlobalOptions_0.1.2
[99] rlang_1.1.3 htmlwidgets_1.6.4
[101] shiny_1.8.0 DelayedMatrixStats_1.24.0
[103] zoo_1.8-12 jsonlite_1.8.8
[105] BiocParallel_1.36.0 BiocSingular_1.18.0
[107] RCurl_1.98-1.14 magrittr_2.0.3
[109] GenomeInfoDbData_1.2.11 dotCall64_1.1-1
[111] munsell_0.5.0 Rcpp_1.0.12
[113] viridis_0.6.5 reticulate_1.35.0
[115] stringi_1.8.3 zlibbioc_1.48.0
[117] MASS_7.3-60.0.1 plyr_1.8.9
[119] pkgbuild_1.4.3 parallel_4.3.2
[121] listenv_0.9.1 ggrepel_0.9.5
[123] deldir_2.0-2 Biostrings_2.70.2
[125] splines_4.3.2 tensor_1.5
[127] circlize_0.4.15 hms_1.1.3
[129] locfit_1.5-9.8 igraph_1.6.0
[131] spatstat.geom_3.2-8 RcppHNSW_0.6.0
[133] reshape2_1.4.4 ScaledMatrix_1.10.0
[135] pkgload_1.3.4 XML_3.99-0.16.1
[137] scran_1.30.2 BiocManager_1.30.22
[139] ggprism_1.0.4 tzdb_0.4.0
[141] httpuv_1.6.14 RANN_2.6.1
[143] polyclip_1.10-6 future_1.33.1
[145] scattermore_1.2 janitor_2.2.0
[147] rsvd_1.0.5 xtable_1.8-4
[149] restfulr_0.0.15 RSpectra_0.16-1
[151] later_1.3.2 viridisLite_0.4.2
[153] memoise_2.0.1 beeswarm_0.4.0
[155] GenomicAlignments_1.38.2 cluster_2.1.6
[157] timechange_0.3.0 globals_0.16.2
@IrinaVKuznetsova IrinaVKuznetsova added the bug Something isn't working label Feb 21, 2024
@kulansam
Copy link

kulansam commented Dec 4, 2024

Hi @IrinaVKuznetsova , I am facing the same issue.

Have you find the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants