liana.mt.lrMistyData#
- liana.mt.lrMistyData(adata, resource_name='consensus', resource=None, nz_threshold=0.1, use_raw=False, layer=None, spatial_key='spatial', kernel='misty_rbf', bandwidth=100, set_diag=False, cutoff=0.1, zoi=0, verbose=False)#
Generate a MistyData object from an AnnData object in ligand-receptor format.
- Parameters:
- adata
AnnData AnnData object
- resource_name
str(default:'consensus') The name of the resource to use. See
show_resourcesfor available resources.- resource
DataFrame|None(default:None) A resource in the form of a pandas DataFrame. If None, the resource is selected using
select_resource.- nz_threshold
float(default:0.1) The threshold for the number of non-zero entries in each view.
- use_raw
bool(default:False) Whether to use the raw data of the AnnData object.
- layer
str|None(default:None) The layer of the AnnData object to use.
- spatial_key
str(default:'spatial') The key in adata.obsm where the spatial coordinates are stored.
- kernel
Literal['gaussian','exponential','linear','misty_rbf'] (default:'misty_rbf') A radial basis function kernel to use for the generation of the connectivity matrix for the extra view. Default is ‘misty_rbf’, a kernel derivative of a Gaussian kernel.
- bandwidth
float(default:100) The bandwidth of the kernel.
- set_diag
bool(default:False) Whether to set the diagonal of the connectivity matrix to 1.
- cutoff
float(default:0.1) The minimum value cutoff for the connectivity matrix.
- zoi
float(default:0) Zone of indifference of the kernel, i.e. the kernel is set to 0 for distances smaller than zoi.
- verbose
bool(default:False) Whether to print progress.
- adata
- Return type:
- Returns:
A
MistyDataobject with receptors in the intra view & ligands in the extra view.
Examples
Splits the data by the roles in a ligand-receptor resource: receptors become the targets (
'intra'), and the ligands of neighbouring cells the predictors ('extra'):>>> import liana as li >>> adata = li.ds.generate_toy_spatial() >>> misty = li.mt.lrMistyData(adata, bandwidth=200)
Fitting this asks, per receptor, which neighbouring ligands predict it – call the object with
bypass_intra=Trueso that the receptors are not predicted from each other. Seeliana.mt.MistyData.__call__().