grassp.tl.tagm_map_train

Contents

grassp.tl.tagm_map_train#

tagm_map_train(adata, gt_col, method='MAP', numIter=100, mu0=None, lambda0=0.01, nu0=None, S0=None, beta0=None, u=2, v=10, random_state=None, key_added='tagm_map', inplace=True)[source]#

Train a TAGM-MAP (T-Augmented Gaussian Mixture, MAP variant) model.

The training procedure follows Crook et al. 2018 and estimates component parameters for known marker classes while accommodating an outlier component modelled by a multivariate t distribution.

Workflow#

  1. Split observations into labelled (markers) and unlabelled according to adata.obs[gt_col].

  2. Compute empirical hyper-priors if not supplied.

  3. Run an EM algorithm to obtain maximum-a-posteriori (MAP) estimates of component means, covariances and mixing proportions.

  4. Store the fitted parameters in adata.uns[f'{key_added}_model'] when inplace is True.

type adata:

AnnData

param adata:

anndata.AnnData with proteins as observations and fractions as variables.

type gt_col:

str

param gt_col:

Column name identifying marker proteins (default "markers").

type method:

str (default: 'MAP')

param method:

Currently only "MAP" is implemented; reserved for future.

type numIter:

int (default: 100)

param numIter:

EM iterations (default 100).

type mu0:

ndarray | None (default: None)

param mu0:

Hyper-parameters of the Normal–Inverse-Wishart–Dirichlet prior. If None sensible empirical defaults are inferred.

type lambda0:

float (default: 0.01)

param lambda0:

Hyper-parameters of the Normal–Inverse-Wishart–Dirichlet prior. If None sensible empirical defaults are inferred.

type nu0:

int | None (default: None)

param nu0:

Hyper-parameters of the Normal–Inverse-Wishart–Dirichlet prior. If None sensible empirical defaults are inferred.

type S0:

ndarray | None (default: None)

param S0:

Hyper-parameters of the Normal–Inverse-Wishart–Dirichlet prior. If None sensible empirical defaults are inferred.

type beta0:

ndarray | None (default: None)

param beta0:

Hyper-parameters of the Normal–Inverse-Wishart–Dirichlet prior. If None sensible empirical defaults are inferred.

type u:

int (default: 2)

param u:

Beta prior parameters for the outlier mixing proportion.

type v:

int (default: 10)

param v:

Beta prior parameters for the outlier mixing proportion.

type random_state:

int | None (default: None)

param random_state:

Random seed for reproducibility.

type key_added:

str (default: 'tagm_map')

param key_added:

Prefix for the stored model (default "tagm_map"), matching the prefix tagm_map_predict() writes its output under. The fitted posteriors land in uns[f"{key_added}_model"], kept apart from the _params provenance slot that every annotator writes.

type inplace:

bool (default: True)

param inplace:

If True (default) write parameters to adata and return None; otherwise return the parameter dictionary.

rtype:

dict | None

returns:

MAP parameter dictionary when inplace is False.

Parameters:
adata AnnData

gt_col str

method str

numIter int

mu0 ndarray | None

lambda0 float

nu0 int | None

S0 ndarray | None

beta0 ndarray | None

u int

v int

random_state int | None

key_added str

inplace bool

Return type:

dict | None