MarioniLab / scran

Clone of the Bioconductor repository for the scran package.
https://bioconductor.org/packages/devel/bioc/html/scran.html
40 stars 22 forks source link

Error in .check_batch_consistency(batches, byrow = TRUE) : number of rows is not the same across batches #25

Closed liuyongcds closed 5 years ago

liuyongcds commented 5 years ago

Hi, Aaron When I run the fastMNN on my sampls( which from 10x), it keep complain the error "number of rows is not the same across batches". May you help me with that? Best, Yong

pathlist <- c("pig_v94/filtered_p/Adult_nc_r1_p", "pig_v94/filtered_p/Adult_r1p" ) pathlist <-pathlist[1:2] library(DropletUtils) library(scran) library(SingleCellExperiment) dalist <- list() davar <- list() batch <- c() aliases <- c() if (is.null(aliases)) aliases <- sub(".*/","", pathlist) for( i in 1:length(pathlist)){ newite <- read10xCounts(pathlist[i], col.names=T) colnames(newite) <- paste(aliases[i],colnames(newite),sep="") logcounts(newite) <- counts(newite) dec <- tryCatch(rownames(decomposeVar(newite, trendVar(newite, parametric=T, use.spikes = FALSE))),error=function(cond){return(c())}) dalist <- c(dalist, newite) davar <- c(davar, dec) batch <- c(batch, rep(aliases[i], ncol(counts(newite)))) } Warning messages: 1: In (function (formula, data = parent.frame(), start, control = nls.control(), : singular gradient 2: In (function (formula, data = parent.frame(), start, control = nls.control(), : singular gradient dalist <- do.call(multiBatchNorm, dalist) Warning messages: 1: In .batch_rescaler(batches, subset.row = nonspike.subset, exprs_values = assay.type, : no size factors in batch 1, using sum of counts instead 2: In .batch_rescaler(batches, subset.row = nonspike.subset, exprs_values = assay.type, : no size factors in batch 2, using sum of counts instead davar <- sort(table(as.character(davar))) if (length(davar) > 2000) davar <- names(davar)[1:2000] else davar <- names(davar) mnninput <- list(); data <- list() for( i in 1:length(pathlist)){ mnninput <- c(mnninput, list(as.matrix(logcounts(dalist[[i]]))[davar,])) data <- c(data, (logcounts(dalist[[i]]))) print(dim(mnninput[[i]])) } [1] 2000 2552 [1] 2000 737 mnnout <- do.call(fastMNN, c(dalist, list(k=20,d=50,approximation=T,subset.row=davar))) Error in .check_batch_consistency(batches, byrow = TRUE) : number of rows is not the same across batches

sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

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

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

other attached packages: [1] DropletUtils_1.2.1 scater_1.10.0 ggplot2_3.1.0 scran_1.10.1 SingleCellExperiment_1.4.0 [6] SummarizedExperiment_1.12.0 DelayedArray_0.8.0 matrixStats_0.54.0 Biobase_2.42.0 GenomicRanges_1.34.0
[11] GenomeInfoDb_1.18.0 IRanges_2.16.0 S4Vectors_0.20.0 BiocGenerics_0.28.0 BiocParallel_1.16.0

loaded via a namespace (and not attached): [1] Rcpp_1.0.0 locfit_1.5-9.1 lattice_0.20-35 digest_0.6.18 assertthat_0.2.0
[6] R6_2.3.0 plyr_1.8.4 dynamicTreeCut_1.63-1 pillar_1.3.0 zlibbioc_1.28.0
[11] rlang_0.3.0.1 lazyeval_0.2.1 irlba_2.3.2 rstudioapi_0.8 Matrix_1.2-14
[16] labeling_0.3 BiocNeighbors_1.0.0 statmod_1.4.30 Rtsne_0.13 stringr_1.3.1
[21] igraph_1.2.2 RCurl_1.95-4.11 munsell_0.5.0 HDF5Array_1.10.0 compiler_3.5.1
[26] vipor_0.4.5 pkgconfig_2.0.2 ggbeeswarm_0.6.0 tidyselect_0.2.5 tibble_1.4.2
[31] gridExtra_2.3 GenomeInfoDbData_1.2.0 edgeR_3.24.0 viridisLite_0.3.0 crayon_1.3.4
[36] dplyr_0.7.8 withr_2.1.2 bitops_1.0-6 grid_3.5.1 gtable_0.2.0
[41] magrittr_1.5 scales_1.0.0 stringi_1.2.4 XVector_0.22.0 reshape2_1.4.3
[46] viridis_0.5.1 bindrcpp_0.2.2 limma_3.38.2 DelayedMatrixStats_1.4.0 cowplot_0.9.3
[51] Rhdf5lib_1.4.0 tools_3.5.1 glue_1.3.0 beeswarm_0.2.3 purrr_0.2.5
[56] colorspace_1.3-2 rhdf5_2.26.0 bindr_0.1.1

LTLA commented 5 years ago

Format your message properly, it's really hard to figure out what's going on here.

But the problem is probably because you supply an approximation argument to fastMNN. No such named argument exists, so it just ends up being treated as a batch, which is obviously silly.

liuyongcds commented 5 years ago

Format your message properly, it's really hard to figure out what's going on here.

But the problem is probably because you supply an approximation argument to fastMNN. No such named argument exists, so it just ends up being treated as a batch, which is obviously silly. Hi Aaron, I have changed the approximation to approximate. Now, it works. Many thanks. Best, Yong