spateo.tdr.interpolations.interpolation_vtk
#
Module Contents#
Functions#
|
Learn a continuous mapping from space to gene expression pattern with the method contained in VTK. |
- spateo.tdr.interpolations.interpolation_vtk.vtk_interpolation(source_adata: anndata.AnnData, target_points: numpy.ndarray | None = None, keys: str | list = None, spatial_key: str = 'spatial', layer: str = 'X', radius: float | None = None, n_points: int | None = None, kernel: Literal[shepard, gaussian, linear] = 'shepard', null_strategy: Literal[0, 1, 2] = 1, null_value: int | float = 0) anndata.AnnData [source]#
Learn a continuous mapping from space to gene expression pattern with the method contained in VTK.
- Parameters:
- source_adata
AnnData object that contains spatial (numpy.ndarray) in the obsm attribute.
- target_points
The spatial coordinates of new data point. If target_coords is None, generate new points based on grid_num.
- keys
Gene list or info list in the obs attribute whose interpolate expression across space needs to learned.
- spatial_key
The key in
.obsm
that corresponds to the spatial coordinate of each bucket.- layer
If
'X'
, uses.X
, otherwise uses the representation given by.layers[layer]
.- radius
Set the radius of the point cloud. If you are generating a Gaussian distribution, then this is the standard deviation for each of x, y, and z.
- n_points
Specify the number of points for the source object to hold. If n_points (number of the closest points to use) is set then radius value is ignored.
- kernel
The kernel of interpolations kernel. Available kernels are: * shepard: vtkShepardKernel is an interpolations kernel that uses the method of Shepard to perform
interpolations. The weights are computed as 1/r^p, where r is the distance to a neighbor point within the kernel radius R; and p (the power parameter) is a positive exponent (typically p=2).
- gaussian: vtkGaussianKernel is an interpolations kernel that simply returns the weights for all
points found in the sphere defined by radius R. The weights are computed as: exp(-(s*r/R)^2) where r is the distance from the point to be interpolated to a neighboring point within R. The sharpness s simply affects the rate of fall off of the Gaussian.
- linear: vtkLinearKernel is an interpolations kernel that averages the contributions of all points in
the basis.
- null_strategy
- Specify a strategy to use when encountering a “null” point during the interpolations process.
Null points occur when the local neighborhood(of nearby points to interpolate from) is empty.
- Case 0: an output array is created that marks points as being valid (=1) or null (invalid =0), and
the nullValue is set as well
Case 1: the output data value(s) are set to the provided nullValue
Case 2: simply use the closest point to perform the interpolations.
- null_value
see above.
- Returns:
an anndata object that has interpolated expression.
- Return type:
interp_adata