Qc Plot Pdf Export
by smith6jt-cop
KINTSUGI quantification plots: Always save QC heatmaps and profiles as PDF
Skill Details
Repository Files
1 file in this skill directory
name: qc-plot-pdf-export description: "KINTSUGI quantification plots: Always save QC heatmaps and profiles as PDF" author: Claude Code date: 2026-01-15 triggers:
- quantification
- QC plots
- heatmaps
- summary plots
- PDF export
- plot_summary_heatmaps
- plot_zplane_profiles
QC Plot PDF Export Pattern
Experiment Overview
| Item | Details |
|---|---|
| Date | 2026-01-15 |
| Goal | Ensure all quantification plots are saved as PDFs for documentation |
| Environment | KINTSUGI notebooks/2_Cycle_Processing.ipynb |
| Status | Implemented |
Context
Quantification cells in the cycle processing notebook generate heatmaps and profile plots showing:
- SNR (Signal-to-Noise Ratio) by cycle/channel
- CV (Coefficient of Variation) for uniformity assessment
- Mean intensity distributions
- Z-plane profiles
These plots should be saved as PDFs to PROJECT_DIR/qc_plots/ for archival and reporting.
Implementation Pattern
QC Output Directory Setup
# QC output directory for PDF plots
QC_OUTPUT_DIR = PROJECT_DIR / 'qc_plots'
QC_OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
Summary Heatmap Function
def plot_summary_heatmaps(stats_df, stage_name="raw", save_pdf=True):
"""Create summary heatmaps: SNR and CV by cycle/channel.
Args:
stats_df: DataFrame with statistics
stage_name: Name for the processing stage (used in PDF filename)
save_pdf: Whether to save the plot as PDF (default: True)
"""
# ... create figure with 3 subplots ...
plt.suptitle(f'{stage_name.upper()} Summary Heatmaps', y=1.02, fontsize=14)
plt.tight_layout()
if save_pdf:
pdf_path = QC_OUTPUT_DIR / f'{stage_name}_summary_heatmaps.pdf'
fig.savefig(pdf_path, format='pdf', bbox_inches='tight', dpi=150)
print(f" Saved: {pdf_path}")
plt.show()
return fig
Z-Plane Profile Function
def plot_zplane_profiles(stats_df, cycle, channel, stage_name="raw", save_pdf=True):
"""Plot statistics across all z-planes for one cycle/channel.
Args:
stats_df: DataFrame with statistics
cycle: Cycle number
channel: Channel number
stage_name: Name for the processing stage (used in PDF filename)
save_pdf: Whether to save the plot as PDF (default: True)
"""
# ... create figure with 4 subplots ...
plt.tight_layout()
if save_pdf:
pdf_path = QC_OUTPUT_DIR / f'{stage_name}_zprofile_cyc{cycle:02d}_ch{channel}.pdf'
fig.savefig(pdf_path, format='pdf', bbox_inches='tight', dpi=150)
plt.show()
return fig
Usage in Quantification Cells
# Summary heatmaps (always save)
plot_summary_heatmaps(raw_stats_df, stage_name="raw")
plot_summary_heatmaps(stitched_stats_df, stage_name="stitched")
plot_summary_heatmaps(decon_stats_df, stage_name="deconvolved")
# Z-plane profiles (save first cycle only to avoid too many files)
for cycle in range(start_cycle, end_cycle + 1):
for channel in range(start_channel, end_channel + 1):
save_pdf = (cycle == start_cycle) # Only first cycle
plot_zplane_profiles(stats_df, cycle, channel, stage_name="raw", save_pdf=save_pdf)
Output Files
| File Pattern | Description |
|---|---|
{stage}_summary_heatmaps.pdf |
3-panel heatmap (SNR, CV, Intensity) |
{stage}_zprofile_cyc{NN}_ch{N}.pdf |
4-panel z-profile (Intensity, SNR, CV, StdDev) |
Where {stage} is one of: raw, stitched, deconvolved, edf
Key Insights
- Always include
stage_nameparameter to differentiate processing stages - Use
bbox_inches='tight'to prevent label clipping - DPI of 150 provides good balance of quality and file size
- Return the figure object for programmatic use if needed
- Limit z-profile PDFs to first cycle to avoid excessive file count
Related Skills
gpu-parallel-scheduling- Statistics collection uses GPU parallelismnotebook-module-refactoring- Function extraction patternrepo-project-sync-workflow- Edit main repo first
References
- KINTSUGI
notebooks/2_Cycle_Processing.ipynb- Quantification cells - KINTSUGI
docs/workflows.md- Workflow 2 documentation
Related Skills
Attack Tree Construction
Build comprehensive attack trees to visualize threat paths. Use when mapping attack scenarios, identifying defense gaps, or communicating security risks to stakeholders.
Grafana Dashboards
Create and manage production Grafana dashboards for real-time visualization of system and application metrics. Use when building monitoring dashboards, visualizing metrics, or creating operational observability interfaces.
Matplotlib
Foundational plotting library. Create line plots, scatter, bar, histograms, heatmaps, 3D, subplots, export PNG/PDF/SVG, for scientific visualization and publication figures.
Scientific Visualization
Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.
Seaborn
Statistical visualization. Scatter, box, violin, heatmaps, pair plots, regression, correlation matrices, KDE, faceted plots, for exploratory analysis and publication figures.
Shap
Model interpretability and explainability using SHAP (SHapley Additive exPlanations). Use this skill when explaining machine learning model predictions, computing feature importance, generating SHAP plots (waterfall, beeswarm, bar, scatter, force, heatmap), debugging models, analyzing model bias or fairness, comparing models, or implementing explainable AI. Works with tree-based models (XGBoost, LightGBM, Random Forest), deep learning (TensorFlow, PyTorch), linear models, and any black-box model
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Query Writing
For writing and executing SQL queries - from simple single-table queries to complex multi-table JOINs and aggregations
Pydeseq2
Differential gene expression analysis (Python DESeq2). Identify DE genes from bulk RNA-seq counts, Wald tests, FDR correction, volcano/MA plots, for RNA-seq analysis.
Scientific Visualization
Meta-skill for publication-ready figures. Use when creating journal submission figures requiring multi-panel layouts, significance annotations, error bars, colorblind-safe palettes, and specific journal formatting (Nature, Science, Cell). Orchestrates matplotlib/seaborn/plotly with publication styles. For quick exploration use seaborn or plotly directly.
