grassp.tl.tagm_model

Contents

grassp.tl.tagm_model#

tagm_model(adata, key_added='tagm_map')[source]#

Fetch the stored TAGM model, preferring the current key.

uns[f"{key_added}_model"] is where tagm_map_train() writes the fitted posteriors; the dotted uns["tagm.map.params"] is where it used to, and where a pRoloc round trip puts its own, so both are accepted.

The model is deliberately not in uns[f"{key_added}_params"]: that slot holds the annotation provenance every annotator writes, and TAGM is the only one of them with a fitted model to persist as well. Sharing the key would have the prediction overwrite the thing it was predicting from.

Return type:

dict

Parameters:
adata AnnData

key_added str

Relation to pRoloc#

pRoloc’s tagmMapTrain returns a standalone MAPParams S4 object and writes nothing to the MSnSet – the model lives in the R session and is handed to tagmMapPredict as an argument. So there is no pRoloc convention for storing it in the data object, and the two uns slots are grassp’s own choice; keeping the model on the object is what lets tagm_map_predict(adata) work without threading it through, and what lets it survive an h5ad round trip.

The dictionary mirrors MAPParams’ five slots so the two stay comparable – method, priors, posteriors, datasize, and seed under grassp’s name random_state – plus gt_col and markers, which grassp needs because it reads the marker column from the stored model where pRoloc takes fcol at predict time.