Creates an interactive oncoplot to visualize the mutation landscape of cancer cohorts.
Usage
ggoncoplot(
  data,
  col_genes,
  col_samples,
  col_mutation_type = NULL,
  genes_to_include = NULL,
  genes_to_ignore = NULL,
  col_tooltip = col_samples,
  topn = 10,
  return_extra_genes_if_tied = FALSE,
  draw_gene_barplot = FALSE,
  draw_tmb_barplot = FALSE,
  copy = c("sample", "gene", "tooltip", "mutation_type", "nothing"),
  palette = NULL,
  metadata = NULL,
  metadata_palette = NULL,
  col_samples_metadata = col_samples,
  cols_to_plot_metadata = NULL,
  metadata_require_mutations = TRUE,
  pathway = NULL,
  col_genes_pathway = col_genes,
  show_all_samples = FALSE,
  total_samples = c("any_mutations", "all", "oncoplot"),
  sample_order = NULL,
  interactive = TRUE,
  options = ggoncoplot_options(),
  verbose = TRUE
)Arguments
- data
 data for oncoplot. A data.frame with 1 row per mutation in your cohort. Must contain columns describing gene_symbols and sample_identifiers (data.frame)
- col_genes
 name of data column containing gene names/symbols (string)
- col_samples
 name of data column containing sample identifiers (string)
- col_mutation_type
 name of data column describing mutation types (string, optional)
- genes_to_include
 specific genes to include in the oncoplot (character, optional)
- genes_to_ignore
 names of the genes that should be ignored (character, optional)
- col_tooltip
 name of data column containing whatever information you want to display in (string, defaults to col_samples)
- topn
 how many of the top genes to visualize. Ignored if
genes_to_includeis supplied (number, default 10)- return_extra_genes_if_tied
 instead of strictly returning
topngenes, in the case of ties (where multiple genes are mutated in the exact same number of samples, complicating selection of top n genes), return all tied genes (potentially more than topn). If FALSE, will return strictlytopngenes, breaking ties based on order of appearance in dataset (flag, default FALSE)- draw_gene_barplot
 add a barplot describing number of samples with each gene mutated (right side) (flag, default FALSE)
- draw_tmb_barplot
 add a barplot describing total number of mutations in each sample (above main plot). If a single gene is mutated multiple times, all mutations are counted towards total (flag, default FALSE)
- copy
 value to copy to clipboard when an oncoplot tile is clicked (string, one of 'sample', 'gene', 'tooltip', 'mutation_type', 'nothing', default 'sample')
- palette
 a named vector mapping all possible mutation types (vector names) to colors (vector values, optional)
- metadata
 dataframe describing sample level metadata. One column must contain unique sample identifiers. Other columns can describe numeric / categorical metadata (data.frame, optional)
- metadata_palette
 A list of named vectors. List names correspond to metadata column names (categorical only). Vector names to levels of columns. Vector values are colors, the vector names are used to map values in data to a color. (optional)
- col_samples_metadata
 which column in metadata data.frame describes sample identifiers (string, defaults to col_samples)
- cols_to_plot_metadata
 names of columns in metadata that should be plotted (character, optional)
- metadata_require_mutations
 filter out samples from metadata lacking any mutations in data (flag, default TRUE)
- pathway
 a two column dataframe describing pathway. The column containing gene names should have the same name as col_gene (data.frame, optional)
- col_genes_pathway
 which column in pathway data.frame describes gene names (string, defaults to col_genes)
- show_all_samples
 show all samples in oncoplot, even if they don't have mutations in the selected genes. Samples only described in metadata but with no mutations at all are still filtered out by default, but you can show these too by setting
metadata_require_mutations = FALSE(flag, default FALSE)- total_samples
 Strategy for calculating the total number of samples. This value is used to compute the proportion of mutation recurrence displayed in the tooltip when hovering over the gene barplot, or as a text annotation when
ggoncoplot_options(show_genebar_labels = TRUE)is set to TRUE. Possible values:any_mutations: All the samples that are in
data(the mutation dataset), irrespective of whether they are on the oncoplot or not.oncoplot: Only the samples that are present on the oncoplot.
all: All the samples in either
dataormetadata.
- sample_order
 sample IDs in the order they should be shown on oncoplot (left to right). Overrides gene-based auto-ranking. (character vector).
- interactive
 should plot be interactive (boolean, default TRUE)
- options
 a list of additional visual parameters created by calling
ggoncoplot_options(). Seeggoncoplot_optionsfor details.- verbose
 verbose mode (flag, default TRUE)
Details
This function generates a customizable oncoplot that displays the most frequently mutated genes (default top 10) along with interactive tooltips and clickable elements.
Examples
# ===== GBM =====
gbm_csv <- system.file(
  package = "ggoncoplot",
  "testdata/GBM_tcgamutations_mc3_maf.csv.gz"
)
gbm_clinical_csv <- system.file(
  package = "ggoncoplot",
  "testdata/GBM_tcgamutations_mc3_clinical.csv"
)
gbm_df <- read.csv(file = gbm_csv, header = TRUE)
gbm_clinical_df <- read.csv(file = gbm_clinical_csv, header = TRUE)
# Plot Basic Oncoplot
ggoncoplot(
  gbm_df,
  "Hugo_Symbol",
  "Tumor_Sample_Barcode",
  col_mutation_type = "Variant_Classification",
  metadata = gbm_clinical_df,
  cols_to_plot_metadata = "gender"
)
#> ℹ 2 samples with metadata have no mutations. Fitering these out
#> ℹ To keep these samples, set `metadata_require_mutations = FALSE`. To view them in the oncoplot ensure you additionally set `show_all_samples = TRUE`
#> → TCGA-06-0165-01
#> → TCGA-06-0167-01
#> 
#> ── Identify Class ──
#> 
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid PAVE terms
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF palete
#> 
#> ── Plotting Sample Metadata ────────────────────────────────────────────────────
#> 
#> ── Sorting 
#> ℹ Sorting X axis by: Order of appearance
#> 
#> ── Generating Plot 
#> ℹ Found 1 plottable columns in data
# Customise how the Oncoplot looks
ggoncoplot(
  gbm_df,
  "Hugo_Symbol",
  "Tumor_Sample_Barcode",
  col_mutation_type = "Variant_Classification",
  metadata = gbm_clinical_df,
  cols_to_plot_metadata = "gender",
  # Customise Visual Options
  options = ggoncoplot_options(
    xlab_title = "Glioblastoma Samples",
    ylab_title = "Top 10 mutated genes"
  )
)
#> ℹ 2 samples with metadata have no mutations. Fitering these out
#> ℹ To keep these samples, set `metadata_require_mutations = FALSE`. To view them in the oncoplot ensure you additionally set `show_all_samples = TRUE`
#> → TCGA-06-0165-01
#> → TCGA-06-0167-01
#> 
#> ── Identify Class ──
#> 
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid PAVE terms
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF palete
#> 
#> ── Plotting Sample Metadata ────────────────────────────────────────────────────
#> 
#> ── Sorting 
#> ℹ Sorting X axis by: Order of appearance
#> 
#> ── Generating Plot 
#> ℹ Found 1 plottable columns in data
