From e4d865059f568dd321f29ec3481d2b72bde5d590 Mon Sep 17 00:00:00 2001 From: TomKellyGenetics Date: Thu, 5 Nov 2020 10:52:42 +0900 Subject: [PATCH] check compatibility with igraph cluster_leiden #1 --- R/leiden.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/leiden.R b/R/leiden.R index ebf8a72..c594541 100644 --- a/R/leiden.R +++ b/R/leiden.R @@ -280,6 +280,16 @@ leiden.igraph <- function(object, } } + #check whether compatible with igraph implementations in R + if(is_directed(object) && !is_bipartite(object)){ + #coerce to undirected graph object if possible + if(all(which_mutual(object) || which_loop(object)) || partition_type == "CPMVertexPartition"){ + object <- as.undirected(object, mode = "each") + } + } + call_igraph <- !is_directed(snn_graph) && !is_bipartite(object) && legacy == FALSE && partition_type == "CPMVertexPartition" || partition_type == "ModularityVertexPartition" + + #import python modules with reticulate numpy <- reticulate::import("numpy", delay_load = TRUE) leidenalg <- import("leidenalg", delay_load = TRUE)