
Run PHATE on a SingleCells/MetaCells object
phate_sc.RdWrapper around manifoldsR::phate() for the SingleCells and MetaCells
classes. PHATE (Potential of Heat-diffusion for Affinity-based Trajectory
Embedding) produces a low-dimensional embedding that preserves both local and
global structure by operating on a diffusion process over the data manifold.
Unlike UMAP or t-SNE, PHATE is explicitly designed to reveal continuous
progressions and branching structure, making it the preferred choice for data
with developmental or trajectory-like organisation.
By default (use_knn = FALSE) neighbours are computed from the chosen
embedding. PHATE searches 6 * k + 5 neighbours so that every point whose
affinity clears the kernel threshold can join, which the kNN graph stored on
the object (usually 15 wide) cannot supply. use_knn = TRUE reuses that
graph anyway and gives a narrower kernel. modality = "wnn" always uses the
integrated WNN graph. The algorithm then constructs a diffusion operator,
raises it to a
power (the diffusion time t, see manifoldsR::params_phate()) that
denoises the manifold, and computes potential distances that are finally
embedded via metric MDS.
Because PHATE inherently smooths over the kNN graph, it pairs naturally
with MetaCells: the combination yields a particularly clean view of
continuous biological processes on denoised data.
Usage
phate_sc(
object,
use_knn = FALSE,
embd_to_use = "pca",
slot_name = "phate",
no_embd_to_use = NULL,
modality = c("rna", "adt", "atac", "wnn"),
n_dim = 2L,
k = 5L,
knn_method = c("kmknn", "hnsw", "annoy", "nndescent", "balltree", "ivf", "exhaustive"),
nn_params = manifoldsR::params_nn(),
phate_params = manifoldsR::params_phate(),
seed = 42L,
.verbose = TRUE
)Arguments
- object
SingleCells,MetaCellsclass.- use_knn
Boolean. Use the kNN graph found in the object. Defaults to
FALSE, see the description.- embd_to_use
String. The embedding to use for PHATE. Must be available in the object.
- slot_name
String. The name of this embedding within the object. Defaults to
"phate".- no_embd_to_use
Optional integer. Number of embedding dimensions to use. If
NULLall will be used.- modality
String. On which modality to run PHATE. One of
c("rna", "adt", "atac", "wnn"). The two latter options are only available for multi-modal versions with the added data.- n_dim
Integer. Number of PHATE dimensions. Currently only
2Lis supported. Defaults to2L.- k
Integer. Number of nearest neighbours for graph construction. Defaults to
5L.- knn_method
String. Approximate nearest neighbour algorithm. One of
c("kmknn", "hnsw", "annoy", "nndescent", "balltree", "ivf", "exhaustive"). Defaults to"kmknn". Only used when neighbours are computed from the embedding.- nn_params
Named list. See
manifoldsR::params_nn().- phate_params
Named list. See
manifoldsR::params_phate().- seed
Integer. For reproducibility.
- .verbose
Boolean. Controls verbosity.
Examples
# PHATE embedding off the cached kNN graph
sc <- demo_single_cells()
sc <- phate_sc(sc, .verbose = FALSE)
dim(get_embedding(sc, "phate"))
#> [1] 500 2
unlink(sc@dir_data, recursive = TRUE, force = TRUE)