Embeddings (GPU)¶
The CPU twin is bixverse.embed.
embed
¶
GPU UMAP, densMAP, t-SNE and PHATE.
The work runs in the manifolds_rs GPU estimators (UMAPGpu, DensMAPGpu,
TSNEGpu, PHATEGpu); inputs, slots and stamps are handled exactly as in
bixverse.embed, which runs the same code with the CPU estimators. The
*_defaults() builders return an estimator set to the defaults the functions
here use. There is no GPU den-SNE.
>>> bixverse_gpu.graph.find_neighbours(sc)
>>> umap(sc)
umap_defaults
¶
GPU UMAP set to the defaults of umap.
n_epochs=None is 500 under the default "adam_gpu".
tsne_defaults
¶
GPU t-SNE set to the defaults of tsne: perplexity 20, the GPU
three-kernel FFT optimiser and an IVF kNN.
phate_defaults
¶
GPU PHATE set to the defaults of phate: the CPU settings with an
NN-Descent GPU kNN. The diffusion and the MDS stay on the CPU.
umap
¶
umap(
sc: ScOrMc,
*,
use_knn: bool = True,
embd_to_use: str = "pca",
slot_name: str = "umap",
no_embd_to_use: int | None = None,
modality: Modality = "rna",
params: UMAPGpu | None = None,
) -> None
GPU UMAP.
With use_knn the cached kNN is reused and only the optimisation runs
on the GPU; without one cached, a warning and a GPU search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment. |
required |
use_knn
|
bool
|
Reuse the cached kNN. |
True
|
embd_to_use
|
str
|
The input embedding, |
'pca'
|
slot_name
|
str
|
The name in |
'umap'
|
no_embd_to_use
|
int | None
|
Number of leading dimensions to use. |
None
|
modality
|
Modality
|
The kNN and the slot: |
'rna'
|
params
|
UMAPGpu | None
|
The estimator. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the embedding or the kNN is stale, the embedding is
absent, or |
tsne
¶
tsne(
sc: ScOrMc,
*,
use_knn: bool = False,
embd_to_use: str = "pca",
slot_name: str = "tsne",
no_embd_to_use: int | None = None,
modality: Modality = "rna",
params: TSNEGpu | None = None,
) -> None
GPU t-SNE.
approx="fft_3k_gpu" (the default) runs the optimiser on the GPU in
fp32; the CPU approximations keep it on the CPU with only the kNN on the
GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment. |
required |
use_knn
|
bool
|
Reuse the cached kNN. |
False
|
embd_to_use
|
str
|
The input embedding. |
'pca'
|
slot_name
|
str
|
The name in |
'tsne'
|
no_embd_to_use
|
int | None
|
Number of leading dimensions to use. |
None
|
modality
|
Modality
|
The kNN and the slot: |
'rna'
|
params
|
TSNEGpu | None
|
The estimator. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
As |
densmap
¶
densmap(
sc: ScOrMc,
*,
use_knn: bool = True,
embd_to_use: str = "pca",
slot_name: str = "densmap",
no_embd_to_use: int | None = None,
modality: Modality = "rna",
params: DensMAPGpu | None = None,
) -> None
GPU densMAP.
Inputs are handled as in umap; with "adam_gpu" the density term runs
on the device alongside the rest of the update.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment. |
required |
use_knn
|
bool
|
Reuse the cached kNN. |
True
|
embd_to_use
|
str
|
The input embedding. |
'pca'
|
slot_name
|
str
|
The name in |
'densmap'
|
no_embd_to_use
|
int | None
|
Number of leading dimensions to use. |
None
|
modality
|
Modality
|
The kNN and the slot: |
'rna'
|
params
|
DensMAPGpu | None
|
The estimator. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
As |
References
Narayan, Berger & Cho, Nat Biotechnol, 2021.
phate
¶
phate(
sc: ScOrMc,
*,
use_knn: bool = False,
embd_to_use: str = "pca",
slot_name: str = "phate",
no_embd_to_use: int | None = None,
modality: Modality = "rna",
params: PHATEGpu | None = None,
) -> None
GPU PHATE.
The kNN search and, for spectral landmarks, the randomised SVD and
k-means run on the device; the diffusion and the MDS on the CPU. Off by
default, use_knn reuses the cached kNN, which should then be 6k + 5
wide, as in bixverse.embed.phate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sc
|
ScOrMc
|
The experiment. |
required |
use_knn
|
bool
|
Reuse the cached kNN. |
False
|
embd_to_use
|
str
|
The input embedding. |
'pca'
|
slot_name
|
str
|
The name in |
'phate'
|
no_embd_to_use
|
int | None
|
Number of leading dimensions to use. |
None
|
modality
|
Modality
|
The kNN and the slot: |
'rna'
|
params
|
PHATEGpu | None
|
The estimator. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
As |
References
Moon, et al., Nat Biotechnol, 2019.