Oncoplot Example¶
This notebook demonstrates the oncoplot() visualization, which displays somatic mutation patterns across genes and samples. The plot combines a mutation matrix with TMB per sample and gene alteration frequency panels.
For detailed documentation, see the Oncoplot API Reference.
Load Data¶
Load the MAF file and create a PyMutation object. The example uses the TCGA-LAML dataset.
In [1]:
Copied!
from pyMut.input import read_maf
maf_path = "../../../src/pyMut/data/examples/MAF/tcga_laml.maf.gz"
print(f'📂 Loading file: {maf_path}')
# Read the MAF file and create the PyMutation object
py_mutation = read_maf(maf_path,assembly="37")
from pyMut.input import read_maf
maf_path = "../../../src/pyMut/data/examples/MAF/tcga_laml.maf.gz"
print(f'📂 Loading file: {maf_path}')
# Read the MAF file and create the PyMutation object
py_mutation = read_maf(maf_path,assembly="37")
2025-11-16 19:02:04,143 | INFO | pyMut.input | Starting MAF reading: ../../../src/pyMut/data/examples/MAF/tcga_laml.maf.gz 2025-11-16 19:02:04,143 | INFO | pyMut.input | Loading from cache: ../../../src/pyMut/data/examples/MAF/.pymut_cache/tcga_laml.maf_0c3d83642d761cde.parquet 2025-11-16 19:02:04,172 | INFO | pyMut.input | Cache loaded successfully in 0.03 seconds
📂 Loading file: ../../../src/pyMut/data/examples/MAF/tcga_laml.maf.gz
Configure Plot Settings¶
Enable high-quality rendering settings for publication-ready figures.
In [2]:
Copied!
py_mutation.configure_high_quality_plots()
py_mutation.configure_high_quality_plots()
Generate Oncoplot¶
The oncoplot() function creates a comprehensive visualization with four panels:
- Center panel: Mutation matrix showing gene-sample mutation status
- Top panel: Tumor Mutation Burden (TMB) per sample
- Right panel: Gene alteration frequency with percentage labels
- Bottom panel: Variant classification legend
Parameters:
figsize: Figure size as (width, height) in inches. Default:(16, 10)title: Plot title. Default:"Oncoplot"gene_column: Column name for gene symbols. Default:"Hugo_Symbol"variant_column: Column name for variant classifications. Default:"Variant_Classification"ref_column: Column name for reference alleles. Default:"REF"alt_column: Column name for alternative alleles. Default:"ALT"top_genes_count: Number of top mutated genes to display. Default:10max_samples: Maximum number of samples to display. Default:180
In [3]:
Copied!
py_mutation.oncoplot()
py_mutation.oncoplot()
Oncoplot generated: 10 genes × 193 samples (5.07s)
Out[3]: