API

Import Monkeybread as:

import monkeybread as mb

Calculations: calc

calc.cellular_niches(adata, cell_type_key, ...)

Compute cellular niches.

calc.neighborhood_profile(adata, groupby[, ...])

Calculates a neighborhood profile for each cell.

calc.cell_density(adata[, groupby, groups, ...])

Calculates the spatial distribution of cells of a given cell type using kernel density estimation.

calc.ligand_receptor_score(adata, ...[, ...])

Calculates an average co-expression score of a ligand-receptor pair between neighboring cells..

calc.ligand_receptor_score_per_niche(adata, ...)

Calculates an average co-expression score of a ligand-receptor pair between neighboring cells within each cellular niche calculated by monkeybread.calc.cellular_niches().

calc.shortest_distances(adata, groupby, ...)

Calculates the distance from each cell in one group to the nearest cell in another group.

calc.shortest_distances_pairwise(adata, ...)

Calculates the distance from each cell in one group to the nearest cell in another group.

calc.cell_neighbors(adata, groupby, group1, ...)

Calculate cell neighbors.

calc.cell_neighbors_from_masks(adata, ...[, ...])

Calculate cell neighbors.

calc.number_of_neighbors(adata, groupby, ...)

Given a set of query groups of cells, group_1, group_2, .

calc.number_of_neighbors_from_masks(adata, ...)

Given a set of query groups of cells, group_1, group_2, .

Plotting: plot

plot.neighbors_profile_matrixplot(...[, ...])

Heatmap plotting the mean, normalized neighbor count of each cell type within each niche.

plot.cell_density(adata, key[, spot_size, ...])

Plots the spatial density of cells across the tissue, as calculated by monkeybread.calc.cell_density().

plot.location_and_density(adata, groupby, groups)

A wrapper around both scanpy.pl.embedding() and monkeybread.calc.cell_density() that creates multi-panel figures showing both the raw location of cells of a given cell type, by calling scanpy.pl.embedding() and their density across the tissue by calling monkeybread.calc.cell_density().

plot.shortest_distances(observed_distances)

Plot the distribution of observed distances from each cell in one group (e.g., all T cells) to its closest cell in a second group (e.g., all macrophages) as calculated by monkeybread.calc.shortest_distances().

plot.shortest_distances_pairwise(...[, ...])

Plot a heatmap of the p-values calculated by monkeybread.stat.shortest_distances_pairwise() that is the result of testing the co-localization between every cell type in one set to every cell type in a second set (e.g., myeloid cell types to T cell subtypes).

plot.cell_neighbor_embedding(adata, ...[, ...])

Shows embeddings of cells with their neighbors.

plot.number_of_neighbors(neighbor_counts[, ...])

plot.embedding_filter(adata, mask[, color, ...])

Shows a filtered embedding, allowing for examination of specific cells.

plot.embedding_zoom(adata[, left_pct, ...])

Shows embeddings of cells neighboring other cells with zoomed focus.

plot.ligand_receptor_scatter(actual_scores, ...)

Plots a scatterplot highlighting the observed ligand-receptor scores and significance.

plot.ligand_receptor_embedding(adata, ...[, ...])

Plot the ligand-receptor co-expression score between pairs of neighboring cells.

plot.ligand_receptor_embedding_zoom(adata, ...)

Plot the ligand-receptor co-expression score between pairs of neighboring cells.

plot.ligand_receptor_score_barplot_per_niche(...)

Create a barplot showing the ligand/receptor score for a specific ligand/receptor pair within each niche.

plot.ligand_receptor_score_heatmap_per_niche(...)

Create a heatmap showing the ligand/receptor scores for a specific set of ligand/receptor pairs within each niche.

Statistical Tests: stat

stat.shortest_distances(adata, groupby, ...)

Calculates an expected null distribution of shortest distances from cells in group1 to cells in group2 by permuting coordinates of cells that aren't in group1.

stat.shortest_distances_pairwise(adata, ...)

Performs the same statistical analyses implemented by monkeybread.stat.shortest_distances(), but in a pairwise fashion between every cell type in group1 and every cell type in group2.

stat.ligand_receptor_score(adata, ...[, n_perms])

Calculates statistical significance of the co-expression of ligand-receptor pairs between neighboring cells.

Utility Functions: util

util.load_merscope([folder, ...])

Loads data from MERSCOPE, in accordance to the folder structure of the FFPE data release.

util.subset_cells(adata, by, subset[, ...])

Subsets cells based on gene expression and optionally labels them.

util.load_ligand_receptor_pairs_omnipath(adata)

Load ligand-receptor pairs from the Omnipath database that are also in the provided dataset.