cole-trapnell-lab / monocle3

Other
330 stars 100 forks source link

Leiden Clustering #664

Closed sophmeye closed 1 year ago

sophmeye commented 1 year ago

Describe the bug After preprocessing and reducing dimensions on my cds, I am unable to cluster using the default leiden clustering method. I am given the error: Error in leidenbase::leiden_find_partition(graph_result[["g"]], partition_type = partition_type, : REAL() can only be applied to a 'numeric', not a 'NULL'

I am, however, able to use the louvain clustering method without any errors.

To Reproduce cluster_cells(cds, reduction_method = "UMAP", resolution = 1e-5)

traceback() 3: leidenbase::leiden_find_partition(graph_result[["g"]], partition_type = partition_type, initial_membership = initial_membership, edge_weights = edge_weights, node_sizes = node_sizes, seed = random_seed, resolution_parameter = cur_resolution_parameter, num_iter = num_iter, verbose = verbose) 2: leiden_clustering(data = reduced_dim_res, pd = colData(cds), weight = weight, nn_index = nn_index, k = k, nn_control = nn_control, num_iter = num_iter, resolution_parameter = resolution, random_seed = random_seed, verbose = verbose, ...) 1: cluster_cells(cds_CZ_x_fake, reduction_method = "UMAP", resolution = 1e-05)

Expected behavior Leidenbase should have run community detection

sessionInfo(): R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C LC_TIME=English_United States.utf8

time zone: America/New_York tzcode source: internal

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

other attached packages: [1] leidenbase_0.1.18 monocle3_1.3.1 SingleCellExperiment_1.22.0 SummarizedExperiment_1.30.2 GenomicRanges_1.52.0 GenomeInfoDb_1.36.0 IRanges_2.34.0
[8] S4Vectors_0.38.1 MatrixGenerics_1.12.2 matrixStats_1.0.0 Biobase_2.60.0 BiocGenerics_0.46.0

loaded via a namespace (and not attached): [1] gtable_0.3.3 ggplot2_3.4.2 ggrepel_0.9.3 lattice_0.21-8 vctrs_0.6.2 tools_4.3.0 bitops_1.0-7 generics_0.1.3
[9] parallel_4.3.0 tibble_3.2.1 fansi_1.0.4 pkgconfig_2.0.3 Matrix_1.5-4 sparseMatrixStats_1.12.0 assertthat_0.2.1 lifecycle_1.0.3
[17] GenomeInfoDbData_1.2.10 stringr_1.5.0 farver_2.1.1 compiler_4.3.0 munsell_0.5.0 terra_1.7-37 codetools_0.2-19 RCurl_1.98-1.12
[25] pillar_1.9.0 nloptr_2.0.3 crayon_1.5.2 MASS_7.3-58.4 uwot_0.1.14 DelayedArray_0.26.3 viridis_0.6.3 boot_1.3-28.1
[33] nlme_3.1-162 parallelly_1.36.0 tidyselect_1.2.0 digest_0.6.31 stringi_1.7.12 future_1.32.0 reshape2_1.4.4 dplyr_1.1.2
[41] listenv_0.9.0 labeling_0.4.2 splines_4.3.0 grid_4.3.0 colorspace_2.1-0 cli_3.6.1 magrittr_2.0.3 S4Arrays_1.0.4
[49] utf8_1.2.3 withr_2.5.0 DelayedMatrixStats_1.22.1 scales_1.2.1 XVector_0.40.0 globals_0.16.2 igraph_1.5.0 lme4_1.1-33
[57] gridExtra_2.3 viridisLite_0.4.2 irlba_2.3.5.1 RcppAnnoy_0.0.20 rlang_1.1.1 Rcpp_1.0.10 glue_1.6.2 rstudioapi_0.14
[65] minqa_1.2.5 R6_2.5.1 plyr_1.8.8 zlibbioc_1.46.0

Additional context I have previously clustered this same dataset successfully with the exact parameters stated.

pyjm commented 1 year ago

I am having the same error! Any thoughts on this would be very helpful.

> cds <- cluster_cells(cds)
Error in leidenbase::leiden_find_partition(graph_result[["g"]], partition_type = partition_type,  : 
  REAL() can only be applied to a 'numeric', not a 'NULL'
> traceback()
3: leidenbase::leiden_find_partition(graph_result[["g"]], partition_type = partition_type, 
       initial_membership = initial_membership, edge_weights = edge_weights, 
       node_sizes = node_sizes, seed = random_seed, resolution_parameter = cur_resolution_parameter, 
       num_iter = num_iter, verbose = verbose)
2: leiden_clustering(data = reduced_dim_res, pd = colData(cds), 
       weight = weight, nn_index = nn_index, k = k, nn_control = nn_control, 
       num_iter = num_iter, resolution_parameter = resolution, random_seed = random_seed, 
       verbose = verbose, ...)
1: cluster_cells(cds)

> utils::sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Thank you!!

ghost commented 1 year ago

Same error too. Monocle3 is the 1.3.1 version. It can work on the linux server system, but not work on my macos computer. The input file is the same.

QiuyuLian commented 1 year ago

Same error too.

QiuyuLian commented 1 year ago

I found if I specified "cluster_method = 'louvain'", it would work.... There might be something wrong with default parameter using leiden.

pyjm commented 1 year ago

Thanks @QiuyuLian!! Changing to "louvain" also works for me.

iichelhadi commented 1 year ago

same issue but what if I want to use leiden instead of louvain?

cierra-walker commented 1 year ago

same issue, following.

eegerber commented 1 year ago

same issue, following.

sands58 commented 1 year ago

Downgrading the igraph package to version 1.4.3 can solve this problem.

eegerber commented 1 year ago

Downgrading the igraph package to version 1.4.3 can solve this problem.

Thank you sands58!! This worked for me.

iichelhadi commented 1 year ago

Downgrading the igraph package to version 1.4.3 can solve this problem.

worked for me as well

chanucy97 commented 1 year ago

Thank you@Qiuyu Lian

Daisyxiaozhou commented 1 year ago

Thanks @QiuyuLian!! Changing to "louvain" also works for me. What version of R is yours, please?

Daisyxiaozhou commented 1 year ago

Downgrading the igraph package to version 1.4.3 can solve this problem.

worked for me as well

What version of R is yours, please?

Krithika-Bhuvan commented 1 year ago

For anyone interested this is the code packageurl <- "https://cran.r-project.org/src/contrib/Archive/igraph/igraph_1.4.3.tar.gz" install.packages(packageurl, repos=NULL, type="source")

Still getting the error even after downgrading

mesposit commented 1 year ago

For anyone interested this is the code packageurl <- "https://cran.r-project.org/src/contrib/Archive/igraph/igraph_1.4.3.tar.gz" install.packages(packageurl, repos=NULL, type="source")

Still getting the error even after downgrading

Have you tried restarting your R session and then loading all the necessary packages again?

Krithika-Bhuvan commented 1 year ago

Still tried that. It fails to load igraph Reason: image not found Error: loading failed Execution halted

Also tried to install monocle3 on google colab R , and that one says that it does not work with its R version

brgew commented 1 year ago

Hi,

The latest leidenbase version 0.1.25 should fix this problem. It can be installed from CRAN.

Best Wishes, Brent

LiMo-bioxer commented 1 year ago

This method is work well, many thanks.