Skip to contents

Plot cell type composition in each density level of cell of interest.

Usage

plotCellCompo(
  spe,
  coi,
  id = "cell_type",
  level.name = paste0(janitor::make_clean_names(coi), "_contour"),
  by.roi = FALSE,
  all = TRUE
)

Arguments

spe

A SpatialExperiment object.

coi

A character vector of cell types of interest (COIs).

id

A character. The name of the column of colData(spe) containing the cell type identifiers. Set to cell_type by default.

level.name

The column name that generated by cellAssign.

by.roi

Logical. Default is FALSE, set to TRUE to allow plotting by ROI.

all

Logical. Whether to include all the cell types in the plot. Default to TRUE. If FALSE, the cell types specified in 'coi' will not be included in the plot.

Value

A ggplot object.

Examples


data("xenium_bc_spe")
spe <- gridDensity(spe, coi = c("Breast cancer", "Fibroblasts"))
spe <- findROI(spe, coi = c("Breast cancer", "Fibroblasts"))
spe <- getContour(spe, coi = "Breast cancer")
#> Using bins = 10 to draw contours.
spe <- allocateCells(spe)
#> Assigning cells to ROIs defined by Breast cancer, Fibroblasts 
#> Assigning cells to contour levels of Breast cancer 
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
plotCellCompo(spe, coi = "Breast cancer")

plotCellCompo(spe, coi = "Breast cancer", by.roi = TRUE)