cluster cells using a NN-network and the Leiden community detection algorithm
doLeidenCluster(
gobject,
spat_unit = NULL,
feat_type = NULL,
name = "leiden_clus",
nn_network_to_use = "sNN",
network_name = "sNN.pca",
python_path = NULL,
resolution = 1,
weight_col = "weight",
partition_type = c("RBConfigurationVertexPartition", "ModularityVertexPartition"),
init_membership = NULL,
n_iterations = 1000,
return_gobject = TRUE,
set_seed = TRUE,
seed_number = 1234
)
giotto object
spatial unit (e.g. "cell")
feature type (e.g. "rna", "dna", "protein")
name for cluster, default to "leiden_clus"
type of NN network to use (kNN vs sNN), default to "sNN"
name of NN network to use, default to "sNN.pca"
specify specific path to python if required
resolution, default = 1
weight column to use for edges, default to "weight"
The type of partition to use for optimization. (e.g. "RBConfigurationVertexPartition", "ModularityVertexPartition")
initial membership of cells for the partition
number of interactions to run the Leiden algorithm. If the number of iterations is negative, the Leiden algorithm is run until an iteration in which there was no improvement.
logical. return giotto object (default = TRUE)
set seed
number for seed
giotto object with new clusters appended to cell metadata
This function is a wrapper for the Leiden algorithm implemented in python, which can detect communities in graphs of millions of nodes (cells), as long as they can fit in memory. See the leidenalg github page or the readthedocs page for more information.
Partition types available and information:
RBConfigurationVertexPartition: Implements Reichardt and Bornholdt’s Potts model with a configuration null model. This quality function is well-defined only for positive edge weights. This quality function uses a linear resolution parameter.
ModularityVertexPartition: Implements modularity. This quality function is well-defined only for positive edge weights. It does not use the resolution parameter
Set weight_col = NULL to give equal weight (=1) to each edge.
g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> cell_spatInfo_spatVector.shp
#> cell
#>
#> 3.2 read Giotto spatial centroid information
#> cell
#>
#> 3.3 read Giotto spatial overlap information
#> No overlaps were found, overlap loading will be
#> skipped
#>
#> 4. read Giotto image information
#> a giotto python environment was found
#> Using python path:
#> "/Users/yuanlab/Library/r-miniconda/envs/giotto_env/bin/pythonw"
doLeidenCluster(g)
#> leiden_clus has already been used, will be overwritten
#> An object of class giotto
#> >Active spat_unit: cell
#> >Active feat_type: rna
#> [SUBCELLULAR INFO]
#> polygons : cell
#> [AGGREGATE INFO]
#> expression -----------------------
#> [cell][rna] raw normalized scaled
#> spatial locations ----------------
#> [cell] raw
#> spatial networks -----------------
#> [cell] Delaunay_network spatial_network
#> spatial enrichments --------------
#> [cell][rna] cluster_metagene DWLS
#> dim reduction --------------------
#> [cell][rna] pca custom_pca umap custom_umap tsne
#> nearest neighbor networks --------
#> [cell][rna] sNN.pca custom_NN
#> attached images ------------------
#> images : alignment image
#>
#>
#> Use objHistory() to see steps and params used