From 1336cc97d053d46322148947a3375e2beb2f8652 Mon Sep 17 00:00:00 2001 From: brgew Date: Thu, 21 Mar 2024 17:43:00 -0700 Subject: [PATCH] Fix compute_partitions() in cluster_cells.R. --- DESCRIPTION | 2 +- R/cluster_cells.R | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index df57bc2..3a9c8c7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: monocle3 Title: Clustering, Differential Expression, and Trajectory Analysis for Single-Cell RNA-Seq -Version: 1.3.5 +Version: 1.3.6 Authors@R: c( person(given = "Hannah", family = "Pliner", diff --git a/R/cluster_cells.R b/R/cluster_cells.R index 69455dd..f0ed42b 100644 --- a/R/cluster_cells.R +++ b/R/cluster_cells.R @@ -599,6 +599,8 @@ compute_partitions <- function(g, optim_res, qval_thresh=0.05, verbose = FALSE){ + # The cells membership may have information about the + # clusters to which cells' nearest neighbors belong. cell_membership <- as.factor(igraph::membership(optim_res)) membership_matrix <- Matrix::sparse.model.matrix( ~ cell_membership + 0) num_links <- Matrix::t(membership_matrix) %*% @@ -617,6 +619,10 @@ compute_partitions <- function(g, num_links <- num_links_ij / total_edges + # Deal with zero total edges. + num_links[is.nan(num_links)] <- 0 + cluster_mat[is.nan(cluster_mat)] <- 0 + cluster_mat <- matrix(stats::p.adjust(cluster_mat), nrow=length(louvain_modules), ncol=length(louvain_modules))