API
SCALLOPS provides an extensive API that supports data reading, writing, processing, and visualization, enabling users to work with OPS data efficiently, and be able to customize it to their needs.
Experiment Data Structure
The core data structure used to organize and handle experiments.
Spatial experiment containing images and labels. |
Reading
Modules for reading and handling input data, including image data, barcode data, and spatial information.
Get the physical spacing (resolution) of an image. |
|
Gets the stage pixel positions from the image at the specified path. |
|
|
Convert physical coordinates to pixel coordinates. |
|
Load barcodes from a CSV file. |
|
Read in an experiment from a directory of tiff, nd2, other Bio-Formats supported images or a zarr file. |
|
Read a single image from various supported formats. |
Load reads and barcodes information for in situ experiments. This function loads reads and |
|
|
Read an image or label at the given zarr node. |
Writing
Functions for saving images and metadata in various formats.
Save this experiment in Zarr format. |
|
Create a multi-scene hyperstack image from a dictionary of xarray DataArrays. |
|
|
Save array to OME-TIFF format. |
|
Taken and modified from https://github.com/blaineylab/OpticalPooledScreens. |
|
Export individual label crops as tiff or npy files. |
|
Write data to a Zarr group with optional metadata and scaling. |
Features
Tools to extract and analyze features from regions of interest, such as nuclei .
Find objects in a labeled array. |
|
Extract features from labeled regions in the image. |
|
Normalize features |
|
|
Rank features for characterizing perturbations. |
|
Aggregate features |
Registration
Modules for image alignment and registration.
Cross-Correlation
Alignment based on SKimage’ phase cross correlation
Align an image within cycles (timepoints) and then between cycles.
Align two images, using the channel at position channel_index (typically DAPI).
ITK
Alignment based on ITK
scallops.registration.itk.itk_align(...[, ...])Align a moving image to a fixed image using ITK registration.
Align a time-series of moving images to the specified time point using ITK registration.
Apply an ITK transform to an image.
Apply an ITK transform to image labels.
Landmarks
Find matching landmarks between two images
Match image to template across a grid of coordinates.
Match image to template.
Pixel-Based Decoding
Functions for decoding images at the pixel level using codebooks.
|
Call features using the supplied codebook. |
Calculate the scale factors that would result in the mean on bit intensity for each bit to be equal. |
|
Reshape a 5-dimensional array of shape (t, c, z, y, x) to a 2-dimensional array of shape (z+y+x, t+c). |
|
|
Unit normalize each feature. |
Spot-Based Decoding
Tools for decoding sequencing spots and assigning them to barcodes and labels.
Applies a linear transformation w * a = y, where y is the corrected data. |
|
Call the barcode for each label. |
|
|
Utility function to generate prefixes based on barcodes. |
|
Compute base counts per cycle. |
|
Estimate and correct differences in channel intensity and spectral overlap among sequencing channels using either median or Li and Speed method. |
|
Correct mismatches between called barcodes and barcodes in a whitelist. |
|
Call reads by assigning the base with the highest intensity. |
|
Combine sequencing and phenotype tables with one row per label. |
|
Convert peaks to bases. |
|
Computes the phred quality score of transformed data using the softmax function. |
|
Compute read statistics, such as mapped_reads, mapped_reads_within_labels, and average_reads_per_label. |
Summarize single base call mismatches in called barcodes in reads_df against whitelist in barcodes_df. |
|
|
Finds local maxima. |
|
Apply a maximum filter in a window of width. |
Normalize base intensities for every time and channel separately. |
|
Calculate recall, precision, f1, and accuracy for different cutoff value of peaks. |
|
Calculate recall, precision, f1, and accuracy for different cutoff value of peaks. |
|
|
Standard deviation over cycles, followed by mean across channels to estimate read locations. |
|
Apply Laplacian-of-Gaussian filter. |
Segmentation
Nuclei Segmentation
Segmentation tools for identifying nuclei in images, using popular algorithms such as Stardist.
scallops.segmentation.cellpose.segment_nuclei_cellpose(image)Segment nuclei using cellpose.
scallops.segmentation.stardist.segment_nuclei_stardist(image)Segment nuclei using StarDist.
scallops.segmentation.watershed.segment_nuclei_watershed(image)Segment nuclei using watershed algorithm.
Cell Segmentation
Tools for segmenting cells, using various algorithms, including watershed and propagation methods.
scallops.segmentation.cellpose.segment_cells_cellpose(image)Segment cells using cellpose.
Takes minimum intensity over cycles, followed by mean intensity over channels if both are present.
scallops.segmentation.propagation.segment_cells_propagation(...)Segment cells using propagation algorithm, matching cell labels to nuclei labels.
scallops.segmentation.watershed.segment_cells_watershed(...)Segment cells using watershed algorithm, matching cell labels to nuclei labels.
Utilities
Segmentation utility functions.
Find labels in y that overlap with labels in x.
Close labels using skimage.morphology.closing.
Takes minimum intensity over cycles, followed by mean intensity over channels if both are present.
Convert an image to a mask.
Remove labels at image boundaries.
Keep labels with area_min < area < area_max
Filter labels using region props.
Remove labels in masked regions
Removes small objects from labels.
Compute threshold using specified quantile after subtraction of the minimum per channel.
Xarray/Experiment Custom Operations
Custom operations for working with Xarray and experiments.
|
Apply a function to all combinations of the values for the given dimensions. |
|
Call a function for all combinations of the values for the given dimensions. |
|
Apply a function to all images in one or more experiments. |
Visualization
Visualization utilities for creating composite images, plots, and segmentation visuals.
Composites
Plot an experiment (one image per axis) composite using additive blending.
Plot an image composite using additive blending.
Plot a label montage.
Plot an image montage, which is a composite view of multiple images arranged in a grid.
Cross-talk
scallops.visualize.crosstalk.pairwise_channel_scatter_plot(bases)Pairwise channel intensity scatter plot.
Distributions
A utility function to create Cumulative Distribution Function (CDF) plots comparing a set of conditions against a reference condition.
scallops.visualize.distribution.comparative_effect_scatter(...)Plots and compares the effect sizes of two treatments with advanced highlighting and regression.
Create a ridge plot to visualize the distribution of a numeric variable across different categorical groups.
Generate a volcano plot to visualize differential expression.
Heatmaps
scallops.visualize.heatmap.base_call_mismatches_heatmap(...)Plot base call mismatches in a heatmap.
scallops.visualize.heatmap.in_situ_identity_matrix_plot(...)Generate an identity matrix depicting cellular read distribution categorized by read identity.
Plot summary statistics for each well and tile in a heatmap.
scallops.visualize.heatmap.plot_well_aggregated_heatmaps(df, ...)Generates aggregated heatmap plots for each well in the dataset using a specified aggregation function.
Histograms
Plot histogram per image/channel.
Generate a histogram plot depicting the percentage of cells containing barcode reads.
Imshow
Plot a 2-d image array from an image stack.
Plot a montage of gene-specific images at specified feature percentiles from a dataframe and image stack.
scallops.visualize.imshow.plot_plate(exp[, ...])Plot raw images per channel in the whole plate layout (mimics heatmap plot).
Display an image with overlaid tiles.
Napari
scallops.visualize.napari.imnapari(image[, ...])View image in Napari.
View an exp in Napari.
scallops.visualize.napari.add_bases(viewer, ...)Add bases to napari viewer.
Run radial distortion estimation.
Registration plots
Overlays 2-d images extracted from a DataArray for visualizing alignment of images from different rounds or channels selected with the sel parameter.
Plot raw images from a list of DataArray with registered images to be visualized.
Segmentation plots
Plot basic segmentation results.
Visualization Utilities
Additional utilities for visualizing multicolor labels and channels.
Compute thresholds per channel for contrast adjustment in visualization. |
|
Create axes labels with multiple colors. |
Stitching Utilities
Utilities specifically for stitching operations.
Create a binary mask where zeros indicate locations where tiles overlap. |
Datasets
Builtin datasets for testing
Example phenotype feature summary statistics. |
|
Example SBS and phenotype tiles from Optical Pooled Screens in Human Cells by Feldman et al. (https://www.cell.com/cell/fulltext/S0092-8674(19)31067-0). |