The bb_oncoplot() function creates publication-ready
onco plots (waterfall plots) showing the mutation landscape across
samples. It is built entirely with ggplot2 and returns a modifiable
ggplot object.
bb_oncoplot() accepts two input formats:
A data.frame with columns sample, gene, and
mutation_type:
# Load bundled example mutation data
ex <- bb_example_mutations()
mut_data <- ex$mutations
clinical_data <- ex$clinical
head(mut_data)
#> sample gene mutation_type
#> 1 TCGA-021 NRAS In_Frame_Ins
#> 2 TCGA-037 PIK3CA Missense_Mutation
#> 3 TCGA-037 BRAF Splice_Site
#> 4 TCGA-031 PIK3CA Frame_Shift_Ins
#> 5 TCGA-042 RB1 Missense_Mutation
#> 6 TCGA-008 NRAS Missense_MutationA data.frame with MAF-style columns: Hugo_Symbol,
Tumor_Sample_Barcode,
Variant_Classification.
Pass a named character vector to mutation_colors:
my_colors <- c(
"Missense_Mutation" = "#3182BD",
"Nonsense_Mutation" = "#E6550D",
"Frame_Shift_Del" = "#31A354",
"Frame_Shift_Ins" = "#756BB1",
"Splice_Site" = "#DE2D26",
"In_Frame_Del" = "#636363",
"Multi_Hit" = "#FDAE6B",
"Other" = "#BDBDBD"
)
bb_oncoplot(mut_data, n_genes = 10, mutation_colors = my_colors)Provide a data.frame with sample annotations:
# Use the bundled clinical annotations
bb_oncoplot(mut_data, n_genes = 8, annotation_df = clinical_data)Sort samples by mutation frequency (default) or by co-occurrence clustering: