cluster cells using a NN-network and the Leiden community detection algorithm as implemented in igraph

doLeidenClusterIgraph(
  gobject,
  spat_unit = NULL,
  feat_type = NULL,
  name = "leiden_clus",
  nn_network_to_use = "sNN",
  network_name = "sNN.pca",
  objective_function = c("modularity", "CPM"),
  weights = NULL,
  resolution_parameter = 1,
  beta = 0.01,
  initial_membership = NULL,
  n_iterations = 1000,
  return_gobject = TRUE,
  set_seed = TRUE,
  seed_number = 1234,
  ...
)

Arguments

gobject

giotto object

spat_unit

spatial unit (e.g. "cell")

feat_type

feature type (e.g. "rna", "dna", "protein")

name

name for cluster, default to "leiden_clus"

nn_network_to_use

type of NN network to use (kNN vs sNN), default to "sNN"

network_name

name of NN network to use, default to "sNN.pca"

objective_function

objective function for the leiden algo

weights

weights of edges

resolution_parameter

resolution, default = 1

beta

leiden randomness

initial_membership

initial membership of cells for the partition

n_iterations

number of interations to run the Leiden algorithm.

return_gobject

boolean: return giotto object (default = TRUE)

set_seed

set seed

seed_number

number for seed

...

Arguments passed on to igraph::cluster_leiden

vertex_weights

the vertex weights used in the Leiden algorithm. If this is not provided, it will be automatically determined on the basis of the objective_function. Please see the details of this function how to interpret the vertex weights.

Value

giotto object with new clusters appended to cell metadata

Details

This function is a wrapper for the Leiden algorithm implemented in igraph, which can detect communities in graphs of millions of nodes (cells), as long as they can fit in memory. See cluster_leiden for more information.

Set weights = NULL to use the vertices weights associated with the igraph network. Set weights = NA if you don't want to use vertices weights

Examples

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
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> 
#> checking default envname 'giotto_env'
#> a system default python environment was found
#> Using python path:
#>  "/usr/bin/python3"

doLeidenClusterIgraph(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