calculateCommunitiesStats.Rd
The results can subsequently be visualized with the function plotCommunitiesStats
This function requires a filtered set of connections in the GRN
object as generated by filterGRNAndConnectGenes
.
It then generates the TF-gene graph from the filtered connections, and clusters its vertices into communities using established community detection algorithms.
calculateCommunitiesStats(GRN, clustering = "louvain", forceRerun = FALSE, ...)
Object of class GRN
Character. Default louvain
. One of: louvain
, leiden
, leading_eigen
, fast_greedy
, optimal
, walktrap
. The community detection algorithm to be used. Please bear in mind the robustness and time consumption of the algorithms when opting for an alternative to the default.
TRUE
or FALSE
. Default FALSE
. Force execution, even if the GRN object already contains the result. Overwrites the old results.
Additional parameters for the used clustering method, see the igraph::cluster_*
methods for details on the specific parameters and what they do. For leiden
clustering, for example, you may add a resolution_parameter
to control the granularity of the community detection or n_iterations
to modify the number of iterations.
An updated GRN
object, with a table that consists of the connections clustered into communities stored in the
GRN@graph$TF_gene$clusterGraph
slot as well as within the igraph
object in GRN@graph$TF_gene$graph
(retrievable via igraph
using igraph::vertex.attributes(GRN@graph$TF_gene$graph)$community
, for example.)
# See the Workflow vignette on the GRaNIE website for examples
GRN = loadExampleObject()
#> Downloading GRaNIE example object from https://git.embl.de/grp-zaugg/GRaNIE/-/raw/master/data/GRN.rds
#> INFO [2023-08-16 17:27:33] Storing GRN@data$RNA$counts matrix as sparse matrix because fraction of 0s is > 0.1 (0.44)
#> Finished successfully. You may explore the example object. Start by typing the object name to the console to see a summaty. Happy GRaNIE'ing!
GRN = calculateCommunitiesStats(GRN, forceRerun = FALSE)
#> INFO [2023-08-16 17:27:33] Data already exists in object or the specified file already exists. Set forceRerun = TRUE to regenerate and overwrite.
#> INFO [2023-08-16 17:27:33] Finished successfully. Execution time: 0 secs