Perform cell subclustering by taking an annotated group of
cells and performing another round of clustering on just that subset.
Several methods are implemented. subClusterCells()
is the main wrapper
function. doLeidenSubCluster()
and doLouvainSubCluster()
are more
specific implementations.
subClusterCells(
gobject,
name = "sub_clus",
cluster_method = c("leiden", "louvain_community", "louvain_multinet"),
cluster_column = NULL,
selected_clusters = NULL,
hvg_param = deprecated(),
hvf_param = list(reverse_log_scale = TRUE, difference_in_cov = 1, expression_values =
"normalized"),
hvg_min_perc_cells = deprecated(),
hvf_min_perc_cells = 5,
hvg_mean_expr_det = deprecated(),
hvf_mean_expr_det = 1,
use_all_genes_as_hvg = deprecated(),
use_all_feats_as_hvf = FALSE,
min_nr_of_hvg = deprecated(),
min_nr_of_hvf = 5,
pca_param = list(expression_values = "normalized", scale_unit = TRUE),
nn_param = list(dimensions_to_use = 1:20),
k_neighbors = 10,
resolution = 1,
n_iterations = 1000,
gamma = 1,
omega = 1,
python_path = NULL,
nn_network_to_use = "sNN",
network_name = "sNN.pca",
return_gobject = TRUE,
verbose = TRUE
)
doLeidenSubCluster(
gobject,
feat_type = NULL,
name = "sub_leiden_clus",
cluster_column = NULL,
selected_clusters = NULL,
hvf_param = list(reverse_log_scale = TRUE, difference_in_cov = 1, expression_values =
"normalized"),
hvg_param = deprecated(),
hvf_min_perc_cells = 5,
hvg_min_perc_cells = deprecated(),
hvf_mean_expr_det = 1,
hvg_mean_expr_det = deprecated(),
use_all_feats_as_hvf = FALSE,
use_all_genes_as_hvg = deprecated(),
min_nr_of_hvf = 5,
min_nr_of_hvg = deprecated(),
pca_param = list(expression_values = "normalized", scale_unit = TRUE),
nn_param = list(dimensions_to_use = 1:20),
k_neighbors = 10,
resolution = 0.5,
n_iterations = 500,
python_path = NULL,
nn_network_to_use = "sNN",
network_name = "sNN.pca",
return_gobject = TRUE,
toplevel = 2,
verbose = TRUE
)
doLouvainSubCluster(
gobject,
name = "sub_louvain_clus",
version = c("community", "multinet"),
cluster_column = NULL,
selected_clusters = NULL,
hvg_param = deprecated(),
hvf_param = list(reverse_log_scale = TRUE, difference_in_cov = 1, expression_values =
"normalized"),
hvg_min_perc_cells = deprecated(),
hvf_min_perc_cells = 5,
hvg_mean_expr_det = deprecated(),
hvf_mean_expr_det = 1,
use_all_genes_as_hvg = deprecated(),
use_all_feats_as_hvf = FALSE,
min_nr_of_hvg = deprecated(),
min_nr_of_hvf = 5,
pca_param = list(expression_values = "normalized", scale_unit = TRUE),
nn_param = list(dimensions_to_use = 1:20),
k_neighbors = 10,
resolution = 0.5,
gamma = 1,
omega = 1,
python_path = NULL,
nn_network_to_use = "sNN",
network_name = "sNN.pca",
return_gobject = TRUE,
verbose = TRUE
)
giotto
object
name for new clustering result
clustering method to use. Currently one of "leiden" (default), "louvain_community", "louvain_multinet"
cluster column to subcluster
only do subclustering on these clusters
deprecated
list of parameters for calculateHVF()
deprecated
threshold for detection in min percentage of cells
deprecated
threshold for mean expression level in cells with detection
deprecated
forces all features to be HVF and to be used as input for PCA
deprecated
minimum number of HVF, or all features will be used as input for PCA
list of parameters for runPCA()
list of parameters for createNearestNetwork()
number of k for createNearestNetwork()
resolution for community algorithm
number of iterations to run the Leiden algorithm.
gamma
omega
specify specific path to python if required
type of NN network to use (kNN vs sNN)
name of NN network to use
logical. return giotto
object (default = TRUE)
verbose
feature type
do not use
version of Louvain algorithm to use. One of "community" or "multinet", with the default being "community"
giotto
object with new subclusters appended to cell metadata
This function performs subclustering on selected clusters. The systematic steps are:
subset Giotto object
identify highly variable genes
run PCA
create nearest neighbouring network
do clustering
doLeidenSubCluster()
: Further subcluster cells using a NN-network and
the Leiden algorithm
doLouvainSubCluster()
: subcluster cells using a NN-network and the
Louvain algorithm
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
#> python already initialized in this session
#> active environment : '/usr/bin/python3'
#> python version : 3.10
#> checking default envname 'giotto_env'
#> a system default python environment was found
#> Using python path:
#> "/usr/bin/python3"
# Run some subclusterings based on "leiden_clus" annotations that already
# exist in the visium mini object
# default method is leiden subclustering
subClusterCells(g, cluster_column = "leiden_clus")
#> start with cluster: 1
#> 43 highly variable feats have been selected
#> Warning: ncp >= minimum dimension of x, will be set to
#> minimum dimension of x - 1
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: did not converge--results might be invalid!; try increasing work or maxit
#> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'igraph'
#> Run `reticulate::py_last_error()` for details.
# use louvain instead
subClusterCells(g,
cluster_column = "leiden_clus",
cluster_method = "louvain_community"
)
#> start with cluster: 1
#> 43 highly variable features have been selected
#> Warning: ncp >= minimum dimension of x, will be set to
#> minimum dimension of x - 1
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: did not converge--results might be invalid!; try increasing work or maxit
#> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'community'
#> Run `reticulate::py_last_error()` for details.
# directly call the more specific functions
doLeidenSubCluster(g, cluster_column = "leiden_clus")
#> start with cluster: 1
#> 43 highly variable feats have been selected
#> Warning: ncp >= minimum dimension of x, will be set to
#> minimum dimension of x - 1
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: did not converge--results might be invalid!; try increasing work or maxit
#> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'igraph'
#> Run `reticulate::py_last_error()` for details.
doLouvainSubCluster(g, cluster_column = "leiden_clus")
#> start with cluster: 1
#> 43 highly variable features have been selected
#> Warning: ncp >= minimum dimension of x, will be set to
#> minimum dimension of x - 1
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: did not converge--results might be invalid!; try increasing work or maxit
#> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'community'
#> Run `reticulate::py_last_error()` for details.