SPOTlight function crashes R studio session
sokratiag opened this issue · 4 comments
Hi,
I am trying to run spotlight on a visium mouse brain dataset but the R studio session keeps crashing. Here is the code:
library(ggplot2)
library(SPOTlight)
library(SingleCellExperiment)
library(SpatialExperiment)
library(scater)
library(scran)
library(Seurat)
library(SeuratDisk)
f <- "/Users/user/Mouse_Brain_coronal_IF"
spe <- SpatialExperiment::read10xVisium(samples = f,
type = "sparse",
data = "filtered",images='lowres',load=FALSE)
sce <-readRDS("/Users/user/Mouse_brain/data/sce.rds")
assay(sce,'counts') <- assay(sce,'X')
labels <- read.csv("/Users/user/Mouse_brain/data/snRNA_annotation_astro_subtypes_refined59_20200823.csv", sep=',')
sce<-sce[,colnames(sce) %in% labels$X]
sce$labels <- labels$annotation_1
sce <- logNormCounts(sce)
genes <- !grepl(pattern = "^Rp[l|s]|Mt", x = rownames(sce))
dec <- modelGeneVar(sce, subset.row = genes)
plot(dec$mean, dec$total, xlab = "Mean log-expression", ylab = "Variance")
curve(metadata(dec)$trend(x), col = "blue", add = TRUE)
hvg <- getTopHVGs(dec, n = 1000)
colLabels(sce) <- colData(sce)$labels
sce_subset <- sce[genes,]
mgs <- scoreMarkers(sce, subset.row = genes)
mgs_fil <- lapply(names(mgs), function(i) {
x <- mgs[[i]]
x <- x[x$mean.AUC > 0.56, ]
x <- x[order(x$mean.AUC, decreasing = TRUE), ]
x$gene <- rownames(x)
x$cluster <- i
data.frame(x)
})
mgs_df <- do.call(rbind, mgs_fil)
rownames(spe)<-rowData(spe)$symbol
res <- SPOTlight(
x = sce,
y = spe,
groups = as.character(sce$labels),
mgs = mgs_df,
hvg = hvg,
weight_id = "mean.AUC",
group_id = "cluster",
gene_id = "gene")
hi @sokratiag,
Could you please specify what error message you get and what package versions are you using?
hi @MarcElosua MarcElosua,
I attach a screenshot
of the package versions. It doesn't specify the error. It says 'R session aborted' - R encountered a fatal error. The session was terminated'.
Thanks
The code looks good, could it be a memory usage? Are you running the code manually or kniting an Rmd document?
i am running it manually. I also tried to run it on the terminal and I get 'Killed: 9' error.