Skip to contents

Compiles classification results, visualizations, and optional differential expression analysis into a self-contained HTML report using an internal R Markdown template.

Usage

report_classification(
  expr = NULL,
  subtype,
  probs = NULL,
  degs = NULL,
  idType = "SYMBOL",
  output_file = "HNSC_classification_report.html"
)

Arguments

expr

A numeric gene expression matrix with genes in rows and samples in columns. Required for the heatmap section.

subtype

A named character vector of predicted subtypes, as returned by classifyHNSC(outputType = "class"). A data frame with columns Sample and Subtype is also accepted.

probs

Optional. A probability matrix as returned by classifyHNSC(outputType = "prob"). If provided, a stacked bar chart of posterior probabilities is included in the report.

degs

Optional. A named list of data frames as returned by extract_top_genes. If provided, the top differentially expressed genes per subtype are included.

idType

Character string specifying the gene identifier type. One of "SYMBOL" (default), "ENSEMBL", "ENTREZID", or "REFSEQ". Only used when expr is provided for the heatmap section.

output_file

Character string for the output HTML file path. Default: "HNSC_classification_report.html" in the current working directory.

Value

The absolute path to the generated HTML file (invisibly).

Details

The report is rendered from an internal R Markdown template and includes the following sections:

  1. Classification Summary — a table of subtype distribution with counts and percentages.

  2. Subtype Distribution — a bar chart visualisation of the summary table.

  3. Posterior Probabilities — a stacked bar chart of per-sample subtype probabilities (only shown if probs is provided).

  4. Subtype Marker Gene Heatmap — an annotated heatmap of curated subtype-driver genes (only shown if expr is provided).

  5. Differentially Expressed Genes — top DEGs per subtype from one-vs-rest analysis (only shown if degs is provided).

  6. Sample-Level Classification — a complete table of per-sample assignments.

The HTML file is self-contained (all plots are embedded as base64) and can be shared with collaborators or included as supplementary material.

Note

Requires the rmarkdown and knitr packages. Install with: install.packages(c("rmarkdown", "knitr"))

See also

classifyHNSC for generating the required inputs, extract_top_genes for differential expression analysis.

Examples

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

# Minimal report (class labels only)
report_classification(subtype = subtypes)

# Full report with heatmap and probabilities
report_classification(
  expr    = TCGA_LUSC,
  subtype = subtypes,
  probs   = probs
)

# Include differential expression results
degs <- extract_top_genes(TCGA_LUSC, subtypes)
report_classification(
  expr    = TCGA_LUSC,
  subtype = subtypes,
  probs   = probs,
  degs    = degs
)
} # }