gene_clustering: Gene clustering using the Markov Cluster Algorithm (MCL)...

View source: R/gene_clustering.R

gene_clusteringR Documentation

Gene clustering using the Markov Cluster Algorithm (MCL) method.

Description

This function performs gene clustering using the MCL algorithm. The method starts by creating a graph with genes as nodes and edges connecting each gene to its nearest neighbors. Then the method use the MCL algorithm to detect clusters of co-expressed genes (method argument).

Usage

gene_clustering(
  object = NULL,
  s = 5,
  inflation = 2,
  method = c("closest_neighborhood", "reciprocal_neighborhood"),
  threads = 1,
  output_path = NULL,
  name = NULL,
  keep_nn = FALSE
)

Arguments

object

A ClusterSet object.

s

If method="closest_neighborhood", s is an integer value indicating the size of the neighbourhood used for graph construction. Default is 5.

inflation

A numeric value indicating the MCL inflation parameter. Default is 2.

method

Which method to use to build the graph. If "closest_neighborhood", creates an edge between two selected genes a and b if b is part of the kg closest nearest neighbors of a (with kg < k). If "reciprocal_neighborhood"), inspect the neighborhood of size k of all selected genes and put an edge between two genes a and b if they are reciprocally in the neighborhood of the other

threads

An integer value indicating the number of threads to use for MCL.

output_path

a character indicating the path where the output files will be stored.

name

a character string giving the name for the output files. If NULL, a random name is generated.

keep_nn

Deprecated. Use 'method' instead.

Value

A ClusterSet object

References

- Van Dongen S. (2000) A cluster algorithm for graphs. National Research Institute for Mathematics and Computer Science in the 1386-3681.

Examples

# Restrict vebosity to info messages only.
library(Seurat)
set_verbosity(1)

# Load a dataset
load_example_dataset("7871581/files/pbmc3k_medium")

# Select informative genes
res <- select_genes(pbmc3k_medium,
                    distance = "pearson",
                    row_sum=5)
                    
# Cluster informative features

## Method 1 - Construct a graph with a 
## novel neighborhood size
res <- gene_clustering(res, method="closest_neighborhood",
                       inflation = 1.5, threads = 4)
                       
# Display the heatmap of gene clusters
res <- top_genes(res)
plot_heatmap(res)
plot_heatmap(res, cell_clusters = Seurat::Idents(pbmc3k_medium))


## Method 2 - Conserve the same neighborhood 
## size
res <- gene_clustering(res, 
                       inflation = 2.2,
                       method="reciprocal_neighborhood")
                       
# Display the heatmap of gene clusters
res <- top_genes(res)
plot_heatmap(res)
plot_heatmap(res, cell_clusters = Seurat::Idents(pbmc3k_medium))


dputhier/scigenex documentation built on May 31, 2024, 8:59 a.m.