
Calculate the local pairwise gene-gene correlation
hotspot_gene_cor_sc.RdThis method implements the HotSpot approach (see DeTomaso, et al.) to calculate the local gene-gene correlations and their Z-scores.
Usage
hotspot_gene_cor_sc(
object,
embd_to_use = "pca",
use_knn = TRUE,
hotspot_params = params_sc_hotspot(),
no_embd_to_use = NULL,
cells_to_take = NULL,
genes_to_take = NULL,
streaming = NULL,
working_mem_gb = 4,
random_seed = 42L,
.verbose = TRUE
)Arguments
- object
SingleCellsorMetaCellsclass.- embd_to_use
String. The embedding to use. Defaults to
"pca".- use_knn
Boolean. Shall the internal kNN be used. If set to yes, you need to ensure consistency. If you provide
cells_to_take, the function will regenerate the kNN graph with these cells.- hotspot_params
List with hotspot parameters, see
params_sc_hotspot()with the following elements:model - String. Which of the available models to use for the gene expression. Choices are one of
c("danb", "normal", "bernoulli").normalise - Boolean. Shall the data be normalised.
weighted_graph - Boolean. Shall the Gaussian kernel be applied to the neighbour distances. If
FALSE, every retained edge weighs one.neighborhood_factor - Float. Kernel width for
weighted_graph.knn - List of kNN parameters. See
params_knn_defaults()for available parameters and their defaults.
- no_embd_to_use
Optional integer. Number of embedding dimensions to use. If
NULLall will be used.- cells_to_take
Optional string vector. If you want to only use selected cells. If
NULLwill default to all cells_to_keep in the class.- genes_to_take
Optional string vector. If you wish to limit the search to a subset of genes. If
NULLwill default to all genes in the class.- streaming
Optional Boolean. Shall the data be streamed in. Useful for larger data sets where you wish to avoid loading in the whole data. If
NULL, will automatically detect. Ignored forMetaCells, which are held in memory.- working_mem_gb
Numeric. Approximate working memory (GB) the streaming pair path may use for resident gene panels. Ignored when
streamingisFALSE. Larger values mean fewer disk re-reads. Note this excludes the two dense N_genes x N_genes output matrices, which scale withgenes_to_use. Defaults to4(4 GB of memory allocated).- random_seed
Integer. Used for reproducibility.
- .verbose
Boolean or integer. Controls verbosity and returns run times.
FALSE-> quiet,TRUEor1L-> normal verbosity,2L-> detailed verbosity.
Details
Should a gene not be found in sufficient cells, the pairs with this gene will be set to 0. Please ensure prior to running the function that you are only calculating gene-gene auto-correlations that occur in sufficient cells.
Whether the neighbour distances need squaring before the kernel sees them
follows from the metric. With use_knn = TRUE it is taken from the metric
stored on the cached kNN graph, otherwise from ann_dist in
hotspot_params.
Examples
# local gene-gene correlations over a subset of the genes
sc <- demo_single_cells()
res <- hotspot_gene_cor_sc(
sc,
genes_to_take = get_gene_names(sc)[1:20],
.verbose = FALSE
)
res
#> Hotspot gene-gene local correlation results
#> Genes: 20
#> Cells: 500
#> Modules: not yet computed (see generate_hotspot_membership)
unlink(sc@dir_data, recursive = TRUE, force = TRUE)