batchelor correctExperiments() returns Error in eval(subscript, envir = eframe, enclos = eframe) : '...' used in an incorrect context
1
0
Entering edit mode
pcantalupo ▴ 10
@pcantalupo-8617
Last seen 5 months ago
United States

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

batchelor • 1.8k views
ADD COMMENT
0
Entering edit mode

sorry, forgot to post sessionInfo()

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] scater_1.22.0               ggplot2_3.3.5               BiocParallel_1.28.3        
 [4] scran_1.22.1                scuttle_1.4.0               batchelor_1.10.0           
 [7] SingleCellExperiment_1.16.0 SummarizedExperiment_1.24.0 Biobase_2.54.0             
[10] GenomicRanges_1.46.1        GenomeInfoDb_1.30.1         IRanges_2.28.0             
[13] S4Vectors_0.32.4            BiocGenerics_0.40.0         MatrixGenerics_1.6.0       
[16] matrixStats_0.62.0         

loaded via a namespace (and not attached):
 [1] viridis_0.6.2             edgeR_3.36.0              BiocSingular_1.10.0      
 [4] viridisLite_0.4.0         DelayedMatrixStats_1.16.0 assertthat_0.2.1         
 [7] statmod_1.4.36            BiocManager_1.30.17       dqrng_0.3.0              
[10] GenomeInfoDbData_1.2.7    vipor_0.4.5               ggrepel_0.9.1            
[13] pillar_1.7.0              lattice_0.20-45           glue_1.6.2               
[16] limma_3.50.3              beachmat_2.10.0           XVector_0.34.0           
[19] colorspace_2.0-3          Matrix_1.4-1              pkgconfig_2.0.3          
[22] zlibbioc_1.40.0           purrr_0.3.4               scales_1.2.0             
[25] ScaledMatrix_1.2.0        Rtsne_0.16                ResidualMatrix_1.4.0     
[28] tibble_3.1.6              generics_0.1.2            ellipsis_0.3.2           
[31] withr_2.5.0               cli_3.2.0                 magrittr_2.0.3           
[34] crayon_1.5.1              fansi_1.0.3               bluster_1.4.0            
[37] beeswarm_0.4.0            tools_4.1.2               lifecycle_1.0.1          
[40] munsell_0.5.0             locfit_1.5-9.5            cluster_2.1.3            
[43] DelayedArray_0.20.0       irlba_2.3.5               compiler_4.1.2           
[46] rsvd_1.0.5                rlang_1.0.2               grid_4.1.2               
[49] RCurl_1.98-1.6            BiocNeighbors_1.12.0      igraph_1.3.1             
[52] bitops_1.0-7              gtable_0.3.0              DBI_1.1.2                
[55] R6_2.5.1                  gridExtra_2.3             dplyr_1.0.8              
[58] utf8_1.2.2                metapod_1.2.0             ggbeeswarm_0.6.0         
[61] parallel_4.1.2            Rcpp_1.0.8.3              vctrs_0.4.1              
[64] tidyselect_1.1.2          sparseMatrixStats_1.6.0
ADD REPLY
0
Entering edit mode

According to this github issue (https://github.com/LTLA/batchelor/issues/32), you may need to update both batchelor and DelayedArray packages

ADD REPLY
0
Entering edit mode

Thank you Basti for the tip. However after upgrading batchelor and DelayedArray

> pacman::p_version('batchelor')
[1] ‘1.13.1’
> pacman::p_version('DelayedArray')
[1] ‘0.23.0’

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:

> str(rownames(sceA))
 chr [1:11092] "ENSG00000225880" "ENSG00000188976" "ENSG00000188290" "ENSG00000187608" "ENSG00000131591" ...
> str(rownames(sceP))
 chr [1:11092] "ENSG00000225880" "ENSG00000188976" "ENSG00000188290" "ENSG00000187608" "ENSG00000131591" ...

However, good news...I found a way around this. I combined my SCE objects into one object sceAP = combineCols(sceA, sceP) and when running mnn <- 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.

ADD REPLY
1
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 4 hours ago
The city by the bay

As @Basti said, the ... used in an incorrect context should be fixed by the Github issue. So if you have batchelor 1.12.1 or higher, you should be fine.

I don't know about the rownames are NULL error though. You'll have to post traceback immediately after encountering the error, e.g., with traceback(max.lines=10).

ADD COMMENT
0
Entering edit mode

Here is the output:

> mnn <- correctExperiments(sceA, sceP, subset.row=chosen.hvgs)
Error: cannot subset by character when rownames are NULL
In addition: Warning messages:
1: In .accumulate_rowdata(all.rrw) :
  ignoring non-identical 'Symbol' field in 'rowData'
2: In .accumulate_rowdata(all.rrw) :
  ignoring non-identical 'mean' field in 'rowData'
3: In .accumulate_rowdata(all.rrw) :
  ignoring non-identical 'detected' field in 'rowData'

> traceback(max.lines=10)
11: stop(wmsg(...), call. = FALSE)
10: .subscript_error("cannot subset by character when ", what, " are NULL")
9: NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, 
       allow.NAs = allow.NAs)
8: NSBS(i, x, exact = exact, strict.upper.bound = !allow.append, 
       allow.NAs = allow.NAs)
7: normalizeSingleBracketSubscript(i, x, allow.NAs = TRUE, as.NSBS = TRUE)
6: extractROWS(x, i)
5: extractROWS(x, i)
4: combined.rd[subset.row, , drop = FALSE]
3: combined.rd[subset.row, , drop = FALSE]
2: .create_fresh_combined_sce(x, merged, subset.row = subset.row, 
       correct.all = correct.all, combine.assays = combine.assays, 
       combine.coldata = combine.coldata, include.rowdata = include.rowdata)
1: correctExperiments(sceA, sceP, subset.row = chosen.hvgs)

Thank you for your help.

ADD REPLY
1
Entering edit mode

Should be patched in batchelor 1.12.2; give it a few days to make its way through BioC's build system, or you can install directly from the RELEASE_3_15 branch on the GitHub repository.

ADD REPLY
0
Entering edit mode

It worked...thank you Aaron

ADD REPLY

Login before adding your answer.

Traffic: 599 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6