grassp.io.read_prolocdata

grassp.io.read_prolocdata#

read_prolocdata(file_name, allow_nullable_strings=False, *, replace_nan=True, unknown_to_nan=True, set_colors=True)[source]#

Read a pRolocdata MSnSet file (.rda/.rds) into an AnnData object.

Reads R’s serialisation format directly with the pure-Python rdata package, so no R installation is involved. The MSnSet maps onto grassp’s layout without a transpose – exprs() is already features-by-fractions – with featureData becoming .obs, phenoData becoming .var, and experimentData becoming .uns["MIAPE_metadata"].

Parameters:
file_name str

Path to the file, or a URL (e.g. a raw pRolocdata GitHub link).

allow_nullable_strings bool (default: False)

If False, convert pandas nullable StringDtype columns in obs/var to regular Python object-dtype strings for compatibility with older anndata writers (anndata<0.11). If True, keep nullable string dtype.

replace_nan bool (default: True)

Replace NaN with 0 in .X and every layer. Kept on by default for backward compatibility, but consider False: in fractionation data a missing measurement is not a measured zero, and pRoloc offers filterNA precisely because the distinction matters.

unknown_to_nan bool (default: True)

Convert pRoloc’s literal "unknown" sentinel to NaN. Leaving this off is almost never what you want: every grassp annotator picks its markers with .notna(), so an untranslated "unknown" is treated as a real compartment and gets trained on as one. This is the only path where grassp does the conversion itself – the h5ad round trip leaves it to the R side, where the convention belongs.

set_colors bool (default: True)

Assign compartment colours to the label columns.

Return type:

AnnData

Returns:

adata : AnnData Proteins in .obs, fractions in .var.

See also

anndata.read_h5ad

Read an MSnSet that the grasspio R package wrote as h5ad. That is an ordinary h5ad, so no grassp function is involved in either direction.

Examples

>>> adata = gr.io.read_prolocdata("dunkley2006.rda")
>>> adata.obs["markers"].isna().sum()  # unlabelled proteins