Closed wang0430 closed 1 year ago
Run rlang::last_trace(drop = FALSE) to see 4 hidden frames.
?SPOTlight rlang::last_trace(drop = FALSE) <error/rlang_error> Error in
SeuratObject::GetAssayData()
: !assay
must be one of "Spatial" or "SCT", not "counts".Backtrace: ▆
- ├─SPOTlight::SPOTlight(...)
- │ └─SPOTlight::trainNMF(...)
- │ └─SPOTlight:::.extract_counts(y, assay_sp, slot_sp)
- │ ├─base::as.matrix(SeuratObject::GetAssayData(x, slot, assay))
- │ ├─SeuratObject::GetAssayData(x, slot, assay)
- │ └─SeuratObject:::GetAssayData.Seurat(assay = slot)
- │ └─rlang::arg_match(arg = assay, values = Assays(object = object))
- │ └─rlang::arg_match0(arg, values, error_arg, error_call = error_call)
- └─rlang:::stop_arg_match(w, values = x, error_arg = y, error_call = z)
- └─rlang::abort(msg, call = error_call, arg = error_arg)
SeuratObject
method is being called, but your objects are called sce
(single-cell) and sample
(spatial). Perhaps you could clarify what those are. Usually sce
is used for a SingleCellExperiment
, so I'm assuming sample
is a SeuratObject
?SeuratObject::GetAssayData(x, slot, assay)
with slot = "counts"
and assay = "Spatial"
(arguments slot_sp
and assay_sp
). So I am fairly confused by the error... Perhaps you could try seeing which slots and assays are available in the object?Seurat
introduced breaking changes that need to be fixed by anything depending on it so... Could you also print the output of Seurat::Assays(sce)
and Seurat::Assays(sample)
as well as sce
and sample
?
I updata the parameter and solved it. Thank you ! Happy
Hi! I've run SPOTlight in the past, but I've recently updated Seurat and now I'm having a similar issue:
"Error in SeuratObject::GetAssayData()
:
! assay
must be one of "RNA" or "SCT", not "counts"."
Any help would be greatly appreciated!
backtrace: └─SPOTlight::SPOTlight(...) └─SPOTlight::trainNMF(...) └─SPOTlight:::.extract_counts(x, assay_sc, slot_sc) ├─base::as.matrix(SeuratObject::GetAssayData(x, slot, assay)) ├─SeuratObject::GetAssayData(x, slot, assay) └─SeuratObject:::GetAssayData.Seurat(assay = slot) Run rlang::last_trace(drop = FALSE) to see 4 hidden frames.
my code:
merged <- readRDS("./objects/visium_merged_scrna_annotated.rds") rna <- readRDS("./objects/scrna_merged.rds") split <- SplitObject(merged, split.by = "sample") Idents(rna) <- "orig.ident" # use only one sample sub <- subset(rna, idents = c("Het")) # use only one sample hvg <- sub@assays$SCT@var.features Idents(sub) <- "clusterid" mgs <- FindAllMarkers(sub, assay = "SCT", test.use = "roc") mgs_df <- mgs[mgs$myAUC >= 0.8,] Idents(sub) <- "clusterid" sub <- subset(sub, downsample = 20) spotlight <- list() for (sample in names(split)){ spe <- split[[sample]] DefaultAssay(spe) <- "Spatial" DefaultAssay(sub) <- "SCT" res <- SPOTlight( x = sub, y = spe, groups = sub$clusterid, mgs = mgs_df, hvg = hvg, weight_id = "myAUC", group_id = "cluster", gene_id = "gene", assay_sc = "SCT", slot_sc = "counts", assay_sp = "Spatial", slot_sp = "counts") spotlight[[sample]] <- res }`
checked available assays Seurat::Assays(sub) [1] "RNA" "SCT" Seurat::Assays(spe) [1] "Spatial" "SCT"
sessionInfo:
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Amazon Linux 2
other attached packages:
[1] lubridate_1.9.2 forcats_1.0.0
[3] stringr_1.5.0 dplyr_1.1.2
[5] purrr_1.0.2 readr_2.1.4
[7] tidyr_1.3.0 tibble_3.2.1
[9] ggplot2_3.4.3 tidyverse_2.0.0
[11] scran_1.28.2 scuttle_1.10.3
[13] SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2
[15] GenomicRanges_1.52.0 GenomeInfoDb_1.36.1
[17] IRanges_2.34.1 S4Vectors_0.38.1
[19] MatrixGenerics_1.12.3 matrixStats_1.0.0
[21] SPOTlight_1.4.1 Biobase_2.60.0
[23] BiocGenerics_0.46.0 Seurat_5.0.1
[25] SeuratObject_5.0.1 sp_2.0-0
[27] BiocManager_1.30.22
Hi @corinnestrawser this is due to Seurat V5 updated its data accessor functions. I will update this in the next release, in the meantime you can pass the count matrix instead of the whole Seurat object!
hi, I updated seurat to seurat5, and presented following error with SPOTlight function.
res = SPOTlight(x = sce,y = sample, groups = sce$celltype, mgs = mgs_df, hvg = hvg, weight_id = "mean.AUC", group_id = "cluster", gene_id = "gene")
Error in
SeuratObject::GetAssayData()
: !assay
must be one of "Spatial" or "SCT", not "counts".