API

Import Bering as:

import Bering as br

Objects

objects.Bering_Graph(df_spots_seg, ...[, ...])

Build Bering Object for training and prediction purposes.

Preprocess

preprocess.add_image_features(bg[, normalize])

Add image features to spots

Graph

graphs.BuildGraph(bg, df_spots[, ...])

Build nearest neighbor graph for mRNA/protein colocalization.

graphs.BuildGraph_fromRaw(bg, df_spots, ...)

Build Graphs from unsegmented spots

graphs.BuildWindowGraphs(bg[, ...])

Build Graphs for originally segemented cells.

graphs.CreateData(bg[, batch_size, ...])

Create training and testing data loader

Models

models.GCN(n_features, n_classes[, ...])

Node classification Model with Graph Convolutional Networks (GCN) and Multilayer Perceptron (MLP).

models.BaselineMLP(n_features, n_classes[, ...])

Node classification Model with Multilayer Perceptron (MLP) without using graph models.

models.GaussianSmearing([start, stop, ...])

This function is from torchdrug package.

models.ImageEncoder(image_dims[, ...])

Convolutional neural network to learn representation from staining images of different sizes.

models.EdgeClf(n_node_latent_features, image)

Edge classifier model which learns node classification embedding, image embedding and distance kernel

Training

training.TrainerNode([model, lr, ...])

Trainer for node classification model.

training.TrainerEdge(model, nodeclf_model, ...)

Trainer for edge classification model.

training.Training(bg[, ...])

Training both node classification and edge classification models.

training.EarlyStopper([patience, min_delta])

Early Stop implementation for loss values

Datasets

datasets.merfish_cortex_zhang([path])

Pre-processed MERFISH dataset from Zhang et al.

datasets.cosmx_nsclc_he([path])

Pre-processed Nanostring CoxMx dataset from He et al.

datasets.iss_ca1_qian([path])

Pre-processed ISS CA1 (sample 3-1 left) from Qian et al.

datasets.merfish_ileum_petukhov([path])

Pre-processed MERFISH dataset from Petukhov et al.

datasets.stereoseq_embryobrain_chen([path])

Pre-processed Stereo-seq dataset from Chen et al.

datasets.xenium_dcis_janesick([path])

Pre-processed Xenium dataset from Janesick et al.

Pretrained Models

datasets.model_merfish_cortex_zhang([path])

Pre-trained model of MERFISH Cortex dataset from Zhang et al.

datasets.model_cosmx_nsclc_he([path])

Pre-trained model of Nanostring ung cancer dataset from He et al.

datasets.model_iss_ca1_qian([path])

Pre-trained model of ISS CA1 hippocampus data (sample 3-1 left) from Qian et al.

datasets.model_xenium_dcis_janesick([path])

Pre-trained model of Xenium breast cancer dataset from Janesick et al.

Plotting

plotting.Plot_SliceImages(bg)

Plot the whole slice, with individual segmented cells as spots.

plotting.Plot_Classification(bg, cell_name)

Plot node classfication results on the original data and predicted data.

plotting.Plot_Segmentation(bg, cell_name[, ...])

Plot the segmentation results with cell IDs on the original data and predicted data.

plotting.Plot_Segmentation_Post(bg, location)

Plot Original Cell IDs and Cell ID distribution on latent space Either input a cell name and then extract a table or a pre-filtered spots window.

plotting.Plot_Classification_Post(bg, location)

Plot original spots and newly-segmented spots

Utilities

tools.node_classification(bg, df_spots[, ...])

Node classification for all spots in the slice

tools.cell_segmentation(bg[, use_image, ...])

Run cell segmentation for all spots.

tools.cell_annotation(bg[, min_transcripts, ...])

Annotate segmented cells based on ensemble strategy.

tools.cell_analyze(adata[, min_counts, ...])

Run a standard analysis pipeline from single-cell data with raw counts.