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
MSnSetfile (.rda/.rds) into an AnnData object.Reads R’s serialisation format directly with the pure-Python
rdatapackage, so no R installation is involved. The MSnSet maps onto grassp’s layout without a transpose –exprs()is already features-by-fractions – withfeatureDatabecoming.obs,phenoDatabecoming.var, andexperimentDatabecoming.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
NaNwith0in.Xand every layer. Kept on by default for backward compatibility, but considerFalse: in fractionation data a missing measurement is not a measured zero, and pRoloc offersfilterNAprecisely because the distinction matters.- unknown_to_nan
bool(default:True) Convert pRoloc’s literal
"unknown"sentinel toNaN. 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.
- file_name
- Return type:
- Returns:
adata : AnnData Proteins in
.obs, fractions in.var.
See also
anndata.read_h5adRead an
MSnSetthat thegrasspioR 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