Closed ahassien closed 2 years ago
The issue seems to arise from the RunAllMethods function when it calls RunCCA.
runAllMethods <- function(...)
{
batches <- list(...)
uncorrected <- do.call(cbind, batches)
per.batch <- unlist(lapply(batches, FUN=ncol))
batch.id <- rep(seq_along(batches), per.batch)
Xmnn <- do.call(fastMNN, c(batches, list(cos.norm=FALSE, BSPARAM=BiocSingular::IrlbaParam(deferred=TRUE))))
Xlm <- removeBatchEffect(uncorrected, factor(batch.id))
Xcom <- ComBat(uncorrected, factor(batch.id), mod=NULL, prior.plots = FALSE)
mat <- list(uncorrected=t(uncorrected), MNN=reducedDim(Xmnn), limma=t(Xlm), ComBat=t(Xcom))
if (length(batches)==2L) {
colnames(batches[[1]]) <- paste0("Cell", seq_len(ncol(batches[[1]])), "-1")
colnames(batches[[2]]) <- paste0("Cell", seq_len(ncol(batches[[2]])), "-2")
rownames(batches[[1]]) <- rownames(batches[[2]]) <- paste0("Gene", seq_len(nrow(batches[[1]])))
Se <- CreateSeuratObject(batches[[1]])
Se2 <- CreateSeuratObject(batches[[2]])
Se@meta.data$group <- "group1"
Se2@meta.data$group <- "group2"
Se <- ScaleData(Se)
Se2 <- ScaleData(Se2)
Y <- RunCCA(Se, Se2, genes.use=rownames(batches[[1]]), do.normalize=FALSE)
suppressWarnings(Y <- AlignSubspace(Y, grouping.var="group", dims.align=1:20))
mat$CCA <- Y@dr$cca.aligned@cell.embeddings
}
list(mat=mat, batch=batch.id)
}
The error message is generated here in RunCCA.Seurat
if (length(x = VariableFeatures(object = object1, assay = assay1)) == 0) { stop(paste0("VariableFeatures not computed for the ", assay1, " assay in object1"))
Debugging shows the following:
Browse[1]> VariableFeatures(object1, assay=assay1)
logical(0)
I have also posted this issue on the page for Seurat. Was the simulation code here written using Seurat v3?
Honestly I have no idea. This was written 3-4 years ago, as you can see from the commit dates - so it must have been written for whatever version of Seurat was floating around at the time. Probably some version of V3, I guess. If you want to use it on the latest version, you'll have to update the scripts yourself; the other methods should still work fine.
No worries, I understand completely. I'll see if I can get it up and running in Seurat v4. Thanks!
Hello there,
I am trying to run the the simulations code using Seurat v4. I get the following error when running cluster_sim.R
Is the VariableFeatures function still supported by Seurat v4? It appears that using this function returns an empty logical. I am using the batchelor package and R version 4.2.1.