calculate_cell_proportions: calculate_cell_proportions

View source: R/calculate_cell_proportions.R

calculate_cell_proportionsR Documentation

calculate_cell_proportions

Description

Calculates the number and proportion of each cell type.

Usage

calculate_cell_proportions(
  spe_object,
  reference_celltypes = NULL,
  celltypes_to_exclude = NULL,
  feature_colname = "Phenotype",
  plot.image = TRUE
)

Arguments

spe_object

SpatialExperiment object in the form of the output of format_image_to_spe.

reference_celltypes

String Vector specifying reference cell types. If NULL (default), then the proportion of each cell type against all cells is returned. Alternatively, a custom vector of cell types can be used as input, and these will be used as the denominator in the calculation of the proportions.

celltypes_to_exclude

String Vector specifying cell types to exclude. For example "OTHER" will exclude that celltype from the Total. If NULL, all cell types are included.

feature_colname

String. Column of cells to choose the cell type from (e.g. Phenotype, Cell.Type, etc).

plot.image

Boolean. Whether to plot the barplot of the cell percentages. By default is TRUE.

Value

A data.frame is returned

Examples

calculate_cell_proportions(SPIAT::defined_image, reference_celltypes = NULL, 
celltypes_to_exclude = "Others", feature_colname="Cell.Type", plot.image = FALSE)

TrigosTeam/SPIAT documentation built on Aug. 22, 2024, 7:50 p.m.