I'm trying to follow the batchelor vignette using my own data. I have two batches "A" (2 samples) and "P" (3 samples). I combined the A samples using Reduce
and separately used Reduce
for the 3 P samples. Then I performed normalization and feature selection separately on each SCE object. When running correctExperiments
with no correction: correctExperiments(sceA, sceP, PARAM=NoCorrectParam())
and subsequent PCA/TSNE, it works. But when running it with the default PARAM (fastMNN) correctExperiments(sceA, sceP, subset.row=chosen.hvgs)
I get the following error after about 5 minutes:
Error in eval(subscript, envir = eframe, enclos = eframe) :
'...' used in an incorrect context
The code that I ran is below:
universe <- Reduce(intersect, lapply(all.sce, rownames))
abmmc_samples = lapply(all.sce[1:2], "[", i=universe)
abmmc_combined = Reduce(combineCols, lapply(abmmc_samples, function(a) {return(a)}))
pbmmc_samples = lapply(all.sce[3:5], "[", i=universe)
pbmmc_combined = Reduce(combineCols, lapply(pbmmc_samples, function(p) {return(p)}))
out = multiBatchNorm(abmmc_combined, pbmmc_combined)
sceA = out[[1]]
sceP = out[[2]]
decA <- modelGeneVar(sceA)
decP <- modelGeneVar(sceP)
combined.dec <- combineVar(decA, decP)
chosen.hvgs <- getTopHVGs(combined.dec, n=1000)
# runs OK with no correction
combined <- correctExperiments(sceA, sceP, PARAM=NoCorrectParam()) # no correction
combined = fixedPCA(combined, subset.row=chosen.hvgs, rank = 10)
combined <- runTSNE(combined, dimred="PCA")
plotTSNE(combined, colour_by="group")
# error with correction
mnn <- correctExperiments(sceA, sceP, subset.row=chosen.hvgs) # fastMNN correction
#Error in eval(subscript, envir = eframe, enclos = eframe) :
# '...' used in an incorrect context
What am I doing wrong? Thank you
sorry, forgot to post sessionInfo()
According to this github issue (https://github.com/LTLA/batchelor/issues/32), you may need to update both batchelor and DelayedArray packages
Thank you Basti for the tip. However after upgrading
batchelor
andDelayedArray
I get a new error when running
mnn <- correctExperiments(sceA, sceP, subset.row=chosen.hvgs)
:Error: cannot subset by character when rownames are NULL
. The rownames are not NULL:However, good news...I found a way around this. I combined my SCE objects into one object
sceAP = combineCols(sceA, sceP)
and when runningmnn <- correctExperiments(sceAP, batch = sceAP$group, subset.row=chosen.hvgs)
, it works!Hopefully somebody has more explaination of what is going on but I think all is OK using this hack.