FACSPy.tl._compute_umap#
- FACSPy.tl._compute_umap(adata, uns_key, min_dist=0.5, spread=1.0, n_components=3, maxiter=None, alpha=1.0, gamma=1.0, negative_sample_rate=5, init_pos='spectral', random_state=187, a=None, b=None, method='umap', neighbors_key=None)#
Internal function to compute the UMAP embedding. The core of the function is implemented from scanpy with the important difference that the UMAP coordinates are returned and not written to the adata object.
- Parameters:
adata (
AnnData) – The anndata object of shape n_obs x n_vars where rows correspond to cells and columns to the channels.uns_key (
str) – Name of the slot in .obsm that the UMAP is calculated on.min_dist (
float) – The effective minimum distance between embedded points. Smaller values will result in a more clustered/clumped embedding where nearby points on the manifold are drawn closer together, while larger values will result on a more even dispersal of points. The value should be set relative to thespreadvalue, which determines the scale at which embedded points will be spread out. The default of in the umap-learn package is 0.1.spread (
float) – The effective scale of embedded points. In combination with min_dist this determines how clustered/clumped the embedded points are.n_components (
int) – The number of dimensions of the embedding.maxiter (
Optional[int]) – The number of iterations (epochs) of the optimization. Called n_epochs in the original UMAP.alpha (
float) – The initial learning rate for the embedding optimization.gamma (
float) – Weighting applied to negative samples in low dimensional embedding optimization. Values higher than one will result in greater weight being given to negative samples.negative_sample_rate (
int) – The number of negative edge/1-simplex samples to use per positive edge/1-simplex sample in optimizing the low dimensional embedding.init_pos (
Optional[Literal['paga','spectral','random'],ndarray]]) –How to initialize the low dimensional embedding. Called init in the original UMAP. Options are:
Any key for adata.obsm.
’paga’: positions from
paga().’spectral’: use a spectral embedding of the graph.
’random’: assign initial embedding positions at random.
A numpy array of initial embedding positions.
random_state (
Optional[Union`[:py:class:`int,RandomState]]) – If int, random_state is the seed used by the random number generator; If RandomState or Generator, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.a (
Optional[float]) – More specific parameters controlling the embedding. If None these values are set automatically as determined by min_dist and spread.b (
Optional[float]) – More specific parameters controlling the embedding. If None these values are set automatically as determined by min_dist and spread.method (
Literal['umap','rapids']) – Use the original ‘umap’ implementation, or ‘rapids’ (experimental, GPU only)neighbors_key (
Optional[str]) – If specified, umap looks .uns[neighbors_key] for neighbors settings and .obsp[.uns[neighbors_key][‘connectivities_key’]] for connectivities.
- Return type:
tuple[ndarray,dict]- Returns:
X_umap – The UMAP coordinates
params – A dictionary containing the parameters used for analysis.