sttkit icon indicating copy to clipboard operation
sttkit copied to clipboard

Subscript out of bounds error during spatial integration in st_cluster.R

Open leap-ahead225 opened this issue 11 months ago • 1 comments

Thank you for making such a great tool! I encountered an error while running st_cluster.R from the STTKIT package. The script terminates with a subscript out-of-bounds error during the spatial integration step. Below are the details of the command used, the full log output, and relevant observations. Warning messages: 1: Key ‘slice1_’ taken, using ‘bp1821023_’ instead 2: Key ‘slice1_’ taken, using ‘ah21171no29_’ instead ... • These keys appear to be renamed automatically, but the process may not be working as intended.

Command: Rscript $STTKIT/st_cluster.R
--infile '/home/ngs/Desktop/ipmn_sctransform.list'
--labels '/home/ngs/Desktop/ipmn_sctransform_labels.list'
--outprefix /media/ngs/SSD/STTKIT/cluster/ipmn
--gmt /home/ngs/Desktop/idep_cleaned.gmt
--extra_gmt /home/ngs/Downloads/c5.go.v2024.1.Hs.symbols.gmt
--min_features 200 --nmf --nmf_rank 4:16 --nmf_nruns 40
--nmf_randomize --nmf_method nsNMF --verbose

Log Output:

INFO [2025-01-10 18:33:48] Loading Seurat... NULL INFO [2025-01-10 18:33:54] Loading infiles A_P18_210_17_scaled.rds, B_P18_210_23_scaled.rds, A_H21-171_No29_scaled.rds, B_P19-927_No42_scaled.rds, 33_1_scaled.rds, 39_1_scaled.rds... Validating object structure Updating object slots Ensuring keys are in the proper structure Ensuring keys are in the proper structure Ensuring feature names don't have underscores or pipes Updating slots in Spatial Updating slots in SCT Updating slots in A_P18_210_17 Setting assay used for NormalizeData.Spatial to Spatial Setting assay used for SCTransform.Spatial to Spatial Validating object structure for Assay5 ‘Spatial’ Validating object structure for SCTAssay ‘SCT’ Validating object structure for VisiumV2 ‘A_P18_210_17’ Object representation is consistent with the most current Seurat version Validating object structure Updating object slots Ensuring keys are in the proper structure Ensuring keys are in the proper structure Ensuring feature names don't have underscores or pipes Updating slots in Spatial Updating slots in SCT Updating slots in B_P18_210_23 Setting assay used for NormalizeData.Spatial to Spatial Setting assay used for SCTransform.Spatial to Spatial Validating object structure for Assay5 ‘Spatial’ Validating object structure for SCTAssay ‘SCT’ Validating object structure for VisiumV2 ‘B_P18_210_23’ Object representation is consistent with the most current Seurat version Validating object structure Updating object slots Ensuring keys are in the proper structure Ensuring keys are in the proper structure Ensuring feature names don't have underscores or pipes Updating slots in Spatial Updating slots in SCT Updating slots in A_H21.171_No29 Setting assay used for NormalizeData.Spatial to Spatial Setting assay used for SCTransform.Spatial to Spatial Validating object structure for Assay5 ‘Spatial’ Validating object structure for SCTAssay ‘SCT’ Validating object structure for VisiumV2 ‘A_H21.171_No29’ Object representation is consistent with the most current Seurat version Validating object structure Updating object slots Ensuring keys are in the proper structure Ensuring keys are in the proper structure Ensuring feature names don't have underscores or pipes Updating slots in Spatial Updating slots in SCT Updating slots in B_P19.927_No42 Setting assay used for NormalizeData.Spatial to Spatial Setting assay used for SCTransform.Spatial to Spatial Validating object structure for Assay5 ‘Spatial’ Validating object structure for SCTAssay ‘SCT’ Validating object structure for VisiumV2 ‘B_P19.927_No42’ Object representation is consistent with the most current Seurat version Validating object structure Updating object slots Ensuring keys are in the proper structure Ensuring keys are in the proper structure Ensuring feature names don't have underscores or pipes Updating slots in Spatial Updating slots in SCT Updating slots in X33_1 Setting assay used for NormalizeData.Spatial to Spatial Setting assay used for SCTransform.Spatial to Spatial Validating object structure for Assay5 ‘Spatial’ Validating object structure for SCTAssay ‘SCT’ Validating object structure for VisiumV2 ‘X33_1’ Object representation is consistent with the most current Seurat version Validating object structure Updating object slots Ensuring keys are in the proper structure Ensuring keys are in the proper structure Ensuring feature names don't have underscores or pipes Updating slots in Spatial Updating slots in SCT Updating slots in X39_1 Setting assay used for NormalizeData.Spatial to Spatial Setting assay used for SCTransform.Spatial to Spatial Validating object structure for Assay5 ‘Spatial’ Validating object structure for SCTAssay ‘SCT’ Validating object structure for VisiumV2 ‘X39_1’ Object representation is consistent with the most current Seurat version INFO [2025-01-10 18:35:14] Doing a simple initial merge of --infile INFO [2025-01-10 18:41:41] Loading --gmt... Warning messages: 1: Key ‘slice1_’ taken, using ‘bp1821023_’ instead 2: Key ‘slice1_’ taken, using ‘ah21171no29_’ instead 3: Key ‘slice1_’ taken, using ‘bp19927no42_’ instead 4: Key ‘slice1_’ taken, using ‘x331_’ instead 5: Key ‘slice1_’ taken, using ‘x391_’ instead INFO [2025-01-10 18:41:41] Selecting 3000 integration features. INFO [2025-01-10 18:42:34] Adding additional features provided in --gmt. INFO [2025-01-10 18:43:27] Not scaling input files. INFO [2025-01-10 18:43:30] Percent Mito: Removing 2 cells from reference library 39_1. Error in .subscript.2ary(x, i, j, drop = TRUE) : subscript out of bounds Calls: integrate_spatial ... LayerData -> LayerData.Assay -> [ -> [ -> .subscript.2ary In addition: There were 22 warnings (use warnings() to see them) Execution halted

leap-ahead225 avatar Jan 10 '25 10:01 leap-ahead225

Hi, sorry I completely missed this one. I'm not sure, I think you would need to debug with

R --args --infile '/home/ngs/Desktop/ipmn_sctransform.list' --labels '/home/ngs/Desktop/ipmn_sctransform_labels.list' --outprefix /media/ngs/SSD/STTKIT/cluster/ipmn --gmt /home/ngs/Desktop/idep_cleaned.gmt --extra_gmt /home/ngs/Downloads/c5.go.v2024.1.Hs.symbols.gmt --min_features 200 --nmf --nmf_rank 4:16 --nmf_nruns 4 --nmf_randomize --nmf_method nsNMF --verbose
library(sttkit)
debug(integrate_spatial)
source("/xxx/sttkit/inst/extdata/st_cluster.R")

There is a bit of input sanity checking, but not a lot and those unhelpful crashes can happen. But please let me know if this is a bug!

lima1 avatar Apr 28 '25 15:04 lima1