liana.ms.lrdata_to_mudata#
- liana.ms.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 in
lrdata.var_names(e.g."celltype^ligand^receptor"). Matches thexy_sepconvention used byliana.mt.inflow. Defaults to'^'.- min_cells
int|None(default:5) Minimum cells (per cell identity if grouped by
groupby) 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 in
lrdata.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.mt.inflow, whosevar_namesencode the sender cell type as a prefix:>>> import liana as li >>> adata = li.ds.generate_toy_spatial() >>> lrdata = li.mt.inflow(adata, groupby="bulk_labels", resource_name="consensus") >>> mdata = li.ms.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.