Skip to contents

Visualises the posterior probability of each TCGA molecular subtype (Atypical, Basal, Classical, Mesenchymal) across samples as a stacked bar chart. Samples are ordered by predicted subtype, then by confidence within each subtype group. Low-confidence samples — where the maximum probability falls below a user-specified threshold — are optionally highlighted with a visual marker.

Usage

plot_subtype_probabilities(
  probs,
  threshold = 0.5,
  mark_low = TRUE,
  palette = NULL
)

Arguments

probs

A numeric probability matrix returned by classifyHNSC(outputType = "prob"), with samples in rows and four subtype columns.

threshold

Numeric value between 0 and 1. Samples whose maximum posterior probability is below this threshold are flagged as low-confidence (default: 0.5).

mark_low

Logical. If TRUE (default), a red asterisk is placed above bars corresponding to low-confidence samples.

palette

A named character vector of four colours for the subtypes. Names must match the subtype column names. If NULL, a default colour palette is used.

Value

A ggplot2 object (stacked bar chart). The plot can be further customised with standard ggplot2 layers.

Details

This plot is useful for quickly assessing classification certainty across a cohort and for identifying borderline cases that may warrant further investigation.

Examples

if (FALSE) { # \dontrun{
data(TCGA_LUSC)
probs <- classifyHNSC(TCGA_LUSC, outputType = "prob")
plot_subtype_probabilities(probs)
plot_subtype_probabilities(probs, threshold = 0.5)
} # }