grassp.tl.resolve_diffusion

grassp.tl.resolve_diffusion#

resolve_diffusion(data, gene_sets, key_added='ann_diffusion', mode='likelihood', min_term_size=0, term_threshold=0.5, eta=1.0, tau=0.4, maxk=3, cap=12, nest_threshold=0.8, gene_key='gene_symbol', species='hsap', out_key=None, inplace=True)[source]#

(Re)resolve stored diffusion probabilities into a per-protein label, in place.

Reads obsm[{key_added}_probabilities] (written by independent_diffusion()) and writes obs[out_key] and obs[f"{out_key}_label_compact"]. out_key defaults to key_added for likelihood/argmax – overwriting the primary call, since that is what re-resolving means – and to f"{key_added}_specific" for specific, so an alternative resolution sits beside the default rather than replacing it. The resolver parameters are as in independent_diffusion(); gene_sets must be the vocabulary that was diffused (it defines the nesting). Re-resolving with the same parameters reproduces the stored call exactly. Lets you obtain several resolutions (e.g. likelihood and specific) or sweep min_term_size without re-diffusing. With inplace=False the labels are written to a copy, which is returned.

Return type:

AnnData | None

Parameters:
data AnnData

key_added str

mode Literal['likelihood', 'specific', 'argmax']

min_term_size int

term_threshold float

eta float

tau float

maxk int

cap int

nest_threshold float

gene_key str

species str

out_key str | None

inplace bool