dcellwanger/CellTrails

Error when executing findStates() - Error in t.default(.exprs(sce[.useFeature(sce), ])) :

Closed this issue · 1 comments

Hello,

I'm trying to execute the follow code:

states(sce_obj) <- findStates(sce_obj, min_size=0.01, min_feat=5, max_pval=1e-4, min_fc=2)

however I'm running into this error message:

Error in t.default(.exprs(sce[.useFeature(sce), ])) :
argument is not a matrix

I'm not quite sure which assay it's accessing however this is what my counts matrices look like:

> str(counts(sce_obj))

Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
...@ i : int [1:3306205] 0 22 70 102 131 186 281 352 384 401 ...
..@ p : int [1:3759] 0 764 1702 1942 3475 4253 4796 5948 6948 7998 ...
..@ Dim : int [1:2] 32524 3758
..@ Dimnames:List of 2
.. ..$ : chr [1:32524] "rpl24" "cep97" "nfkbiz" "CU651657.1" ...
.. ..$ : chr [1:3758] "AAACCTGCAAGAGTCG_3" "AAACCTGCATTAACCG_3" >"AAACCTGGTGTGGTTT_3" "AAACCTGTCAGATAAG_3" ...
..@ x : num [1:3306205] 5 1 1 1 1 1 1 1 5 6 ...
..@ factors : list()

> str(logcounts(sce_obj))

Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:3306205] 0 22 70 102 131 186 281 352 384 401 ...
..@ p : int [1:3759] 0 764 1702 1942 3475 4253 4796 5948 6948 7998 ...
..@ Dim : int [1:2] 32524 3758
..@ Dimnames:List of 2
.. ..$ : chr [1:32524] "rpl24" "cep97" "nfkbiz" "CU651657.1" ...
.. ..$ : chr [1:3758] "AAACCTGCAAGAGTCG_3" "AAACCTGCATTAACCG_3" >"AAACCTGGTGTGGTTT_3" "AAACCTGTCAGATAAG_3" ...
..@ x : num [1:3306205] 3.19 1.73 1.73 1.73 1.73 ...
..@ factors : list()

Here's what my SingleCellExperiment object looks like:
> show(sce_obj)

class: SingleCellExperiment
dim: 32524 3758
metadata(0):
assays(2): counts logcounts
rownames(32524): rpl24 cep97 ... *3 *4
rowData names(0):
colnames(3758): AAACCTGCAAGAGTCG_3 AAACCTGCATTAACCG_3 ... >TTTGTCAGTGTGCGTC_3 TTTGTCATCACCGGGT_3
colData names(12): orig.ident nCount_RNA ... seq.method ident
reducedDimNames(4): PCA UMAP CellTrails CellTrails.tSNE
spikeNames(0):

I had the same issue happen when running embedSample() however I was able to convert my dgCMatrix into a regular matrix however I'm unsure as to convert it within the SingleCellExperiment object

Here's my sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.6 (Maipo)

Matrix products: default
BLAS: /gpfs/packages/R/3.5.1/lib64/R/lib/libRblas.so
LAPACK: /gpfs/packages/R/3.5.1/lib64/R/lib/libRlapack.so

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

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

other attached packages:
[1] devtools_2.3.0 usethis_1.6.1 wesanderson_0.3.6 RColorBrewer_1.1-2
[5] ggplot2_3.2.1 scran_1.10.2 CellTrails_1.7.1 SingleCellExperiment_1.4.1
[9] SummarizedExperiment_1.12.0 DelayedArray_0.8.0 BiocParallel_1.14.2 matrixStats_0.54.0
[13] Biobase_2.40.0 GenomicRanges_1.34.0 GenomeInfoDb_1.18.2 IRanges_2.16.0
[17] S4Vectors_0.20.1 BiocGenerics_0.28.0 Seurat_3.1.5

loaded via a namespace (and not attached):
[1] backports_1.1.2 plyr_1.8.4 igraph_1.2.2 lazyeval_0.2.1
[5] splines_3.5.1 listenv_0.8.0 scater_1.10.1 digest_0.6.25
[9] htmltools_0.4.0 viridis_0.5.1 gdata_2.18.0 fansi_0.4.0
[13] magrittr_1.5 memoise_1.1.0 cluster_2.0.7-1 ROCR_1.0-7
[17] remotes_2.1.1 limma_3.36.3 globals_0.12.5 prettyunits_1.0.2
[21] colorspace_1.3-2 ggrepel_0.8.0 dplyr_0.8.3 callr_3.4.3
[25] crayon_1.3.4 RCurl_1.95-4.11 jsonlite_1.6.1 EnvStats_2.3.1
[29] survival_2.42-6 zoo_1.8-7 ape_5.4 glue_1.4.1
[33] gtable_0.2.0 zlibbioc_1.26.0 XVector_0.22.0 leiden_0.3.1
[37] cba_0.2-21 pkgbuild_1.0.6 Rhdf5lib_1.4.3 future.apply_1.3.0
[41] HDF5Array_1.10.1 scales_1.0.0 edgeR_3.24.3 Rcpp_1.0.3
[45] dtw_1.20-1 viridisLite_0.3.0 reticulate_1.10 rsvd_1.0.2
[49] proxy_0.4-22 tsne_0.1-3 htmlwidgets_1.5.1 httr_1.4.1
[53] gplots_3.0.3 ellipsis_0.3.0 ica_1.0-2 pkgconfig_2.0.2
[57] uwot_0.1.8 locfit_1.5-9.1 dynamicTreeCut_1.63-1 tidyselect_1.1.0
[61] labeling_0.3 rlang_0.4.6 reshape2_1.4.3 munsell_0.5.0
[65] tools_3.5.1 cli_2.0.2 ggridges_0.5.0 stringr_1.4.0
[69] maptree_1.4-7 npsurv_0.4-0 processx_3.4.2 fs_1.3.1
[73] fitdistrplus_1.0-11 caTools_1.17.1.1 purrr_0.3.3 RANN_2.6
[77] dendextend_1.13.4 pbapply_1.3-4 future_1.17.0 nlme_3.1-137
[81] compiler_3.5.1 rstudioapi_0.11 curl_3.2 beeswarm_0.2.3
[85] plotly_4.9.2 png_0.1-7 testthat_2.3.2 lsei_1.2-0
[89] tibble_2.1.3 statmod_1.4.30 stringi_1.4.6 ps_1.3.2
[93] desc_1.2.0 lattice_0.20-35 Matrix_1.2-14 vctrs_0.3.1
[97] pillar_1.4.3 lifecycle_0.1.0 lmtest_0.9-36 RcppAnnoy_0.0.12
[101] BiocNeighbors_1.0.0 data.table_1.12.8 cowplot_0.9.3 bitops_1.0-6
[105] irlba_2.3.2 patchwork_1.0.0 R6_2.2.2 KernSmooth_2.23-15
[109] gridExtra_2.3 vipor_0.4.5 sessioninfo_1.1.1 codetools_0.2-15
[113] pkgload_1.1.0 MASS_7.3-51.6 gtools_3.8.1 assertthat_0.2.0
[117] rhdf5_2.26.2 rprojroot_1.3-2 withr_2.1.2 sctransform_0.2.0
[121] GenomeInfoDbData_1.1.0 mgcv_1.8-24 grid_3.5.1 rpart_4.1-13
[125] tidyr_1.0.0 DelayedMatrixStats_1.4.0 Rtsne_0.13 ggbeeswarm_0.6.0

Any insight is greatly appreciated, thank you!!

Hi @ntran95,

Unfortunately, some methods implemented in CellTrails are are not optimized for sparse matrices (yet). The best workaround is to convert your sparse (dgCMatrix) matrix into a dense matrix:

logcounts(sce_obj) <- as.matrix(logcounts(sce_obj))

I hope this helps.

Thanks for using CellTrails!