grassp.tl.tagm_map_predict

grassp.tl.tagm_map_predict#

tagm_map_predict(adata, params=None, gt_col=None, probJoint=False, probOutlier=True, inplace=True)[source]#

Predict sub-cellular localization for unlabelled proteins using a fitted TAGM-MAP model.

Given a set of maximum-a-posteriori (MAP) parameters obtained from tagm_map_train(), the function computes, for every protein with an unknown label, the posterior probability of originating from each compartment-specific Gaussian as well as from the global multivariate t outlier component. Proteins are allocated to the compartment whose Gaussian posterior is largest and the results are written to adata.obs / adata.obsm.

Workflow#

  1. Retrieve MAP parameters from params or adata.uns['tagm.map.params'].

  2. Split observations into labelled (marker) and unlabelled sets via adata.obs[gt_col].

  3. Compute posterior probabilities for every component and the outlier model.

  4. Allocate unlabelled proteins to the compartment with the highest Gaussian posterior probability.

  5. Store allocations, per-protein probabilities and, optionally, the joint probability matrix/outlier probability.

type adata:

AnnData

param adata:

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

type params:

dict | None (default: None)

param params:

Parameter dictionary as returned by tagm_map_train(). If None (default) the parameters are read from adata.uns['tagm.map.params'].

type gt_col:

str | None (default: None)

param gt_col:

Observation column containing marker labels (default "markers").

type probJoint:

bool (default: False)

param probJoint:

If True also store the joint probability matrix in adata.obs['tagm.map.joint'] (default False).

type probOutlier:

bool (default: True)

param probOutlier:

If True (default) store the probability of belonging to the outlier component in adata.obs['tagm.map.outlier'].

type inplace:

bool (default: True)

param inplace:

If True (default) modify adata in place and return None; otherwise return a DataFrame with the predictions.

rtype:

DataFrame | None

returns:

When inplace is False a DataFrame with the allocation, allocation probability and outlier probability is returned; otherwise None.

Parameters:
adata AnnData

params dict | None

gt_col str | None

probJoint bool

probOutlier bool

inplace bool

Return type:

DataFrame | None