liana.multi.lrdata_to_mudata#
- liana.multi.lrdata_to_mudata(lrdata, xy_sep='^', min_cells=5, min_features=10, obs_keys=None, verbose=False)#
Convert an inflow score AnnData object to a MuData object, where each modality corresponds to a unique sender cell type.
- Parameters:
adata – Annotated data object.
xy_sep (
str(default:'^')) – Separator between the sender cell-type/view prefix and the ligand-receptor interaction name inlrdata.var_names(e.g."celltype^ligand^receptor"). Matches thexy_sepconvention used byliana.method.inflow. Defaults to'^'.min_cells (
int|None(default:5)) – Minimum cells (per cell identity if grouped bygroupby) to be considered for downstream analysis.min_features (int | None, default 10) – Modalities with fewer than this many features after cell-filtering are dropped entirely. Pass
Noneto keep all modalities.obs_keys (
list[str] |None(default:None)) – List of keys inlrdata.obsthat should be included in the MuData object.verbose (
bool(default:False)) – Verbosity flag.
- Return type:
- Returns:
MuData MuData object with one modality per sender cell type.
- Raises:
TypeError – If
lrdatais not an AnnData object.ValueError – If any of the provided keys are not found in
lrdata.obs.
Examples
lrdatais normally the output ofliana.method.inflow, whosevar_namesencode the sender cell type as a prefix:>>> import liana as li >>> adata = li.testing.generate_toy_spatial() >>> lrdata = li.mt.inflow(adata, groupby='bulk_labels', ... resource_name='consensus') >>> mdata = li.mu.lrdata_to_mudata(lrdata)
The sender in each
'sender^ligand^receptor'name becomes one modality, so that every sender cell type can be modelled as its own view.