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

doubletCluster error: invalid rownames length #22

Closed danshu closed 5 years ago

danshu commented 5 years ago

Hi,

I'm using doubletCluster to identify potential doublets but having this error: dbl.out <- doubletCluster(sce, sce$Cluster) Error in rownames<-(*tmp*, value = c("AL627309.1", "CICP27", "AL627309.7", : invalid rownames length This error does not show up when I run doubletCluster using the following example? https://rdrr.io/github/MarioniLab/scran/man/doubletCluster.html Anyone can help?

Best, Danshu

LTLA commented 5 years ago

Can you make a minimum reproducible example?

https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Certainly I have no problems running doubletCluster on a SingleCellExperiment object:

https://bioconductor.org/packages/devel/workflows/vignettes/simpleSingleCell/inst/doc/work-6-doublet.html#3_doublet_detection_with_clusters

... which is probably where you got the code from anyway.

danshu commented 5 years ago

This seems to have something to do with rownames. counts <- as.matrix(counts(sce)) rownames(counts) <- c() dbl.out <- doubletCluster(counts, sce$Cluster) After deleting rownames, there is no error now.

On the other hand, for the example (https://rdrr.io/github/MarioniLab/scran/man/doubletCluster.html): rownames(counts) <- paste0("gene",1:100) After giving rownames to "counts", I got the same error.

Interestingly, I got the same error when running "read10xCounts()". Actually, there is no such error before I updated scater and scran.

R version 3.5.1 (2018-07-02) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux buster/sid

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale: [1] LC_CTYPE=en_HK.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_HK.UTF-8 LC_COLLATE=en_HK.UTF-8
[5] LC_MONETARY=en_HK.UTF-8 LC_MESSAGES=en_HK.UTF-8
[7] LC_PAPER=en_HK.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_HK.UTF-8 LC_IDENTIFICATION=C

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

other attached packages: [1] DropletUtils_1.0.3 SingleCellExperiment_1.3.11 [3] SummarizedExperiment_1.10.1 DelayedArray_0.7.48
[5] matrixStats_0.54.0 Biobase_2.40.0
[7] GenomicRanges_1.32.7 GenomeInfoDb_1.16.0
[9] IRanges_2.14.12 S4Vectors_0.19.22
[11] BiocGenerics_0.27.1 BiocParallel_1.14.2

loaded via a namespace (and not attached): [1] Rcpp_0.12.19 XVector_0.20.0 edgeR_3.23.5
[4] lattice_0.20-35 tools_3.5.1 grid_3.5.1
[7] rhdf5_2.25.11 Matrix_1.2-14 GenomeInfoDbData_1.1.0 [10] Rhdf5lib_1.3.3 bitops_1.0-6 RCurl_1.95-4.11
[13] limma_3.36.5 compiler_3.5.1 locfit_1.5-9.1

LTLA commented 5 years ago

Regarding the modified example; I observe no such error with the following code:

library(scran)

# Mocking up an example.
ngenes <- 100
mu1 <- 2^rexp(ngenes)
mu2 <- 2^rnorm(ngenes)

counts.1 <- matrix(rpois(ngenes*100, mu1), nrow=ngenes)
counts.2 <- matrix(rpois(ngenes*100, mu2), nrow=ngenes)
counts.m <- matrix(rpois(ngenes*20, mu1+mu2), nrow=ngenes)

counts <- cbind(counts.1, counts.2, counts.m)
clusters <- rep(1:3, c(ncol(counts.1), ncol(counts.2), ncol(counts.m)))
rownames(counts) <- paste0("gene", seq_len(ngenes))

# Find potential doublets: works fine for me.
dbl <- doubletCluster(counts, clusters)

If you want to use the latest version of scran, then you should also be using the latest version of the other Bioconductor packages. I would suggest running BiocManager::install(version="devel") to synchronize the other packages; this may or may not solve your problem.

Session information ``` R version 3.5.0 RC (2018-04-16 r74624) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.6 Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] parallel stats4 stats graphics grDevices utils datasets [8] methods base other attached packages: [1] scran_1.9.36 SingleCellExperiment_1.3.11 [3] SummarizedExperiment_1.11.6 DelayedArray_0.7.48 [5] matrixStats_0.54.0 Biobase_2.41.2 [7] GenomicRanges_1.33.14 GenomeInfoDb_1.17.2 [9] IRanges_2.15.18 S4Vectors_0.19.22 [11] BiocGenerics_0.27.1 BiocParallel_1.15.15 loaded via a namespace (and not attached): [1] statmod_1.4.30 beeswarm_0.2.3 [3] locfit_1.5-9.1 tidyselect_0.2.5 [5] reshape2_1.4.3 purrr_0.2.5 [7] HDF5Array_1.9.19 lattice_0.20-35 [9] rhdf5_2.25.11 colorspace_1.3-2 [11] viridisLite_0.3.0 rlang_0.2.2 [13] pillar_1.3.0 glue_1.3.0 [15] bindrcpp_0.2.2 GenomeInfoDbData_1.2.0 [17] plyr_1.8.4 bindr_0.1.1 [19] stringr_1.3.1 zlibbioc_1.27.0 [21] munsell_0.5.0 gtable_0.2.0 [23] vipor_0.4.5 scater_1.9.21 [25] BiocNeighbors_0.99.22 Rcpp_0.12.19 [27] edgeR_3.23.5 scales_1.0.0 [29] limma_3.37.7 XVector_0.21.4 [31] gridExtra_2.3 ggplot2_3.0.0 [33] stringi_1.2.4 dplyr_0.7.6 [35] grid_3.5.0 tools_3.5.0 [37] bitops_1.0-6 magrittr_1.5 [39] RCurl_1.95-4.11 lazyeval_0.2.1 [41] tibble_1.4.2 dynamicTreeCut_1.63-1 [43] crayon_1.3.4 pkgconfig_2.0.2 [45] Matrix_1.2-14 DelayedMatrixStats_1.3.11 [47] ggbeeswarm_0.6.0 assertthat_0.2.0 [49] viridis_0.5.1 Rhdf5lib_1.3.3 [51] R6_2.3.0 igraph_1.2.2 [53] compiler_3.5.0 ```
danshu commented 5 years ago

Thanks! Updating "other attached packages" to development versions solved this problem.