Skip to contents

Reproduces the manuscript proximity figure (verbatim style port of density_bin_boxplot in the analysis helpers): for each focal cell the number of neighbour-type cells within radius micrometres is counted and binned, and each gene's raw counts are drawn as a boxplot per bin with the per-bin mean overlaid as a point. Because these genes are zero-inflated the box median sits at zero in most bins, so the mean point carries the trend.

Usage

plotProximity(
  object,
  spe,
  genes,
  focal,
  neighbour,
  radius = 30,
  breaks = c(0, 2, 4, 6, 8, Inf),
  condition = NULL,
  condition_colours = c("#3B6FB6", "#C0392B"),
  box_colour = "#4F8B5E",
  assay_name = "counts"
)

Arguments

object

A PACEFit (supplies the cell-type column used at fit time).

spe

The SpatialExperiment::SpatialExperiment that was fitted.

genes

Character vector of genes (shown as facets).

focal, neighbour

Focal and neighbour cell types.

radius

Neighbour search radius in micrometres (default 30).

breaks

Neighbour-count bin breaks (default c(0, 2, 4, 6, 8, Inf)).

condition

Optional colData column splitting the boxes by group, so the two arms of a condition cohort can be compared within each bin. TRUE uses the fit's own condition_col; NULL (default) pools all cells.

condition_colours

Colours for the condition levels.

box_colour

Box and mean-point colour, used when condition is NULL.

assay_name

Counts assay name (default "counts").

Value

A ggplot object.

Examples

spe <- readRDS(system.file("extdata", "bc_xenium_subset.rds", package = "PACE"))
fit <- readRDS(system.file("extdata", "pace_fit_example.rds", package = "PACE"))
g <- head(subset(neighbourSlopes(fit),
                  focal == "Macrophage" & neighbour == "Tumour")$gene, 2)
plotProximity(fit, spe, g, "Macrophage", "Tumour")