liana.utils.interpolate_adata#
- liana.utils.interpolate_adata(target, reference, spatial_key, layer=None, use_raw=True, method='linear', fill_value=0, verbose=False)#
Interpolates spatial data from a target AnnData object to a reference AnnData object based on spatial coordinates.
The function creates a new AnnData object where the
.Xattribute is filled with interpolated data using the specified method.- Parameters:
target (
AnnData) – The AnnData object to be interpolated.reference (
AnnData) – The AnnData object to be used as reference.spatial_key (
str) – Key inadata.obsmthat contains the spatial coordinates. Default is'spatial'.layer (
str(default:None)) – Layer in anndata.AnnData.layers to use. If None, use anndata.AnnData.X.use_raw (
bool(default:True)) – Use raw attribute of adata if present.method (
str(default:'linear')) – Interpolation method. Seescipy.interpolate.griddatafor more information.fill_value (
float(default:0)) – Value to fill in for points outside of the convex hull of the input points.verbose (
bool(default:False)) – Verbosity flag.
- Return type:
- Returns:
AnnData: A new AnnData object with the same metadata as the reference but with interpolated spatial data in
.X.