drisso / SingleCellExperiment

Clone of the Bioconductor repository for the SingleCellExperiment package, see https://bioconductor.org/packages/devel/bioc/html/SingleCellExperiment.html for the official development version.
63 stars 17 forks source link

logNormcounts() function doesn't work for my singlecellExperiment object #59

Open tf1993614 opened 3 years ago

tf1993614 commented 3 years ago

sce <- SingleCellExperiment(list(counts = dge$counts))

clst <- quickCluster(sce, method="igraph", min.mean = 0.5)

sce <- computeSumFactors(sce, cluster =lst)`

libsize <- dge$samples$lib.size

plot(libsize/1e3, sizeFactors(sce), log="xy", pch=16, cex = 0.7, xlab = "library size(thousands)", ylab = "size factor")

sce <- logNormCounts(sce)

error message: Error in assays<-(*tmp*, withDimnames = withDimnames, ..., value = *vtmp*) : please use 'assay(x, withDimnames=FALSE)) <- value' or 'assays(x, withDimnames=FALSE)) <- value' when the dimnames on the supplied assay(s) are not identical to the dimnames on SingleCellExperiment object 'x'

Could you help me figure out this problem?

LTLA commented 3 years ago

Are you using the latest versions of all packages? Run BiocManager::valid() and check that you're not using packages from different Bioconductor releases. The error that you're seeing should not occur when using packages from the same release.

tf1993614 commented 3 years ago

Hi Aaron,

Thanks for your response.

I pretty sure that all packages I used are in the latest version after upgradation. I tried to rebuild the object with lastest SingcellExperiment package and do the log normalization with latest scater package. However, same problem still comes out and logNormcounts() function still doesn't work.

I even try an alternative way like this:

logcounts(sce) <- normalizeCounts(sce)

But it doesn't help.


From: Aaron Lun @.> Sent: Monday, 3 May 2021 4:33 AM To: drisso/SingleCellExperiment @.> Cc: Feng Tang @.>; Author @.> Subject: Re: [drisso/SingleCellExperiment] logNormcounts() function doesn't work for my singlecellExperiment object (#59)

Are you using the latest versions of all packages? Run BiocManager::valid() and check that you're not using packages from different Bioconductor releases. The error that you're seeing should not occur when using packages from the same release.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/drisso/SingleCellExperiment/issues/59#issuecomment-830855717, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOUG3KVEQDFCJH64R3QSBM3TLWOWXANCNFSM437CQLNQ.

LTLA commented 3 years ago

Perhaps you should run BiocManager::valid(), as I suggested, and show the output.

tf1993614 commented 3 years ago

Hi Aaron,

I did what you suggested. The output is shown below:

R version 4.0.4 (2021-02-15) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

Matrix products: default

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

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

other attached packages: [1] edgeR_3.30.3 scran_1.16.0 scater_1.16.2 SingleCellExperiment_1.10.1 [5] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.1 purrr_0.3.4 [9] readr_1.3.1 tidyr_1.1.1 tibble_3.0.3 tidyverse_1.3.0 [13] magrittr_1.5 limma_3.44.3 ggplot2_3.3.2 SummarizedExperiment_1.18.2 [17] DelayedArray_0.14.1 matrixStats_0.56.0 Biobase_2.48.0 GenomicRanges_1.40.0 [21] GenomeInfoDb_1.24.2 IRanges_2.22.2 S4Vectors_0.26.1 BiocGenerics_0.34.0

loaded via a namespace (and not attached): [1] bitops_1.0-6 fs_1.5.0 lubridate_1.7.9.2 httr_1.4.2 [5] tools_4.0.4 backports_1.1.7 R6_2.4.1 irlba_2.3.3 [9] vipor_0.4.5 DBI_1.1.0 colorspace_1.4-1 withr_2.4.1 [13] tidyselect_1.1.0 gridExtra_2.3 compiler_4.0.4 cli_2.0.2 [17] rvest_1.0.0 BiocNeighbors_1.6.0 xml2_1.3.2 scales_1.1.1 [21] XVector_0.28.0 pkgconfig_2.0.3 dbplyr_1.4.4 rlang_0.4.10 [25] readxl_1.3.1 rstudioapi_0.11 DelayedMatrixStats_1.10.1 generics_0.0.2 [29] jsonlite_1.7.0 BiocParallel_1.22.0 RCurl_1.98-1.2 BiocSingular_1.4.0 [33] GenomeInfoDbData_1.2.3 Matrix_1.3-2 Rcpp_1.0.5 ggbeeswarm_0.6.0 [37] munsell_0.5.0 fansi_0.4.1 viridis_0.5.1 lifecycle_1.0.0 [41] stringi_1.4.6 yaml_2.2.1 zlibbioc_1.34.0 grid_4.0.4 [45] blob_1.2.1 dqrng_0.3.0 crayon_1.3.4 lattice_0.20-41 [49] haven_2.3.1 hms_0.5.3 locfit_1.5-9.4 knitr_1.29 [53] pillar_1.4.6 igraph_1.2.6 reprex_1.0.0 glue_1.4.1 [57] BiocManager_1.30.10 modelr_0.1.8 vctrs_0.3.2 cellranger_1.1.0 [61] gtable_0.3.0 assertthat_0.2.1 xfun_0.16 rsvd_1.0.5 [65] broom_0.7.5 viridisLite_0.3.0 tinytex_0.25 beeswarm_0.3.1 [69] statmod_1.4.35 ellipsis_0.3.1

Bioconductor version '3.11'

create a valid installation with

BiocManager::install(c( "backports", "BH", "BiocManager", "bit64", "bitops", "broom", "callr", "cli", "clipr", "colorspace", "cpp11", "crayon", "crosstalk", "curl", "data.table", "DBI", "dbplyr", "desc", "digest", "doParallel", "dplyr", "DT", "ellipsis", "FactoMineR", "fansi", "farver", "fastmap", "forcats", "foreach", "formatR", "Formula", "gdtools", "generics", "ggplot2", "ggrepel", "glue", "haven", "hexbin", "highr", "Hmisc", "hms", "htmlTable", "htmltools", "htmlwidgets", "httpuv", "isoband", "iterators", "jsonlite", "knitr", "labeling", "later", "lme4", "lubridate", "magrittr", "maptools", "MatrixModels", "matrixStats", "memoise", "mime", "nycflights13", "openssl", "pbkrtest", "pillar", "pkgbuild", "pkgload", "plotly", "processx", "promises", "ps", "quantreg", "R6", "rappdirs", "Rcpp", "RcppArmadillo", "RcppEigen", "RCurl", "readr", "reprex", "rio", "rlang", "rmarkdown", "rprojroot", "RSQLite", "rstudioapi", "shiny", "sp", "SparseM", "stringi", "svglite", "systemfonts", "testthat", "tibble", "tidyr", "tidyselect", "tidyverse", "tinytex", "utf8", "vctrs", "viridis", "viridisLite", "WGCNA", "withr", "xfun", "XML", "zoo" ), update = TRUE, ask = FALSE)

more details: BiocManager::valid()$too_new, BiocManager::valid()$out_of_date


From: Aaron Lun @.> Sent: Monday, 3 May 2021 4:39 PM To: drisso/SingleCellExperiment @.> Cc: Feng Tang @.>; Author @.> Subject: Re: [drisso/SingleCellExperiment] logNormcounts() function doesn't work for my singlecellExperiment object (#59)

Perhaps you should run BiocManager::valid(), as I suggested, and show the output.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/drisso/SingleCellExperiment/issues/59#issuecomment-831068573, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOUG3KT2A34CVYGY5UQZVU3TLZD2DANCNFSM437CQLNQ.

LTLA commented 3 years ago

Your version of scran is out of date. The latest version is 1.18.7, see the landing page.

In fact, all your Bioconductor packages seem to be from the previous release, and Biocmanager::valid() tells you as such; you're on BioC 3.11, and the latest Bioconductor release is 3.12, so that's that.

Now, I don't understand why you're seeing that error because it didn't occur in the previous release either. I can only suggest that you upgrade to the latest release and try with the latest versions of all relevant packages. This may or may not fix the problem, but if you stick to 3.11, then I definitely can't fix anything, because that release is already frozen.

tf1993614 commented 3 years ago

Hi Aaron,

I upgraded all the relevant packages and did a BioManager::valid() again. The output is shown below:

R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale: [1] LC_COLLATE=Chinese (Simplified)_China.936 LC_CTYPE=Chinese (Simplified)_China.936 [3] LC_MONETARY=Chinese (Simplified)_China.936 LC_NUMERIC=C [5] LC_TIME=Chinese (Simplified)_China.936

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

other attached packages: [1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.5 [4] purrr_0.3.4 readr_1.4.0 tidyr_1.1.3 [7] tibble_3.1.1 tidyverse_1.3.1 magrittr_2.0.1 [10] edgeR_3.32.1 limma_3.46.0 scran_1.18.7 [13] scater_1.18.6 ggplot2_3.3.3 SingleCellExperiment_1.12.0 [16] SummarizedExperiment_1.20.0 Biobase_2.50.0 GenomicRanges_1.42.0 [19] GenomeInfoDb_1.26.7 IRanges_2.24.1 S4Vectors_0.28.1 [22] BiocGenerics_0.36.1 MatrixGenerics_1.2.1 matrixStats_0.58.0

loaded via a namespace (and not attached): [1] bitops_1.0-7 fs_1.5.0 lubridate_1.7.10 [4] httr_1.4.2 tools_4.0.3 backports_1.2.1 [7] utf8_1.2.1 R6_2.5.0 irlba_2.3.3 [10] vipor_0.4.5 DBI_1.1.1 colorspace_2.0-0 [13] withr_2.4.2 tidyselect_1.1.1 gridExtra_2.3 [16] compiler_4.0.3 cli_2.5.0 rvest_1.0.0 [19] BiocNeighbors_1.8.2 xml2_1.3.2 DelayedArray_0.16.3 [22] scales_1.1.1 digest_0.6.27 XVector_0.30.0 [25] pkgconfig_2.0.3 sparseMatrixStats_1.2.1 dbplyr_2.1.1 [28] rlang_0.4.11 readxl_1.3.1 rstudioapi_0.13 [31] DelayedMatrixStats_1.12.3 generics_0.1.0 jsonlite_1.7.2 [34] BiocParallel_1.24.1 RCurl_1.98-1.3 BiocSingular_1.6.0 [37] GenomeInfoDbData_1.2.4 scuttle_1.0.4 Matrix_1.2-18 [40] Rcpp_1.0.6 ggbeeswarm_0.6.0 munsell_0.5.0 [43] fansi_0.4.2 viridis_0.6.0 lifecycle_1.0.0 [46] stringi_1.5.3 zlibbioc_1.36.0 grid_4.0.3 [49] dqrng_0.3.0 crayon_1.4.1 lattice_0.20-41 [52] haven_2.4.1 beachmat_2.6.4 hms_1.0.0 [55] locfit_1.5-9.4 knitr_1.33 pillar_1.6.0 [58] igraph_1.2.6 reprex_2.0.0 glue_1.4.2 [61] evaluate_0.14 BiocManager_1.30.12 modelr_0.1.8 [64] vctrs_0.3.7 cellranger_1.1.0 gtable_0.3.0 [67] assertthat_0.2.1 xfun_0.22 rsvd_1.0.5 [70] broom_0.7.6 viridisLite_0.4.0 beeswarm_0.3.1 [73] bluster_1.0.0 statmod_1.4.35 ellipsis_0.3.1

Bioconductor version '3.12'

create a valid installation with

BiocManager::install(c( "ellipsis", "processx", "rtracklayer", "vctrs" ), update = TRUE, ask = FALSE)

more details: BiocManager::valid()$too_new, BiocManager::valid()$out_of_date.

It seems all packages are in a healthy state. However, logNormcounts() function still doesn't work.

The public sequencing data I am using comes from here (https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSM2510617).

The analysis procedure I followed comes from this tutorial (http://bioinf.wehi.edu.au/edgeR/10XWorkshop/10X.pdf)


From: Aaron Lun @.> Sent: Monday, 3 May 2021 4:53 PM To: drisso/SingleCellExperiment @.> Cc: Feng Tang @.>; Author @.> Subject: Re: [drisso/SingleCellExperiment] logNormcounts() function doesn't work for my singlecellExperiment object (#59)

Your version of scran is out of date. The latest version is 1.18.7, see the landing pagehttps://www.bioconductor.org/packages/release/bioc/html/scran.html.

In fact, all your Bioconductor packages seem to be from the previous release, and Biocmanager::valid() tells you as such; you're on BioC 3.11, and the latest Bioconductor release is 3.12, so that's that.

Now, I don't understand why you're seeing that error because it didn't occur in the previous release either. I can only suggest that you upgrade to the latest release and try with the latest versions of all relevant packages. This may or may not fix the problem, but if you stick to 3.11, then I definitely can't fix anything, because that release is already frozen.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/drisso/SingleCellExperiment/issues/59#issuecomment-831075896, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOUG3KUPLMJGTCDBYJUGINLTLZFQ3ANCNFSM437CQLNQ.

LTLA commented 3 years ago

I don't know why it doesn't work for you. The following minimal example works fine for me.

library(BiocFileCache)
bfc <- BiocFileCache(ask=FALSE)
base <- "https://www.ncbi.nlm.nih.gov/geo/download/?acc=GSM2510617&format=file&file=GSM2510617%5FP7%2D"
barcodes <- bfcrpath(bfc, paste0(base[1], "barcodes%2Etsv%2Egz"))
genes <- bfcrpath(bfc, paste0(base[1], "genes%2Etsv%2Egz"))
mat <- bfcrpath(bfc, paste0(base[1], "matrix%2Emtx%2Egz"))

library(SingleCellExperiment)
rd <- read.table(genes, row.names=1, header=FALSE)
colnames(rd) <- "SYMBOL"
sce <- SingleCellExperiment(list(counts=Matrix::readMM(mat)), rowData=rd)
colnames(sce) <- readLines(barcodes)

library(scuttle)
logNormCounts(sce)
## class: SingleCellExperiment 
## dim: 27998 3302 
## metadata(0):
## assays(2): counts logcounts
## rownames(27998): ENSMUSG00000051951 ENSMUSG00000089699 ...
##   ENSMUSG00000096730 ENSMUSG00000095742
## rowData names(1): SYMBOL
## colnames(3302): AAACATACCCTTTA-1 AAACATACGAACTC-1 ... TTTGCATGAGCTAC-1
##   TTTGCATGCTTTAC-1
## colData names(1): sizeFactor
## reducedDimNames(0):
## altExpNames(0):
fengyuanelab commented 2 years ago

I am having the same issue. Have you find the solution for this?

LTLA commented 2 years ago

Depends on whether you can provide a minimum reproducible example.

LachlanD commented 2 years ago

I was also receiving this same error but I was able to work out that it was because I had labeled the dimensions on my count matrix ($Gene, $Cell) but the SingleCellExperiment had unlabeled dimnames. Removing the labels from the count matrix resolved the issue for me. Hope that might help.

LTLA commented 2 years ago

Thanks @LachlanD, that was a useful diagnosis. See the linked issue in the SummarizedExperiment repo for the follow-up.