ehrapy.tools.diffmap#
- ehrapy.tools.diffmap(edata, *, n_comps=15, neighbors_key=None, random_state=0, copy=False)[source]#
Diffusion Maps [CLL+05], [HBT15], [WHP+19].
Diffusion maps [CLL+05] has been proposed for visualizing biomedical data by [HBT15]. The tool uses the adapted Gaussian kernel suggested by [HBW+16] in the implementation of [WAT18]. The width (“sigma”) of the connectivity kernel is implicitly determined by the number of neighbors used to compute the graph in
neighbors(). To reproduce the original implementation using a Gaussian kernel, use method==’gauss’ inneighbors(). To use an exponential kernel, use the default method==’umap’. Differences between these options shouldn’t usually be dramatic.- Parameters:
edata (
EHRData) – Central data object.n_comps (
int, default:15) – The number of dimensions of the representation. neighbors_key: If not specified, diffmap looks .uns[‘neighbors’] for neighbors settings and .obsp[‘connectivities’], .obsp[‘distances’] for connectivities and distances respectively (default storage places for pp.neighbors). If specified, diffmap looks .uns[neighbors_key] for neighbors settings and .obsp[.uns[neighbors_key][‘connectivities_key’]], .obsp[.uns[neighbors_key][‘distances_key’]] for connectivities and distances respectively.neighbors_key (
str|None, default:None) – Key to stored neighbors.random_state (
int|RandomState|None, default:0) – Random seed for the initialization.copy (
bool, default:False) – Whether to return a copy of the Data object.
- Return type:
- Returns:
Depending on copy, returns or updates edata with the following fields.
X_diffmap :
numpy.ndarray(edata.obsm) Diffusion map representation of data, which is the right eigen basis of the transition matrix with eigenvectors as columns.diffmap_evals :
numpy.ndarray(edata.uns) Array of size (number of eigen vectors). Eigenvalues of transition matrix.