mira.time.normalize_diffmap#
- mira.time.normalize_diffmap(adata, diffmap_key='X_diffmap', rescale=True)#
Calculates the eigengap heuristic for selecting optimal number of diffusion components to represent dataset. By default, rescales and normalizes the l2 norm of each eigenvector to prioritize components with larger eigenvalues.
Rescaling eigenvectors produces a smoother pseudotime representation, but may over-smooth the nearest neighbor space and distort branch points and lineage paths. If branch points appear poorly-defined, try setting rescale to False.
- Parameters
- adataanndata.AnnData
Adata with diffusion map calculated.
- rescaleboolean, default = True
Whether to rescale magnitudes of eigenvectors. Rescaling produces smoother pseudotime, but may distort KNN graph and obfuscate fine differences between lineages.
- Returns
- adataanndata.AnnData
- .obs[‘diffmap’]np.ndarray[float] of shape (n_cells, n_comps)
Rescaled diffusion map subset with estimated optimal number of components.
- .obs[‘eigen_gap’]np.ndarray[float] of shape (15,)
Eigen gap, difference between previous and current eigenvalues, e.g. [1st - 2nd, 3rd - 2nd, …]. The component with the largest eigengap is taken to be the number of components needed to represent the dataset, as this represents the point where subsequent eigenvectors drop-off in the amount of variance explained.
Note
This function is part of the mira.time API and works with several others to help users understand lineage structures and dynamic processes in their data. Please refer to the pseudotime trajectory inference tutorial.