Entering edit mode
muad.abdelhay
▴
10
@muadabdelhay-14075
Last seen 5.4 years ago
I wanted to run SC3 on normalized (scran/scater) logcounts that were then sent through limma's removeBatchEffect using the follwing script:
library(scater)
library(scran)
library(SC3)
txi.bbsplit <- readRDS("txi-bbsplit.rds")
counts.annotated <- txi.bbsplit$counts
### Removes genes that have no expression at all
counts.annotated <- counts.annotated[rowSums(counts.annotated)>0,]
### Load phenotypes
labels <- read.csv(file = "../118-phenotype-table.csv")
### Leave out the cells that were not added to the pool
labels <- labels[labels$CellNumber %in% as.character(colnames(counts.annotated)),]
labels$X <- NULL
## removed sex as it is complitely contained in the animal number
labels$Sex <- NULL
## removed Date as it is also completely contained in the animal
labels$Date <- NULL
rownames(labels) <- labels$CellNumber
labels$Animal <- factor(labels$Animal)
labels$AmpBatch <- factor(labels$AmpBatch)
pd <- new("AnnotatedDataFrame", data = labels)
sce <- newSCESet(countData = data.matrix(counts.annotated), phenoData = pd)
is.mito <- grepl("^mt.", rownames(sce))
sce <- calculateQCMetrics(sce, feature_controls = list(Mt = is.mito))
libsize.drop <- isOutlier(sce$total_counts, nmads=3, type="lower", log=TRUE)
feature.drop <- isOutlier(sce$total_features, nmads=3, type="lower", log=TRUE)
mito.drop <- isOutlier(sce$pct_counts_Mt, nmads=3, type="higher")
sce <- sce[,!(libsize.drop | feature.drop | mito.drop)]
filtered.out <- data.frame(ByLibSize=sum(libsize.drop), ByFeature=sum(feature.drop),
ByMito=sum(mito.drop), Remaining=ncol(sce))
## ave.counts <- calcAverage(sce)
## keep <- ave.counts >= 1
## sce <- sce[keep,]
sce <- computeSumFactors(sce)
sce <- normalize(sce)
library(limma)
logcounts.sce <- logcounts(sce)
logcounts(sce) <- removeBatchEffect(logcounts.sce, batch=sce$AmpBatch)
sce <- sc3_prepare(sce, ks = 2:6)
I get the following error:
Error in sc3_prepare(sce, ks = 2:6) :
All genes were removed after the gene filter! Stopping now...
The above script runs fine without the batch effect removal step. Any idea why this happens?
