Lollipop Plot Example¶
This notebook demonstrates the lollipop_plot() function, which visualizes somatic mutations mapped onto a protein structure, revealing mutation hotspots and their relationship to functional domains.
For detailed documentation, see the Lollipop Plot API Reference.
Load Data¶
Load the MAF file and create a PyMutation object. Using consolidate_variants=False preserves all original mutation events for accurate counting.
from pyMut.input import read_maf
maf_path = "../../../src/pyMut/data/examples/MAF/tcga_laml.maf.gz"
print(f'📂 Loading file: {maf_path}')
py_mutation = read_maf(maf_path, assembly="37", consolidate_variants=False)
2025-11-13 00:05:18,592 | INFO | pyMut.input | Starting MAF reading: ../../../src/pyMut/data/examples/MAF/tcga_laml.maf.gz 2025-11-13 00:05:18,593 | INFO | pyMut.input | Loading from cache: ../../../src/pyMut/data/examples/MAF/.pymut_cache/tcga_laml.maf_bec334f3b1d679b0.parquet 2025-11-13 00:05:18,593 | INFO | pyMut.input | Loading from cache: ../../../src/pyMut/data/examples/MAF/.pymut_cache/tcga_laml.maf_bec334f3b1d679b0.parquet 2025-11-13 00:05:18,619 | INFO | pyMut.input | Cache loaded successfully in 0.03 seconds 2025-11-13 00:05:18,619 | 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.
py_mutation.configure_high_quality_plots()
Lollipop Plot - DNMT3A¶
DNMT3A is one of the most frequently mutated genes in acute myeloid leukemia (AML). This example uses a specific transcript ID for reproducibility.
Parameters:
gene: Gene symbol to visualize (required)aa_col: Column containing protein change annotation. Default:"HGVSp_Short"transcript_id: Specific transcript ID for isoform selection. Default:Nonelabel_top_n: Number of top mutated positions to label. Default:20count_by: Count mode ("mutations"or"samples"). Default:"mutations"show_lollipops: Show mutation lollipops. Default:Truefigsize: Figure size. Default:(16, 6)
py_mutation.lollipop_plot(
gene='DNMT3A',
aa_col='Protein_Change',
transcript_id='NM_022552',
label_top_n=1,
)
2025-11-13 00:05:39,793 | INFO | pyMut.visualizations.lollipop_plot | Lollipop plot for DNMT3A created in 0.48s (54 mutations, 26 AA changes)
Show Only Protein Domains¶
Setting show_lollipops=False displays only the protein backbone with PFAM domain annotations, without mutation markers.
py_mutation.lollipop_plot(
gene='DNMT3A',
aa_col='Protein_Change',
transcript_id='NM_022552',
label_top_n=1,
show_lollipops=False
)
2025-11-13 00:07:56,535 | INFO | pyMut.visualizations.lollipop_plot | Protein domain plot for DNMT3A created in 0.44s
Lollipop Plot - TP53¶
TP53 is a tumor suppressor gene frequently mutated across many cancer types. This example demonstrates the same visualization approach with a different gene.
py_mutation.lollipop_plot(
gene='TP53',
aa_col='Protein_Change',
transcript_id='NM_000546',
label_top_n=1,
)
2025-11-13 00:05:45,161 | INFO | pyMut.visualizations.lollipop_plot | Lollipop plot for TP53 created in 0.54s (19 mutations, 17 AA changes)