API
Contents
API#
Import Bento with:
import bento
Bento takes inspiration from the success of other tools in the python single-cell omics ecosystem. The API is organized under a set of modules including:
bento.pp
: preprocessing databento.tl
: subcellular spatial analysesbento.pl
: visualizing molecule-resolved spatial data, localization pattern statistics, and morebento.io
: reading and writing data stored in theAnnData
format, customized to hold molecular coordinates and segmentation masks
Preprocessing#
|
Get points DataFrame. |
|
Set points for the given AnnData object, data. |
|
Get values of layers reformatted as a long-form dataframe. |
Tools#
Sample Features#
Compute spatial properties of samples. A sample is the set of points for a given gene-pair. These include properties of shape(s) and points associated with each cell.
A list of available cell features and their names is stored in the dict bento.tl.sample_features
.
|
Calculate the set of specified features for every sample, defined as the set of molecules corresponding to every cell-gene pair. |
|
For a set of points, calculates the second moment of all points in a cell relative to the centroid of the total RNA signal. |
|
For a set of points, calculates properties of the L-function. |
|
For a set of points, computes the asymmetry of points within shape_name as well as the asymmetry of points outside shape_name. |
|
For a set of points, calculates the second moment of all points in a cell relative to the centroid of shape_name. |
|
For a set of points, calculates the fraction of points within shape_name out of all points in the cell. |
|
For a set of points, computes the proximity of points within shape_name as well as the proximity of points outside shape_name. |
Cell Features#
Compute spatial properties of cells. These include properties of shape(s) and points associated with each cell.
A list of available cell features and their names is stored in the dict bento.tl.cell_features
.
|
Compute multiple cell features at once. |
|
Compute the area of each cell. |
|
Compute the aspect ratio of the minimum rotated rectangle that contains each cell. |
|
Compute the minimum and maximum coordinate values that bound each cell. |
|
Compute the RNA density of each cell. |
|
Compute the second moment of each cell. |
|
Compute the opening (morphological) of distance d for each cell. |
|
Compute the perimeter of each cell. |
|
Compute the radius of each cell. |
|
Compute the length of the longest diagonal of each cell. |
Subcellular Shape Features#
Compute spatial properties of shapes linked to each cell, such as nuclei, other organelles, or regions of interest.
|
Check if shape_name is contained within the nucleus. |
|
|
|
|
|
|
|
|
|
Generate a grid of points contained within each cell. |
Localization Patterns#
|
Predict transcript subcellular localization patterns. |
|
Computes frequencies of localization patterns across cells and genes. |
|
Gene-wise test for differential localization across phenotype of interest. |
|
Calculate localization signatures by performing tensor decomposition on the dataset tensor. |
|
Perform tensor decomposition on the 3-dimensional tensor built from [cell, gene, layers]. |
|
Perform bento.tl.decompose_tensor() up to rank upper_rank repeating each decomposition runs times to compute a 95% confidence interval, plotting reconstruction error for each rank. |
Colocalization#
|
Calculate pairwise gene colocalization quotient in each cell. |
Plotting#
|
Plot quality control metric distributions. |
|
|
|
Plot the pattern distribution of each gene in a RadViz plot. |
|
Plot the cell fraction distribution of each pattern as a density plot. |
|
|
|
Plot pattern combination frequencies as an UpSet plot. |
|
Visualize gene pattern frequencies between groups of cells by plotting log2 fold change and -log10p, similar to volcano plot. |
Read/Write#
|
Load bento processed AnnData object from h5ad. |
|
Write AnnData to h5ad. |
|
Datasets#
|