Summary Plot Example¶
This notebook demonstrates the summary_plot() function and its individual panel components. The summary dashboard provides a compact, high-level overview of somatic variants in a cohort, answering key questions about the mutational landscape.
For detailed documentation, see the Summary Plot API Reference.
Load Data¶
Load the MAF file and create a PyMutation object. The example uses the TCGA-LAML dataset.
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-10 17:37:19,110 | INFO | pyMut.input | Starting MAF reading: ../../../src/pyMut/data/examples/MAF/tcga_laml.maf.gz 2025-11-10 17:37:19,111 | INFO | pyMut.input | Loading from cache: ../../../src/pyMut/data/examples/MAF/.pymut_cache/tcga_laml.maf_0c3d83642d761cde.parquet 2025-11-10 17:37:19,143 | 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()
Full Summary Dashboard¶
The summary_plot() function generates a six-panel dashboard combining sample-level, gene-level, and cohort-level views.
Parameters:
figsize: Figure size as (width, height) in inches. Default:(16, 12)title: Main title for the plot. Default:"Mutation Summary"max_samples: Maximum samples to display in the variants per sample panel. Default:200top_genes_count: Number of top genes to show. Default:10
py_mutation.summary_plot()
2025-11-10 17:37:19,159 | INFO | pyMut.core | Generating summary plot... 2025-11-10 17:37:20,989 | INFO | pyMut.core | Summary plot generated in 1.83 seconds
Individual Panel Components¶
Each panel from the summary dashboard is also available as a standalone function.
Variant Classification¶
Horizontal barplot showing the distribution of variant classifications (e.g., Missense_Mutation, Nonsense_Mutation). Bars are sorted by frequency and annotated with counts.
Parameters:
figsize: Figure size. Default:(10, 6)title: Plot title. Default:"Variant Classification"
py_mutation.variant_classification_plot()
2025-11-10 17:37:22,156 | INFO | pyMut.core | Generating variant classification plot... 2025-11-10 17:37:22,255 | INFO | pyMut.core | Variant classification plot generated in 0.10 seconds
Variant Type¶
Horizontal barplot summarizing structural variant types (SNP, INS, DEL). Bars are sorted by frequency and annotated with counts.
Parameters:
figsize: Figure size. Default:(10, 6)title: Plot title. Default:"Variant Type"
py_mutation.variant_type_plot()
2025-11-10 17:37:22,497 | INFO | pyMut.core | Generating variant type plot... 2025-11-10 17:37:22,537 | INFO | pyMut.core | Variant type plot generated in 0.04 seconds
SNV Class¶
Horizontal barplot showing single-nucleotide variant substitution classes (e.g., C>T, G>A). Displays the raw REF>ALT patterns without pyrimidine normalization.
Parameters:
figsize: Figure size. Default:(10, 6)title: Plot title. Default:"SNV Class"
py_mutation.snv_class_plot()
2025-11-10 17:37:22,705 | INFO | pyMut.core | Generating SNV class plot... 2025-11-10 17:37:22,761 | INFO | pyMut.core | SNV class plot generated in 0.06 seconds
Variants per Sample¶
Stacked barplot showing the number of variants per sample, sorted by total count. The red dashed line indicates the median variant count across all samples.
Parameters:
figsize: Figure size. Default:(12, 6)title: Plot title. Default:"Variants per Sample"max_samples: Maximum number of samples to display. Default:None(all samples)
py_mutation.variants_per_sample_plot()
2025-11-10 17:37:22,960 | INFO | pyMut.core | Generating variants per sample plot... 2025-11-10 17:37:24,213 | INFO | pyMut.core | Variants per sample plot generated in 1.25 seconds
Variant Classification Summary¶
Boxplots showing the distribution of per-sample variant counts for each classification type. Ordered by total count (most common first).
Parameters:
figsize: Figure size. Default:(10, 6)title: Plot title. Default:"Variant Classification Summary"
py_mutation.variant_classification_summary_plot()
2025-11-10 17:37:24,903 | INFO | pyMut.core | Generating variant classification summary plot... 2025-11-10 17:37:25,042 | INFO | pyMut.core | Variant classification summary plot generated in 0.14 seconds
Top Mutated Genes¶
Horizontal stacked barplot showing the most frequently mutated genes. Two counting modes are available:
Parameters:
figsize: Figure size. Default:(10, 6)title: Plot title. Default:"Top Mutated Genes"top_genes_count: Number of genes to display. Default:10mode: Counting mode. Options:"samples": Count distinct samples with at least one variant per gene (shows percentage)"variants": Count total variants per gene (default)
py_mutation.top_mutated_genes_plot(mode="samples")
2025-11-10 17:37:25,274 | INFO | pyMut.core | Generating top mutated genes plot (mode=samples, count=10)... 2025-11-10 17:39:32,446 | INFO | pyMut.core | Top mutated genes plot generated in 127.17 seconds
Using mode="variants" to count total mutations per gene:
py_mutation.top_mutated_genes_plot(mode="variants")
2025-11-10 17:39:32,675 | INFO | pyMut.core | Generating top mutated genes plot (mode=variants, count=10)... 2025-11-10 17:39:32,789 | INFO | pyMut.core | Top mutated genes plot generated in 0.11 seconds