CalcClusterAverages_Gruffi: Calculate Cluster Averages for Granules in a Seurat Object

View source: R/gruffi.R

CalcClusterAverages_GruffiR Documentation

Calculate Cluster Averages for Granules in a Seurat Object

Description

Calculates the central tendency (mean or median) of specified scores for clusters (granules) within a Seurat object and optionally plots these averages.

Usage

CalcClusterAverages_Gruffi(
  col_name = "Score.GO.0006096",
  obj = combined.obj,
  split_by = GetGruffiClusteringName(obj),
  stat = c("mean", "median", "normalized.mean", "normalized.median")[3],
  scale.zscore = FALSE,
  quantile.thr = 0.99,
  absolute.thr = FALSE,
  plotit = FALSE,
  save.plot = FALSE,
  return.plot = FALSE,
  max.bin.plot = 50,
  simplify = TRUE,
  suffix = NULL,
  ylab.text = paste("Cluster", stat, "score"),
  title = paste("Cluster", stat, col_name),
  subtitle = NULL,
  width = 8,
  height = 6,
  xlb = if (absolute.thr) {
     paste("Threshold at", absolute.thr)
 } else {
    
    paste("Black lines: ",
    Stringendo::kppd(Stringendo::percentage_formatter(quantile.thr)), "quantiles |",
    "Cl. >", Stringendo::percentage_formatter(quantile.thr), "are highlighted. |",
    split_by)
 },
  ...
)

Arguments

col_name

Name of the numeric metadata column to calculate averages for. Default: 'Score.GO.0006096'.

obj

Seurat single cell object, Default: combined.obj

split_by

Name of the clustering (categorical metadata column) to calculate averages within. Default: First clustering result from Seurat.utils::GetClusteringRuns(obj).

stat

Method to calculate the central tendency. Options are "mean", "median", "normalized.mean", and "normalized.median". Default: "normalized.mean".

scale.zscore

Logical flag to scale the calculated scores as z-scores. Default: FALSE.

quantile.thr

Quantile threshold for cutoff, Default: 0.99

absolute.thr

Use an absolute threshold? Default: FALSE

plotit

Draw a plot? Default: FALSE

save.plot

Save plot into a file? Default: FALSE

max.bin.plot

Maximum number of clusters for which a barplot is considered feasible, otherwise a histogram is drawn. Default: 50.

suffix

Suffix to append to the plot/file name. Default: NULL.

ylab.text

Y-axis label. Default: paste("Cluster", stat, "score")

title

Plot title, Default: paste("Cluster", stat, col_name)

subtitle

Plot subtitle, Default: NULL

width

Plot width, Default: 8

height

Plot height, Default: 6

xlb

X-axis label for the plot, with dynamic content based on absolute.thr and quantile.thr. Default varies based on these parameters.

...

Additional parameters passed to internally called functions.

See Also

percentage_formatter, iprint select_all, group_by_all, summarise, context sym sem, sortbyitsnames


jn-goe/gruffi documentation built on Nov. 7, 2024, 10:38 p.m.