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 toadata.obs
/adata.obsm
.Workflow#
Retrieve MAP parameters from params or
adata.uns['tagm.map.params']
.Split observations into labelled (marker) and unlabelled sets via
adata.obs[gt_col]
.Compute posterior probabilities for every component and the outlier model.
Allocate unlabelled proteins to the compartment with the highest Gaussian posterior probability.
Store allocations, per-protein probabilities and, optionally, the joint probability matrix/outlier probability.
- type adata:
- param adata:
anndata.AnnData
with proteins as observations and fractions as variables.- type params:
- param params:
Parameter dictionary as returned by
tagm_map_train()
. IfNone
(default) the parameters are read fromadata.uns['tagm.map.params']
.- type gt_col:
- 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 inadata.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 inadata.obs['tagm.map.outlier']
.- type inplace:
bool
(default:True
)- param inplace:
If
True
(default) modify adata in place and return None; otherwise return aDataFrame
with the predictions.- rtype:
- returns:
When
inplace
isFalse
a DataFrame with the allocation, allocation probability and outlier probability is returned; otherwiseNone
.