API
Toolkit functions
Preprocessing
Functions
|
Generates a DataFrame with the top 50 genes for each observation in an AnnData object. |
|
Extracts small image patches centered at specified coordinates and saves them as individual PNG files. |
|
Retrieves the library ID from the AnnData object, assuming it contains spatial data. |
|
Retrieves the scalefactors from the AnnData object for a given library ID. |
|
Retrieves the spot diameter in pixels from the AnnData object's scalefactors for a given library ID. |
|
Prepares data for alignment by reading an AnnData object and preparing the high-resolution tissue image. |
|
Loads spatial transcriptomics (ST) data from an .h5ad file and prepares it for annotation. |
Utilities
Functions
|
Load pretrained OmiCLIP (COCA ViT‑L‑14) model, its image preprocess, and tokenizer. |
|
Batch–encode a list of image file paths into L2‑normalized embeddings. |
|
Batch–encode a list of strings into L2‑normalized embeddings. |
|
Encodes an entire DataFrame column into (N, D) embeddings. |
Loki Align
Functions
|
Apply a 3x3 homography matrix to 2D coordinates. |
|
Aligns the source coordinates to the target coordinates using Coherent Point Drift (CPD) registration, and applies a homography transformation to warp the source coordinates accordingly. |
Find the homography between two sets of coordinates with only translation and rotation. |
Classes
|
Deformable registration. |
|
Expectation maximization point cloud registration. |
Loki Annotate
Functions
|
Annotates tissue image with similarity scores between image features and bulk RNA-seq features. |
|
Annotates tissue image with similarity scores between image features and marker gene features. |
|
Loads an image with annotation. |
Loki Decompose
Functions
|
Generates an AnnData object with OmiCLIP text or image embeddings. |
|
Performs cell type decomposition on spatial data (ST or image) with single-cell data . |
Loki Retrieve
Functions
|
Retrieves the top-k most similar ST based on the similarity between ST embeddings and image embeddings. |
Loki PredEx
Functions
|
Predicts ST gene expression by H&E image. |
Plotting
Functions
|
Optimized plot: target, source, and aligned coordinates with titles. |
|
Optimized plot with images in the background and subplot titles. |
|
Plots image with polygons. |
|
Plots tissue type annotation heatmap. |