sift.SiFT#

class sift.SiFT(adata, kernel_key=None, metric=KernelType.RBF, mask_key=None, src_key=None, tgt_key=None, copy=False, kernel_params=mappingproxy({}), **kwargs)[source]#

SiFT object.

Parameters:
  • adata (AnnData) – Annotated data object.

  • kernel_key (Optional[str]) – Key in anndata.AnnData where information for distance is stored.

  • metric (Literal['precomputed', 'knn', 'mapping', 'rbf', 'laplacian']) – The kernel type.

  • src_key (Optional[str]) – Mask for the source space of the kernel.

  • tgt_key (Optional[str]) – Mask for the target space of the kernel.

  • knn_key – wey in anndata.AnnData.obs for k-NN masking.

  • save (bool) – Whether to save the kernel.

  • kernel_params (Optional[Dict[str, Any]]) – Kernel object parameters [length_scale].

  • kwargs (Any) – Keyword arguments for kernel computations [precomputed_kernel, n_neighbors, knn_batch_key].

Examples

>>> import scanpy as sc
>>> import sift
>>> adata = sc.read(...)
>>> sft = sift.SiFT(
        adata=adata,
        kernel_key="cell_cycle_genes",
        metric="RBF",
    )
>>> sft.filter()

Attributes table#

adata

The SiFT annotated data object.

kernel

The pykeops kernel object.

Methods table#

filter([embedding_key, use_raw, ...])

Perform filtering, subtract the projection of the kernel from the expression.

materialize_kernel([kernel_containers, to_cpu])

Materialize the initialized kernel.

plot_kernel([save_path, show])

Visualize the cell-cell similarity kernel.

Attributes#

adata#

SiFT.adata#

The SiFT annotated data object.

kernel#

SiFT.kernel#

The pykeops kernel object.

Methods#

filter#

SiFT.filter(embedding_key=None, use_raw=False, pseudocount=False, key_added=None)[source]#

Perform filtering, subtract the projection of the kernel from the expression.

Parameters:
Return type:

Optional[AnnData]

Returns:

: The filtered data matrix.

materialize_kernel#

SiFT.materialize_kernel(kernel_containers=None, to_cpu=True)[source]#

Materialize the initialized kernel.

Parameters:
  • to_cpu (bool) – Whether to move kernel to CPU.

  • kernel_containers (Optional[Dict]) – Keyword arguments to the kernel call.

Return type:

ndarray

Returns:

: The materialized kernel after masking, if _kernel_mask is present.

Notes

This operation can result in out-of-memory (OOM) error.

plot_kernel#

SiFT.plot_kernel(save_path=None, show=True, **kwargs)[source]#

Visualize the cell-cell similarity kernel.

Parameters:
Return type:

Optional[Axes]

Returns:

: The axes object, if show = False, otherwise None.