Skip to contents

Creates oncoplots (mutation landscapes) to visualize genomic alterations across genes and samples with optional clinical annotations.

Usage

ggoncoplot(
  data,
  sampleVar,
  geneVars,
  clinicalVars = NULL,
  plotType = "oncoplot",
  maxGenes = 20,
  maxSamples = 50,
  sortBy = "mutation_count",
  colorScheme = "default",
  showMutationLoad = TRUE,
  showGeneFreq = TRUE,
  showClinicalAnnotation = FALSE,
  plotWidth = 800,
  plotHeight = 600,
  fontSize = 10,
  showLegend = TRUE
)

Arguments

data

The data as a data frame.

sampleVar

Variable containing sample identifiers.

geneVars

Variables representing genes or mutations (0/1 or categorical values).

clinicalVars

Optional clinical variables for annotation (e.g., age, stage, treatment).

plotType

Type of plot to generate.

maxGenes

Maximum number of genes to display (most frequently mutated).

maxSamples

Maximum number of samples to display.

sortBy

Method for sorting samples in the plot.

colorScheme

Color scheme for the oncoplot.

showMutationLoad

Display mutation load bar plot alongside oncoplot.

showGeneFreq

Display gene mutation frequency alongside oncoplot.

showClinicalAnnotation

Display clinical annotations as heatmap.

plotWidth

Width of the plot in pixels.

plotHeight

Height of the plot in pixels.

fontSize

Font size for plot labels.

showLegend

Display plot legend.

Value

A results object containing:

results$instructionsa html
results$mainan image
results$mutationSummarya table
results$sampleSummarya table
results$clinicalSummarya table
results$cooccurrencea table
results$plotInfoa table

Tables can be converted to data frames with asDF or as.data.frame. For example:

results$mutationSummary$asDF

as.data.frame(results$mutationSummary)

Examples

# \donttest{
data <- data.frame(
    SampleID = paste0("S", 1:10),
    TP53 = c(1, 0, 1, 0, 1, 0, 0, 1, 0, 1),
    KRAS = c(0, 1, 0, 1, 0, 1, 1, 0, 1, 0),
    PIK3CA = c(1, 1, 0, 0, 1, 0, 1, 1, 0, 0)
)
ggoncoplot(
    data = data,
    sampleVar = "SampleID",
    geneVars = c("TP53", "KRAS", "PIK3CA")
)
#> Error: 'setData' does not exist in this results element
# }