satijalab / seurat

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

RunUMAP() is not working #9250

Closed tu-jihao closed 2 weeks ago

tu-jihao commented 1 month ago

I can not appoint reduction to run in function RunUMAP. Any ideals could help.

file = list.files()
seurat = list()
for (i in file) {
  pbmc = CreateSeuratObject(Read10X(i))
  pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-")
  pbmc =subset(pbmc, subset = nFeature_RNA > 500  & percent.mt < 25&nCount_RNA >1000)
  pbmc = NormalizeData(pbmc,verbose = T)
  pbmc = FindVariableFeatures(pbmc,selection.method = "vst",nfeatures = 2000,verbose = T)
  pbmc <- ScaleData(pbmc)
  pbmc <- RunPCA(pbmc,npcs = 30,verbose = T)
  pbmc <- JackStraw(object = pbmc,num.replicate = 100)
  pbmc = FindNeighbors(pbmc,dims = 1:10)
  pbmc <- FindClusters(object = pbmc,
                              dims.use = 1:10,
                              resolution = 0.3,)
  sweep.res.list_pbmc <- paramSweep(pbmc, PCs = 1:10, sct = FALSE)
  sweep.stats_pbmc <- summarizeSweep(sweep.res.list_pbmc, GT = FALSE)
  bcmvn_pbmc <- find.pK(sweep.stats_pbmc)
  pK_bcmvn <- bcmvn_pbmc$pK[which.max(bcmvn_pbmc$BCmetric)] %>% as.character() %>% as.numeric()
  homotypic.prop <- modelHomotypic(pbmc$seurat_clusters)    
  nExp_poi <- round(0.04*ncol(pbmc)) 
  nExp_poi.adj <- round(nExp_poi*(1-homotypic.prop))
  pbmc <- doubletFinder(pbmc, PCs = 1:10, pN = 0.25, pK = pK_bcmvn, nExp = nExp_poi, reuse.pANN = FALSE, sct = FALSE)
  pbmc = pbmc[,pbmc@meta.data[,8]%in%c("Singlet")]
  seurat[[i]] = pbmc
}
for (i in names(seurat)) {
  seurat[[i]]@meta.data = seurat[[i]]@meta.data[,1:4]
  seurat[[i]]@assays[["RNA"]]@meta.data = seurat[[i]]@assays[["RNA"]]@meta.data[,-1:-8]
}
pbmc = merge(seurat[[1]],unlist(seurat[-1]))
pbmc = JoinLayers(pbmc)
pbmc <- NormalizeData(pbmc)
pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000)
pbmc = ScaleData(pbmc)
pbmc@meta.data$group = c(rep(names(seurat)[1],ncol(seurat[[1]])),
                                         rep(names(seurat)[2],ncol(seurat[[2]])),
                                         rep(names(seurat)[3],ncol(seurat[[3]])),
                                         rep(names(seurat)[4],ncol(seurat[[4]])),
                                         rep(names(seurat)[5],ncol(seurat[[5]])))
**pbmc = RunHarmony(pbmc,"group")
pbmc <- RunPCA(pbmc)
pbmc = Seurat::RunUMAP(pbmc,reduction = "harmony")**

Error in RunUMAP.Seurat(pbmc, reduction = "harmony") : Only one parameter among 'dims', 'nn.name', 'graph', or 'features' should be used at a time to run UMAP

R version 4.3.2 (2023-10-31) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.6 LTS

Matrix products: default BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so; LAPACK version 3.9.0

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=en_US.UTF-8
[9] LC_ADDRESS=en_US.UTF-8 LC_TELEPHONE=en_US.UTF-8 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=en_US.UTF-8

time zone: Asia/Shanghai tzcode source: system (glibc)

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

other attached packages: [1] ROCR_1.0-11 KernSmooth_2.23-22 fields_16.2 viridisLite_0.4.2 spam_2.10-0
[6] DoubletFinder_2.0.4 harmony_1.2.0 Rcpp_1.0.13 ggsci_3.2.0 monocle_2.30.1
[11] DDRTree_0.1.5 irlba_2.3.5.1 VGAM_1.1-11 GSVA_1.50.5 clusterProfiler_4.10.1
[16] GSEABase_1.64.0 graph_1.80.0 annotate_1.80.0 XML_3.99-0.17 AUCell_1.24.0
[21] gson_0.1.0 gmt_2.0.3 stringr_1.5.1 org.Mm.eg.db_3.18.0 AnnotationDbi_1.64.1
[26] IRanges_2.36.0 S4Vectors_0.40.2 Biobase_2.62.0 BiocGenerics_0.48.1 readr_2.1.5
[31] Seurat.utils_2.6.5 magrittr_2.0.3 ggExpress_0.9.0 MarkdownHelpers_1.0.7 ggpubr_0.6.0
[36] CodeAndRoll2_2.6.0 Stringendo_0.6.0 SeuratHelper_0.0.0.9000 SeuratDisk_0.0.0.9021 pbmcsca.SeuratData_3.0.0 [41] pbmcref.SeuratData_1.0.0 ifnb.SeuratData_3.1.0 SeuratData_0.2.2.9001 Seurat_5.1.0 SeuratObject_5.0.2
[46] sp_2.1-4 CommPath_1.0.0 igraph_2.0.3 Matrix_1.6-5 ggplot2_3.5.1
[51] dplyr_1.1.4 plyr_1.8.9 reshape2_1.4.4 circlize_0.4.16

loaded via a namespace (and not attached): [1] ica_1.0-3 plotly_4.10.4 maps_3.4.2 zlibbioc_1.48.2
[5] tidyselect_1.2.1 bit_4.0.5 doParallel_1.0.17 clue_0.3-65
[9] lattice_0.21-9 rjson_0.2.21 blob_1.2.4 S4Arrays_1.2.1
[13] tictoc_1.2.1 png_0.1-8 cli_3.6.3 ggplotify_0.1.2
[17] goftest_1.2-3 purrr_1.0.2 uwot_0.2.2 shadowtext_0.1.3
[21] mime_0.12 tidytree_0.4.6 leiden_0.4.3.1 ComplexHeatmap_2.18.0
[25] stringi_1.8.4 backports_1.5.0 ggVennDiagram_1.5.2 httpuv_1.6.15
[29] rappdirs_0.3.3 RApiSerialize_0.1.3 xlsx_0.6.5 ggraph_2.2.1
[33] sctransform_0.4.1 sessioninfo_1.2.2 SoupX_1.6.2 DBI_1.2.3
[37] HDF5Array_1.30.1 withr_3.0.0 enrichplot_1.22.0 lmtest_0.9-40
[41] tidygraph_1.3.1 formatR_1.14 htmlwidgets_1.6.4 fs_1.6.4
[45] SingleCellExperiment_1.24.0 ggrepel_0.9.5 tidyverse_2.0.0 princurve_2.1.6
[49] labeling_0.4.3 SparseArray_1.2.4 cellranger_1.1.0 MatrixGenerics_1.14.0
[53] reticulate_1.38.0 zoo_1.8-12 XVector_0.42.0 RhpcBLASctl_0.23-42
[57] foreach_1.5.2 fansi_1.0.6 patchwork_1.2.0 caTools_1.18.2
[61] grid_4.3.2 data.table_1.15.4 ggtree_3.10.1 rhdf5_2.46.1
[65] R.oo_1.26.0 RSpectra_0.16-1 clipr_0.8.0 fastDummies_1.7.3
[69] gridGraphics_0.5-1 lazyeval_0.2.2 survival_3.5-7 scattermore_1.2
[73] crayon_1.5.3 RcppAnnoy_0.0.22 RColorBrewer_1.1-3 tidyr_1.3.1
[77] progressr_0.14.0 tweenr_2.0.3 later_1.3.2 ggridges_0.5.6
[81] codetools_0.2-19 GlobalOptions_0.1.2 HSMMSingleCell_1.22.0 KEGGREST_1.42.0
[85] Rtsne_0.17 shape_1.4.6.1 fastICA_1.2-4 limma_3.58.1
[89] splitstackshape_1.4.8 pkgconfig_2.0.3 GenomicRanges_1.54.1 aplot_0.2.3
[93] spatstat.sparse_3.1-0 ape_5.8 xtable_1.8-4 car_3.1-2
[97] httr_1.4.7 tools_4.3.2 globals_0.16.3 broom_1.0.6
[101] checkmate_2.3.1 nlme_3.1-163 futile.logger_1.4.3 lambda.r_1.2.4
[105] HDO.db_0.99.1 hdf5r_1.3.11 digest_0.6.36 farver_2.1.2
[109] tzdb_0.4.0 yulab.utils_0.1.4 viridis_0.6.5 glue_1.7.0
[113] cachem_1.1.0 VennDiagram_1.7.3 polyclip_1.10-6 generics_0.1.3
[117] Biostrings_2.70.3 presto_1.0.0 parallelly_1.37.1 statmod_1.5.0
[121] RcppHNSW_0.6.0 ScaledMatrix_1.10.0 carData_3.0-5 pbapply_1.7-2
[125] job_0.3.1 SummarizedExperiment_1.32.0 vroom_1.6.5 utf8_1.2.4
[129] graphlayouts_1.1.1 gtools_3.9.5 readxl_1.4.3 ggsignif_0.6.4
[133] gridExtra_2.3 shiny_1.8.1.1 GenomeInfoDbData_1.2.11 R.utils_2.12.3
[137] rhdf5filters_1.14.1 RCurl_1.98-1.16 memoise_2.0.1 pheatmap_1.0.12
[141] scales_1.3.0 R.methodsS3_1.8.2 future_1.33.2 RANN_2.6.1
[145] stringfish_0.16.0 spatstat.data_3.1-2 rstudioapi_0.16.0 cluster_2.1.4
[149] spatstat.utils_3.0-5 hms_1.1.3 fitdistrplus_1.1-11 munsell_0.5.1
[153] vioplot_0.5.0 ggcorrplot_0.1.4.1 cowplot_1.1.3 colorspace_2.1-0
[157] rlang_1.1.4 GenomeInfoDb_1.38.8 HGNChelper_0.8.14 DelayedMatrixStats_1.24.0
[161] sparseMatrixStats_1.14.0 dotCall64_1.1-1 ggforce_0.4.2 iterators_1.0.14
[165] matrixStats_1.3.0 abind_1.4-5 GOSemSim_2.28.1 tibble_3.2.1
[169] treeio_1.26.0 rJava_1.0-11 Rhdf5lib_1.24.2 DatabaseLinke.R_1.7.0
[173] futile.options_1.0.1 bitops_1.0-7 promises_1.3.0 scatterpie_0.2.3
[177] RSQLite_2.3.7 leidenbase_0.1.30 qvalue_2.34.0 openxlsx_4.2.5.2
[181] fgsea_1.28.0 DelayedArray_0.28.0 ReadWriter_1.5.3 GO.db_3.18.0
[185] compiler_4.3.2 colorRamps_2.3.4 beachmat_2.18.1 listenv_0.9.1
[189] BiocSingular_1.18.0 tensor_1.5 qs_0.26.3 MASS_7.3-60
[193] BiocParallel_1.36.0 spatstat.random_3.2-3 R6_2.5.1 fastmap_1.2.0
[197] fastmatch_1.1-4 rstatix_0.7.2 rsvd_1.0.5 gtable_0.3.5
[201] miniUI_0.1.1.1 deldir_2.0-4 htmltools_0.5.8.1 RcppParallel_5.1.8
[205] bit64_4.0.5 spatstat.explore_3.2-7 lifecycle_1.0.4 zip_2.3.1
[209] xlsxjars_0.6.1 MarkdownReports_4.7.0 vctrs_0.6.5 slam_0.1-50
[213] sm_2.2-6.0 spatstat.geom_3.2-9 DOSE_3.28.2 ggfun_0.1.5
[217] future.apply_1.11.2 pillar_1.9.0 gplots_3.1.3.1 combinat_0.0-8
[221] jsonlite_1.8.8 GetoptLong_1.0.5

tu-jihao commented 1 month ago

pbmc = RunUMAP(pbmc) will lead the same error :(

igrabski commented 2 weeks ago

Hi, to use RunUMAP, you should specify one of the arguments mentioned in the error message, i.e. 'dims', 'nn.name', 'graph', or 'features'. For example, if you wanted to use the first 30 dimensions of your PCA, you could specify dims=1:30.