satijalab / seurat

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

Error with Load_Nanostring() #6521

Closed dst53 closed 3 months ago

dst53 commented 1 year ago

Hello,

I am having a problem with the Load_Nanostring() function from the spatial imaging vignette. nano.obj <- LoadNanostring(data.dir = lung5_rep1, fov = "lung5.rep1")

`Error in (function (cond)  : 
  error in evaluating a 'primitive' next method: object of type 'S4' is not subsettable
In addition: Warning messages:
1: In Polygon(coords = cx) : less than 4 coordinates in polygon
2: In Polygon(coords = cx) : less than 4 coordinates in polygon`

I am able to load the data into a list containing matrix, pixels, and centroids using Read_Nanostring() nano.obj <- ReadNanostring(data.dir = lung5_rep1)

head(nano.obj)

> $matrix
979 x 100149 sparse Matrix of class "dgCMatrix"
   [[ suppressing 93 column names ‘1_1’, ‘2_1’, ‘3_1’ ... ]]
   [[ suppressing 93 column names ‘1_1’, ‘2_1’, ‘3_1’ ... ]]

My lung5_rep1 data dir looks like this:

image

sessionInfo()

> R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /share/pkg.7/r/4.2.1/install/lib64/R/lib/libRblas.so
LAPACK: /share/pkg.7/r/4.2.1/install/lib64/R/lib/libRlapack.so

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

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

other attached packages:
[1] future_1.26.1           Seurat_4.2.0.9001       sp_1.5-0                SeuratObject_4.1.2.9003 remotes_2.4.2           uwot_0.1.14             sctransform_0.3.5       Matrix_1.5-1           

Thank you

AustinHartman commented 1 year ago

Thanks for reporting - your sessionInfo looks good but I'm having a hard time reproducing this. Could you provide the traceback showing where this error is occurring?

dst53 commented 1 year ago

Hi @AustinHartman,

Here is the traceback

> traceback()

12: (function (cond) 
    .Internal(C_tryCatchHelper(addr, 1L, cond)))(structure(list(message = "object of type 'S4' is not subsettable", 
        call = x[i = i], object = new("Centroids", cells = c("1_1", 
        "2_1", "3_1", "4_1", "5_1", "6_1", "7_1", "8_1", "9_1", "10_1", 
        "11_1", "12_1", "13_1", "14_1", "15_1", "16_1", "17_1", "18_1", 
        "19_1", "20_1", "21_1", "22_1", "23_1", "24_1", "25_1", "26_1", 
        "27_1", "28_1", "29_1", "30_1", "31_1", "32_1", "33_1", "34_1", 
        "35_1", "36_1", "37_1", "38_1", "39_1", "40_1", "41_1", "42_1", 
        "43_1", "44_1", "45_1", "46_1", "47_1", "48_1", "49_1", "50_1", 
        "51_1", "52_1", "53_1", "54_1", "55_1", "56_1", "57_1", "58_1", 
        "59_1", "60_1", "61_1", "62_1", "63_1", "64_1", "65_1", "66_1", 
        "67_1", "68_1", "69_1", "70_1", "71_1", "72_1", "73_1", "74_1", 
        "75_1", "76_1", "77_1", "78_1", "79_1", "80_1", "81_1", "82_1", 
        "83_1", "84_1", "85_1", "86_1", "87_1", "88_1", "89_1", "90_1", 
        "91_1", "92_1", "93_1", "94_1", "95_1", "96_1", "97_1", "98_1", 
        "99_1", "100_1", "101_1", "102_1", "103_1", "104_1", "105_1", 
        "106_1", "107_1", "108_1", "109_1", "110_1", "111_1", "112_1", 
        "113_1", "114_1", "115_1", "116_1", "117_1", "118_1", "119_1", 
        "120_1", "121_1", "122_1", "123_1", "124_1", "125_1", "126_1", 
        "127_1", "128_1", "129_1", "130_1", "131_1", "132_1", "133_1", 
     ...
11: callNextMethod()
10: object[[b]][bcells]
9: object[[b]][bcells]
8: .OrderCells(object = .Object)
7: .local(.Object, ...)
6: initialize(value, ...)
5: initialize(value, ...)
4: new(Class = "FOV", boundaries = coords, molecules = molecules, 
       assay = assay, key = key %||% Key(object = assay, quiet = TRUE))
3: CreateFOV.list(coords = segmentations.data, type = c("segmentation", 
       "centroids"), molecules = data$pixels, assay = assay)
2: CreateFOV(coords = segmentations.data, type = c("segmentation", 
       "centroids"), molecules = data$pixels, assay = assay)
1: LoadNanostring(data.dir = lung5_rep1, fov = "lung5.rep1")

Thank you

AustinHartman commented 1 year ago

Thank you! Unfortunately this is tricky for me to debug without seeing the data as I am able to load this dataset. Any chance you could email me the output of ReadNanostring(data.dir = lung5_rep1) saved as an rds? My email is ahartman@nygenome.org.

MomenehForoutan commented 1 year ago

Hi team, I am getting different Errors for the same functions when trying to read/load CosMx lung13; please see below. Any advice on how to fix these would be highly appreciated! Many thanks! Cheers,

rawPath <- "~/data/Spatial/CosMx_Lung/Lung13/Lung13-Flat_files_and_images/"
nano.obj <- LoadNanostring(data.dir = rawPath, fov = "lung13")
Error in data.frame(x = segs$x_global_px, y = segs$y_global_px, cell = paste0(as.character(segs$cellID),  : 
object 'segs' not found

nano.obj <- ReadNanostring(data.dir = rawPath, fov = "lung13")
Error in if ((sum(tx == 0)/length(x = tx)) > ratio) { : 
missing value where TRUE/FALSE needed

Here is my session info:

SessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.4 (Ootpa)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.12.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] 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] future_1.28.0           sp_1.5-0                SeuratObject_4.1.2.9003
[4] Seurat_4.2.0.9001      

loaded via a namespace (and not attached):
  [1] Rtsne_0.16            colorspace_2.0-3      deldir_1.0-6          ellipsis_0.3.2       
  [5] ggridges_0.5.4        spatstat.data_3.0-0   leiden_0.4.3          listenv_0.8.0        
  [9] remotes_2.4.2         ggrepel_0.9.1         fansi_1.0.3           codetools_0.2-18     
 [13] splines_4.2.0         knitr_1.40            polyclip_1.10-4       jsonlite_1.8.3       
 [17] ica_1.0-3             cluster_2.1.3         png_0.1-7             rgeos_0.5-9          
 [21] uwot_0.1.14           shiny_1.7.2           sctransform_0.3.5     spatstat.sparse_3.0-0
 [25] compiler_4.2.0        httr_1.4.4            Matrix_1.5-1          fastmap_1.1.0        
 [29] lazyeval_0.2.2        cli_3.4.1             later_1.3.0           htmltools_0.5.3      
 [33] tools_4.2.0           igraph_1.3.5          gtable_0.3.1          glue_1.6.2           
 [37] RANN_2.6.1            reshape2_1.4.4        dplyr_1.0.10          Rcpp_1.0.9           
 [41] scattermore_0.8       vctrs_0.5.0           nlme_3.1-157          progressr_0.11.0     
 [45] lmtest_0.9-40         spatstat.random_2.2-0 xfun_0.33             stringr_1.4.1        
 [49] globals_0.16.1        mime_0.12             miniUI_0.1.1.1        lifecycle_1.0.3      
 [53] irlba_2.3.5.1         goftest_1.2-3         MASS_7.3-56           zoo_1.8-11           
 [57] scales_1.2.1          spatstat.core_2.4-4   promises_1.2.0.1      spatstat.utils_3.0-1 
 [61] parallel_4.2.0        RColorBrewer_1.1-3    qs_0.25.4             yaml_2.3.6           
 [65] reticulate_1.26       pbapply_1.5-0         gridExtra_2.3         ggplot2_3.3.6        
 [69] rpart_4.1.16          stringi_1.7.8         rlang_1.0.6           pkgconfig_2.0.3      
 [73] matrixStats_0.62.0    evaluate_0.16         lattice_0.20-45       ROCR_1.0-11          
 [77] purrr_0.3.5           tensor_1.5            patchwork_1.1.2       htmlwidgets_1.5.4    
 [81] cowplot_1.1.1         tidyselect_1.2.0      parallelly_1.32.1     RcppAnnoy_0.0.19     
 [85] plyr_1.8.7            magrittr_2.0.3        R6_2.5.1              generics_0.1.3       
 [89] mgcv_1.8-40           pillar_1.8.1          fitdistrplus_1.1-8    survival_3.3-1       
 [93] abind_1.4-5           tibble_3.1.8          future.apply_1.9.1    KernSmooth_2.23-20   
 [97] utf8_1.2.2            spatstat.geom_2.4-0   RApiSerialize_0.1.2   plotly_4.10.0        
[101] rmarkdown_2.17        grid_4.2.0            data.table_1.14.4     digest_0.6.30        
[105] xtable_1.8-4          tidyr_1.2.1           httpuv_1.6.6          RcppParallel_5.1.5   
[109] munsell_0.5.0         stringfish_0.15.7     viridisLite_0.4.1 

And this is my traceback():

traceback()
3: data.frame(x = segs$x_global_px, y = segs$y_global_px, cell = paste0(as.character(segs$cellID), 
       "_", segs$fov), stringsAsFactors = FALSE)
2: ReadNanostring(data.dir = data.dir, type = c("centroids", "segmentations"))
1: LoadNanostring(data.dir = rawPath, fov = "lung13")

And here are the files under the rawPath "Lung13-Flat_files_and_images/": Screen Shot 2022-10-24 at 11 03 01 am

dcollins15 commented 3 months ago

Thanks for using Seurat!

It appears that this issue has gone stale. In an effort to keep our Issues board from getting more unruly than it already is, we’re going to begin closing out issues that haven’t had any activity since the release of v4.4.0.

If this issue is still relevant we strongly encourage you to reopen or repost it, especially if you didn’t initially receive a response from us.