satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.29k stars 915 forks source link

GetDimReduction Error. MNN has not been run for this object yet. #1146

Closed hkarakurt8742 closed 5 years ago

hkarakurt8742 commented 5 years ago

Hello, I have a data set and I used MNN for batch correction provided by Scater/Scran package. After that I used the original data (all data set counts combined in a matrix) to create a Seurat object. I want to assignd the MNN results as a dimension reduction to Seurat object with GetDimReduction function but I have an error. My code and error is down below:

colnames(x = mnn_res) <- paste0("MNN", 1:50) # MNN has 50 columns
seu <- SetDimReduction(object = seu, reduction.type = "mnn", slot = "cell.embeddings", new.data = mnn_res)
seu <- SetDimReduction(object = seu, reduction.type = "mnn", slot = "key", new.data = "MNN")

When I do that I have this error:

Error in DimPlot(object = seu, reduction.use = "mnn", pt.size = 0.5) : mnn has not been run for this object yet.

And when I want to check object@dr$mnn section I have this warning:

Error in if (more || nchar(output) > 80) { : missing value where TRUE/FALSE needed

What can be the reason of this error?

Thanks in advance.

My sessionInfo: R version 3.5.2 (2018-12-20) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS High Sierra 10.13.2 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] parallel stats4 stats graphics grDevices utils datasets methods base other attached packages: [1] ccRemover_1.0.4 scran_1.10.2 scater_1.10.1 SingleCellExperiment_1.4.1 SummarizedExperiment_1.12.0 DelayedArray_0.8.0 [7] BiocParallel_1.16.6 matrixStats_0.54.0 Biobase_2.42.0 GenomicRanges_1.34.0 GenomeInfoDb_1.18.2 IRanges_2.16.0 [13] S4Vectors_0.20.1 BiocGenerics_0.28.0 Seurat_2.3.4 Matrix_1.2-15 cowplot_0.9.4 ggplot2_3.1.0 loaded via a namespace (and not attached): [1] snow_0.4-3 backports_1.1.3 Hmisc_4.2-0 plyr_1.8.4 igraph_1.2.2 lazyeval_0.2.1 splines_3.5.2 [8] digest_0.6.18 foreach_1.4.4 htmltools_0.3.6 viridis_0.5.1 lars_1.2 gdata_2.18.0 magrittr_1.5 [15] checkmate_1.9.1 cluster_2.0.7-1 mixtools_1.1.0 ROCR_1.0-7 limma_3.38.3 R.utils_2.8.0 colorspace_1.4-0 [22] xfun_0.4 dplyr_0.8.0 crayon_1.3.4 RCurl_1.95-4.11 jsonlite_1.6 survival_2.43-3 zoo_1.8-4 [29] iterators_1.0.10 ape_5.2 glue_1.3.0 gtable_0.2.0 zlibbioc_1.28.0 XVector_0.22.0 kernlab_0.9-27 [36] Rhdf5lib_1.4.2 prabclus_2.2-7 DEoptimR_1.0-8 HDF5Array_1.10.1 scales_1.0.0 mvtnorm_1.0-8 edgeR_3.24.3 [43] bibtex_0.4.2 Rcpp_1.0.0 metap_1.1 dtw_1.20-1 viridisLite_0.3.0 htmlTable_1.13.1 reticulate_1.10 [50] foreign_0.8-71 bit_1.1-14 proxy_0.4-22 mclust_5.4.2 SDMTools_1.1-221 Formula_1.2-3 tsne_0.1-3 [57] htmlwidgets_1.3 httr_1.4.0 gplots_3.0.1.1 RColorBrewer_1.1-2 fpc_2.1-11.1 acepack_1.4.1 modeltools_0.2-22 [64] ica_1.0-2 pkgconfig_2.0.2 R.methodsS3_1.7.1 flexmix_2.3-14 nnet_7.3-12 locfit_1.5-9.1 dynamicTreeCut_1.63-1 [71] tidyselect_0.2.5 labeling_0.3 rlang_0.3.1 reshape2_1.4.3 munsell_0.5.0 tools_3.5.2 ggridges_0.5.1 [78] stringr_1.4.0 yaml_2.2.0 npsurv_0.4-0 knitr_1.21 bit64_0.9-7 fitdistrplus_1.0-14 robustbase_0.93-3 [85] caTools_1.17.1.1 purrr_0.3.0 RANN_2.6.1 pbapply_1.4-0 nlme_3.1-137 R.oo_1.22.0 hdf5r_1.0.1 [92] compiler_3.5.2 rstudioapi_0.9.0 beeswarm_0.2.3 png_0.1-7 lsei_1.2-0 statmod_1.4.30 tibble_2.0.1 [99] stringi_1.3.1 lattice_0.20-38 trimcluster_0.1-2.1 pillar_1.3.1 Rdpack_0.10-1 lmtest_0.9-36 BiocNeighbors_1.0.0 [106] data.table_1.12.0 bitops_1.0-6 irlba_2.3.3 gbRd_0.4-11 R6_2.4.0 latticeExtra_0.6-28 KernSmooth_2.23-15 [113] gridExtra_2.3 vipor_0.4.5 codetools_0.2-16 MASS_7.3-51.1 gtools_3.8.1 assertthat_0.2.0 rhdf5_2.26.2 [120] withr_2.1.2 GenomeInfoDbData_1.2.0 diptest_0.75-7 doSNOW_1.0.16 grid_3.5.2 rpart_4.1-13 tidyr_0.8.2 [127] class_7.3-15 DelayedMatrixStats_1.4.0 segmented_0.5-3.0 Rtsne_0.15 base64enc_0.1-3 ggbeeswarm_0.6.0 <\details>
andrewwbutler commented 5 years ago

Hi,

I haven't been able to reproduce the error here. If you check the which dimensional reduction objects you have stored, does "mnn" show up after running SetDimReduction?

names(seu@dr)

Also, if you're able to generate a reproducible example using either the provided pbmc_small object or one from the tutorials, that would be helpful as well for debugging purposes.

hkarakurt8742 commented 5 years ago

Hi,

I haven't been able to reproduce the error here. If you check the which dimensional reduction objects you have stored, does "mnn" show up after running SetDimReduction?

names(seu@dr)

Also, if you're able to generate a reproducible example using either the provided pbmc_small object or one from the tutorials, that would be helpful as well for debugging purposes.

Hello and thank you for answer. Apparently the error is based on a basic rownames problem. I fixed it and I can see "mnn" when I use names(seu@dr) but the other problem; "Error in if (more || nchar(output) > 80) { : missing value where TRUE/FALSE needed" is still there when I try to click on mnn section of object. Also, when I use FindClusters function with MNN as dimension reduction, the SNN matrix in object@snn have 2 integers (0 and 1). When I transform it to a matrix it only have a "1" in it. I wanted to use it for quality control but apparently it is not possible.

andrewwbutler commented 5 years ago

What command did you run for FindClusters?

hkarakurt8742 commented 5 years ago

What command did you run for FindClusters?

I used as this:

FindClusters(seu, genes.use = rownames(seu@data), reduction.type = "mnn", dims.use = 1:10)

Thanks in advance.

andrewwbutler commented 5 years ago

By default (in Seurat v2), the SNN matrix is not stored after running FindClusters. You can see this in the documentation as save.SNN parameter is FALSE by default. To be able to access the SNN matrix, you'll need to set save.SNN=TRUE.

hkarakurt8742 commented 5 years ago

By default (in Seurat v2), the SNN matrix is not stored after running FindClusters. You can see this in the documentation as save.SNN parameter is FALSE by default. To be able to access the SNN matrix, you'll need to set save.SNN=TRUE.

Thank you so much. Now everything looks okay and working.