partipy.compute_archetype_weights#
- partipy.compute_archetype_weights(adata, mode='automatic', length_scale=None, save_to_anndata=True, result_filters=None)#
Calculate weights for the data points based on their distance to archetypes using a squared exponential kernel.
- Parameters:
adata (anndata.AnnData) – An AnnData object containing the data and archetypes. The data should be stored in
adata.obsm[obsm_key]and the archetypes inadata.uns["AA_results"]["Z"].mode (str, default
automatic) – The mode for determining the length scale of the kernel: - “automatic”: The length scale is calculated as half the median distance from the data centroid to the archetypes. - “manual”: The length scale is provided by the user via thelength_scaleparameter.length_scale (float, default
None) – Ifmode="manual", this is the user-defined length scale for the kernel. Ifmode="automatic", it is calculated automatically.save_to_anndata (bool, default
True) – IfTrue, the weights are saved toadata.uns["AA_cell_weights"]under the resolved AA configuration. IfFalse, the weights are returned as a NumPy array.result_filters (Mapping[str, Any] | None, default
None) – Filters forwarded to_resolve_aa_resultto select the AA configuration for which weights are computed.
- Return type:
- Returns:
np.ndarray - If
save_to_anndatais True, weights are stored inadata.uns["AA_cell_weights"]andNoneis returned. - Ifsave_to_anndatais False, the computed weights are returned as a NumPy array.