grassp.io.read_msnset

Contents

grassp.io.read_msnset#

read_msnset(path, *, set_colors=True, strict_spec=True)[source]#

Read a pRoloc artifact back into grassp.

This is the return leg of the round trip: write_msnset() out, grasspio’s grassp_write_msnset in R, then this. The artifact is already grassp-shaped, so the work is a contract-version check and two sanity warnings – proteins are in .obs, fractions in .var, matrix-valued fData/pData columns in .obsm/.varm with their class names in uns["obsm_colnames"]/uns["varm_colnames"], extra assayData elements in .layers. Nothing is renamed or converted.

Everything crosses except .obsp/.varp: eSet has no pairwise slot. Recompute the graph with grassp.pp.neighbors(), which is where it came from anyway.

Parameters:
path str | Path | AnnData

Path to an h5ad written by grasspio’s grassp_write_msnset (or by write_msnset()). An in-memory AnnData is passed through as-is.

set_colors bool (default: True)

Assign compartment colours via grassp.preprocessing.set_sensible_compartment_colors().

strict_spec bool (default: True)

Whether an artifact written by a newer contract version raises rather than warns.

Return type:

AnnData

Returns:

The artifact as an AnnData.

See also

read_proloc_results

Graft an artifact’s annotations onto an object you already have.

list_msnset_results

Inventory an artifact without reading it into a session.

Examples

>>> adata = gr.io.read_msnset("results.h5ad")
>>> adata.obs["markers"].isna().sum()               # unlabelled proteins   doctest: +SKIP