satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.27k stars 910 forks source link

FindVariableFeatures: Error in simpleLoess(y, x, w, span, degree = degree, parametric = parametric, : invalid 'x' #9010

Closed changve closed 4 months ago

changve commented 4 months ago

Hello, I am working with a normalized data set from: http://gerg.gsc.riken.jp/SC2018/. I'm trying to go through the integration introduction vignette. I looked through other issues and saw that the developers have recommended to skip the normalization step when working with already normalized data. So I have skipped this step but while running FindVariableFeatures() on my Seurat object, I'm getting the following error:

Finding variable features for layer counts
Calculating gene variances
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,  : 
  invalid 'x'

I looked at #2387 and running DefaultAssay(object = seurat.object) returns "RNA". This is my session info:

R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.2

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

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

time zone: America/Toronto
tzcode source: internal

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

other attached packages:
 [1] ggpubr_0.6.0                forcats_1.0.0               reshape2_1.4.4              EnsDb.Hsapiens.v86_2.99.0   ensembldb_2.28.0            AnnotationFilter_1.28.0     GenomicFeatures_1.56.0     
 [8] AnnotationDbi_1.66.0        msigdbr_7.5.1               clusterProfiler_4.12.0      dbplyr_2.5.0                SingleR_2.6.0               clustree_0.5.1              ggraph_2.2.1               
[15] Matrix_1.7-0                pheatmap_1.0.12             viridis_0.6.5               viridisLite_0.4.2           Seurat_5.1.0                SeuratObject_5.0.2          sp_2.1-4                   
[22] SingleCellExperiment_1.26.0 SummarizedExperiment_1.34.0 GenomicRanges_1.56.0        GenomeInfoDb_1.40.1         IRanges_2.38.0              S4Vectors_0.42.0            MatrixGenerics_1.16.0      
[29] matrixStats_1.3.0           kableExtra_1.4.0            RColorBrewer_1.1-3          gprofiler2_0.2.3            ggplot2_3.5.1               dplyr_1.1.4                 plyr_1.8.9                 
[36] tinytex_0.51                knitr_1.47                  Biobase_2.64.0              BiocGenerics_0.50.0         biomaRt_2.60.0              edgeR_4.2.0                 limma_3.60.2               

loaded via a namespace (and not attached):
  [1] ProtGenerics_1.36.0       fs_1.6.4                  spatstat.sparse_3.0-3     bitops_1.0-7              enrichplot_1.24.0         HDO.db_0.99.1             httr_1.4.7               
  [8] backports_1.5.0           tools_4.4.0               sctransform_0.4.1         utf8_1.2.4                R6_2.5.1                  lazyeval_0.2.2            uwot_0.2.2               
 [15] withr_3.0.0               prettyunits_1.2.0         gridExtra_2.3             progressr_0.14.0          cli_3.6.2                 spatstat.explore_3.2-7    fastDummies_1.7.3        
 [22] scatterpie_0.2.3          spatstat.data_3.0-4       ggridges_0.5.6            pbapply_1.7-2             yulab.utils_0.1.4         Rsamtools_2.20.0          systemfonts_1.1.0        
 [29] gson_0.1.0                DOSE_3.30.1               svglite_2.1.3             parallelly_1.37.1         rstudioapi_0.16.0         RSQLite_2.3.7             gridGraphics_0.5-1       
 [36] generics_0.1.3            BiocIO_1.14.0             ica_1.0-3                 spatstat.random_3.2-3     car_3.1-2                 GO.db_3.19.1              fansi_1.0.6              
 [43] abind_1.4-5               lifecycle_1.0.4           yaml_2.3.8                carData_3.0-5             qvalue_2.36.0             SparseArray_1.4.8         BiocFileCache_2.12.0     
 [50] Rtsne_0.17                grid_4.4.0                blob_1.2.4                promises_1.3.0            crayon_1.5.2              miniUI_0.1.1.1            lattice_0.22-6           
 [57] beachmat_2.20.0           cowplot_1.1.3             KEGGREST_1.44.0           pillar_1.9.0              fgsea_1.30.0              rjson_0.2.21              future.apply_1.11.2      
 [64] codetools_0.2-20          fastmatch_1.1-4           leiden_0.4.3.1            glue_1.7.0                ggfun_0.1.5               data.table_1.15.4         remotes_2.5.0            
 [71] treeio_1.28.0             vctrs_0.6.5               png_0.1-8                 spam_2.10-0               gtable_0.3.5              cachem_1.1.0              xfun_0.44                
 [78] S4Arrays_1.4.1            mime_0.12                 tidygraph_1.3.1           tidyverse_2.0.0           survival_3.5-8            statmod_1.5.0             fitdistrplus_1.1-11      
 [85] ROCR_1.0-11               nlme_3.1-164              ggtree_3.12.0             bit64_4.0.5               progress_1.2.3            filelock_1.0.3            RcppAnnoy_0.0.22         
 [92] irlba_2.3.5.1             KernSmooth_2.23-22        colorspace_2.1-0          DBI_1.2.3                 DESeq2_1.44.0             tidyselect_1.2.1          bit_4.0.5                
 [99] compiler_4.4.0            curl_5.2.1                httr2_1.0.1               xml2_1.3.6                DelayedArray_0.30.1       plotly_4.10.4             shadowtext_0.1.3         
[106] rtracklayer_1.64.0        scales_1.3.0              lmtest_0.9-40             rappdirs_0.3.3            stringr_1.5.1             digest_0.6.35             goftest_1.2-3            
[113] spatstat.utils_3.0-4      rmarkdown_2.27            XVector_0.44.0            htmltools_0.5.8.1         pkgconfig_2.0.3           sparseMatrixStats_1.16.0  fastmap_1.2.0            
[120] rlang_1.1.4               htmlwidgets_1.6.4         UCSC.utils_1.0.0          DelayedMatrixStats_1.26.0 shiny_1.8.1.1             farver_2.1.2              zoo_1.8-12               
[127] jsonlite_1.8.8            BiocParallel_1.38.0       GOSemSim_2.30.0           BiocSingular_1.20.0       RCurl_1.98-1.14           magrittr_2.0.3            ggplotify_0.1.2          
[134] GenomeInfoDbData_1.2.12   dotCall64_1.1-1           patchwork_1.2.0           munsell_0.5.1             Rcpp_1.0.12               babelgene_22.9            ape_5.8                  
[141] reticulate_1.37.0         stringi_1.8.4             zlibbioc_1.50.0           MASS_7.3-60.2             parallel_4.4.0            listenv_0.9.1             ggrepel_0.9.5            
[148] deldir_2.0-4              Biostrings_2.72.1         graphlayouts_1.1.1        splines_4.4.0             tensor_1.5                hms_1.1.3                 locfit_1.5-9.9           
[155] igraph_2.0.3              spatstat.geom_3.2-9       ggsignif_0.6.4            RcppHNSW_0.6.0            ScaledMatrix_1.12.0       XML_3.99-0.16.1           evaluate_0.24.0          
[162] BiocManager_1.30.23       tweenr_2.0.3              httpuv_1.6.15             RANN_2.6.1                tidyr_1.3.1               purrr_1.0.2               polyclip_1.10-6          
[169] future_1.33.2             scattermore_1.2           ggforce_0.4.2             rsvd_1.0.5                broom_1.0.6               xtable_1.8-4              restfulr_0.0.15          
[176] tidytree_0.4.6            RSpectra_0.16-1           rstatix_0.7.2             later_1.3.2               tibble_3.2.1              aplot_0.2.2               memoise_2.0.1            
[183] GenomicAlignments_1.40.0  cluster_2.1.6             globals_0.16.3          
longmanz commented 4 months ago

Hi, Could you check your input matrix (i.e., in your case, your "data" matrix since you input the logNorm data) to see if there is any invalid value (e.g., NA/INF/NaN)? Also, since http://gerg.gsc.riken.jp/SC2018/ also provides the raw count matrix (UMI.txt.gz), you may also consider using that instead of the Normalized data.

changve commented 4 months ago

Hi, thank you so much for your response. I did check the data and changed all the NAs to 0 but still encountered the same problem. I tried using the raw count matrix instead to go through the normalization step but I'm getting the following error:

Normalizing layer: counts
Performing log-normalization
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error in `fn()`:
! Cannot add new cells with [[<-
Backtrace:
 1. Seurat::NormalizeData(seu1)
 2. Seurat:::NormalizeData.Seurat(seu1)
 4. SeuratObject (local) `[[<-`(`*tmp*`, assay, value = `<Assay5[,61203]>`)
 8. SeuratObject (local) .nextMethod(x = x, i = i, ..., value = value)
 9. SeuratObject (local) fn(x = x, i = i, value = value)
changve commented 4 months ago

I found a solution! I think my meta.data columns did not match up with my counts slot. I created a new object using the following: stripped.seu <- CreateSeuratObject(counts = scrna1[rownames(seu@meta.data)], meta.data = seu@meta.data)