Skip to contents

Plot density correlation between two cell types

Usage

plotDensCor(
  spe,
  celltype1 = NULL,
  celltype2 = NULL,
  by.roi = TRUE,
  probs = 0.85,
  fit = c("spline", "linear"),
  df = 3,
  ...
)

Arguments

spe

A SpatialExperiment object.

celltype1

Cell type 1 to compare.

celltype2

Cell type 2 to compare.

by.roi

Logical. Plot facet by ROIs or not. Default to TRUE.

probs

A numeric scalar. The threshold of proportion that used to filter grids by density when ROIs have not been identified previously. Ignored if 'roi' is present in the 'metadata' component of spe. Default to 0.85.

fit

Character. Options are "spline" and "linear".

df

Integer. Degrees of freedom of the spline fit. Default to 3 (i.e., a cubic spline fit).

...

aesthetic mappings to pass to ggplot2::aes().

Value

A ggplot object.

Examples


data("xenium_bc_spe")

coi <- c("Breast cancer", "Fibroblasts")

spe <- gridDensity(spe, coi = coi)

spe <- findROI(spe, coi = coi, method = "walktrap")

plotDensCor(spe, celltype1 = "Breast cancer", celltype2 = "Fibroblasts")