monkeybread.plot.shortest_distances

monkeybread.plot.shortest_distances(observed_distances, expected_distances=None, show=True, **kwargs)

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().

Optionally, also plot the null distribution of these distances under the null hypothesis that the two cell types do not co-locate. This null distribution must first be computed by monkeybread.stat.shortest_distances().

Parameters:
Return type:

Union[Axes, Tuple[Axes, Axes]]

Returns:

: If show = False, returns nothing. Otherwise, returns a single Axes object or a tuple of two Axes objects if expected_distances is provided.

Example

In the left-hand figure, we plot the distribution of distances between each cell in the first group to its closest cell in the second group. The right-hand plot shows the expected distribution under the null hypothesis that cells do not co-locate. The vertical red line denotes the distance threshold used to compute the test-statistic described by the p-value from monkeybread.stat.shortest_distances().

https://raw.githubusercontent.com/immunitastx/monkeybread/main/docs/_static/shortest_distances.png