Skip to contents

Produces a tidy summary table from the output of classifyHNSC(outputType = "class"), showing sample counts, percentages, and an optional bar plot of the subtype distribution.

Usage

summarize_subtype(subtype, plot = TRUE)

Arguments

subtype

A named character vector or factor giving the predicted subtype for each sample, as returned by classifyHNSC(outputType = "class"). Must have names (sample IDs). Alternatively, a data frame with columns Sample and Subtype.

plot

Logical. If TRUE (default), a ggplot2 bar chart of the subtype distribution is printed as a side effect.

Value

A data frame (invisibly, if plot = TRUE) with columns:

  • Subtype: the four TCGA molecular subtypes

  • N: number of samples assigned to each subtype

  • Pct: percentage of total samples (rounded to 1 decimal)

  • Proportion: numeric proportion (0–1)

The rows are sorted by frequency in descending order. If a subtype has zero samples, it is still included with N = 0.

Details

The function always includes all four TCGA subtypes (Atypical, Basal, Classical, Mesenchymal) in the output, even if one or more have zero assigned samples. This ensures consistent output across cohorts.

Examples

if (FALSE) { # \dontrun{
data(TCGA_LUSC)
subtypes <- classifyHNSC(TCGA_LUSC, outputType = "class")

# Table + bar plot (default)
summarize_subtype(subtypes)

# Table only, store result
tbl <- summarize_subtype(subtypes, plot = FALSE)
print(tbl)
} # }