mdhewei/bioinfor-claw/plot-heatmap
Claude Code and agent skill by mdhewei/bioinfor-claw
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install mdhewei/bioinfor-claw/plot-heatmapSKILL.md
plot-heatmap
name: plot-heatmap description: Generate publication-quality heatmaps from numeric matrices with hierarchical clustering, custom scaling, and flexible annotations. commands:
- name: generate-heatmap
description: Create a heatmap from a matrix file args:
- --input (required): Path to matrix file (TSV/CSV)
- --output (required): Output image path (PNG/SVG/PDF)
Overview
plot-heatmap is a bioinformatics tool for generating publication-ready heatmaps from numeric data matrices. It supports:
- Hierarchical clustering with multiple linkage methods and distance metrics
- Flexible scaling: z-score or min-max normalization across rows, columns, or both
- Advanced visualization: dendrograms, cell annotations, custom colormaps, and missing-value handling
- Input flexibility: TSV/CSV formats with automatic or manual row label detection
- Publication quality: high-DPI output (PNG/SVG/PDF) with full layout control
Ideal for genomics (gene expression heatmaps), proteomics, metabolomics, and any tabular numeric data requiring visual clustering and pattern discovery.
When to Use
Use When:
- Analyzing expression matrices (RNA-seq, microarray, qPCR)
- Visualizing correlation or distance matrices
- Exploring high-dimensional tabular data with clustering
- Creating publication-quality figures for scientific manuscripts
- Comparing sample groups across features (genes, proteins, metabolites)
- Need reproducible, script-based heatmap generation with version control
Do Not Use When:
- Data is non-numeric or contains many categorical features (use box plots, violin plots instead)
- Matrix has fewer than 3 rows or columns (use tables instead)
- You need interactive exploration (consider Plotly, Shiny, or JavaScript libraries)
- Data is not rectangular/tabular (use specialized network or 3D visualization tools)
- Real-time updates are required (this generates static images)
Input/Output Specification
Input Files
Matrix File (--input)
- Format: TSV (tab-separated) or CSV (comma-separated)
- Structure: Rows = features (genes, proteins, metabolites), Columns = samples
- Data Type: Numeric values (floats or integers)
- Missing Values: NaN, NA, empty cells (rendered with
--na-color) - Row Labels: First column (auto-detected) or specified via
--index-col - Example:
`` GeneID Sample1 Sample2 Sample3 Sample4 GENE001 12.5 18.3 9.2 14.1 GENE002 5.1 NA 6.3 7.8 GENE003 22.4 25.1 20.9 23.5 ``
Annotation Files (Optional)
- Column Annotation File (--col-annotation): TSV with sample names in first column, annotation groups in subsequent columns
`` Sample Condition Batch Sample1 Control Batch1 Sample2 Treatment Batch1 Sample3 Control Batch2 ``
- Row Annotation File (--row-annotation): Similar structure with feature names in first column
Output Files
Primary Output (--output)
- Format: PNG (default), SVG, or PDF
- Resolution: Configurable via
--dpi(default 300 dpi for publication quality) - Contents: Heatmap with optional dendrograms, annotations, colorbar, title
Optional Outputs
- --output-svg: Save additional SVG version (vector graphics, scalable)
- --output-matrix: Export processed (scaled and reordered) matrix as TSV for downstream analysis
Execution Examples
Example 1: Basic Usage (RNA-seq Expression)
- Plots top 100 rows by variance
- Row-wise z-score scaling
- Hierarchical clustering (Ward linkage, Euclidean distance)
- Auto-sized figure
Example 2: Large Expression Matrix with Variance Filtering
- Selects top 50 genes by variance instead of 100
- Custom figure dimensions
- Publication-quality 300 DPI output
Example 3: Correlation Matrix with Custom Coloring
- No scaling (raw correlation values)
- Diverging colormap centered at 0
- No clustering (preserve matrix order)
Example 4: Heatmap with Row and Column Dendrograms
- Both row-wise and column-wise min-max scaling
- Complete linkage clustering with correlation distance
- Cell values annotated with 2 decimal places
Example 5: With Sample Annotations and Filtered Features
- Filters features with variance < 0.5
- Selects specific sample subset
- Adds sample condition annotation
- Exports reordered and scaled matrix
Example 6: High-Resolution Multi-Panel Figure
- Fixed cell dimensions for reproducible sizing
- Ultra-high resolution (600 DPI)
- Visible grid for clarity
- Professional font choice
Parameter Decision Guide
| Goal | Key Parameters | Example | |
|---|---|---|---|
| Reduce dimensionality | --select-by-variance, --min-variance | --select-by-variance 50 --min-variance 0.1 | |
| Custom scaling | --scale (row/col/both), --scale-method (zscore/minmax) | --scale both --scale-method minmax | |
| No clustering | --no-cluster-rows --no-cluster-cols | Use for matrices where order is meaningful | |
| Custom distance metric | --distance-metric (euclidean/correlation/cosine) | --distance-metric correlation for gene co-expression | |
| Diverging colormap | --cmap (RdBu_r, RdYlBu, seismic, coolwarm), --center | --cmap RdBu_r --center 0 for z-scores | |
| Hide labels | --no-row-labels --no-col-labels | For large matrices (>100 rows) | |
| Add cell values | --show-values --value-fmt | --show-values --value-fmt ".2f" | |
| Control figure size | --fig-width, --fig-height OR --cell-width, --cell-height | --cell-width 0.2 --cell-height 0.25 | |
| Annotation bars | --col-annotation, --row-annotation | Paired TSV files with sample/feature metadata | |
| Publication quality | --dpi 300, --font-family Arial, --base-fontsize 10 | Default 300 DPI PNG + SVG backup | |
| Subset samples | --sample-cols | --sample-cols "WT1,WT2,WT3,Mutant1,Mutant2" | |
| Save processed data | --output-matrix | Export clustered/scaled matrix for downstream analysis |
Technical Details
Scaling Methods
Z-score Normalization (default)
- Centers each row (or column) by subtracting mean
- Divides by standard deviation
- Clips extreme values (default ±3 sigma) to prevent color saturation
- Suitable for comparing features with different absolute ranges
- Recommended for: gene expression, proteomics
Min-Max Scaling
- Scales values to [0, 1] range
- Formula:
(x - min) / (max - min) - Preserves relative differences within each row/column
- Recommended for: abundance data, abundance ratios
Clustering
- Method: Hierarchical agglomerative clustering via SciPy
- Linkage: Ward (default), complete, average, single
- Distance metrics: Euclidean (default), correlation, cosine
- Correlation distance: 1 - Pearson correlation coefficient
- Handling missing values: Forward-fill mean values before clustering
- Dendrogram: Optional colored dendrograms for row/column clusters (set
--row-cluster-cutoffor--col-cluster-cutoffto color by N clusters)
Colormaps
Common choices:
- Diverging (centered): RdBu_r, RdYlBu, coolwarm, seismic (good for z-scores)
- Sequential: viridis, plasma, YlOrRd, Blues (good for abundance)
- Qualitative: Set1, tab10 (for categorical data)
All matplotlib colormaps supported.
Missing Value Handling
- Cells with NaN/NA displayed as
--na-color(default lightgray) - Variance calculations skip NaN
- Clustering: NaN filled with row/column mean before distance computation
- Cell value annotation skips NaN cells
Common Workflows
1. RNA-seq Differential Expression Heatmap
2. Correlation Matrix Between Samples
3. Clustering-Focused Exploration
4. Reproducible Publication Figure
Troubleshooting
| Issue | Cause | Solution | |
|---|---|---|---|
| Labels overlap | Too many rows/columns | Use --no-row-labels, --row-label-size 6 | |
| Wrong row order detected | TSV has unnamed index column | Use --index-col GeneID (column name) | |
| Colors look washed out | vmin/vmax too wide | Set --vmin, --vmax explicitly | |
| Clustering disabled | scipy not installed | Install: pip install scipy>=1.8 | |
| All white heatmap | All NaN values | Check data format, try sample file first | |
| Memory error on large files | >50k rows | Use --select-by-variance 1000 to pre-filter |
Dependencies
- numpy >= 1.22: Numerical computing
- pandas >= 1.4: Data I/O and manipulation
- matplotlib >= 3.5: Plotting and rendering
- scipy >= 1.8: Hierarchical clustering (optional; skipped if unavailable)
Install all with: pip install -r requirements.txt
Version History
- v1.0 (2025): Initial release with full clustering, scaling, and annotation support
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingbioinformatics-plot-generator/plot-heatmap/SKILL.md
Popularity
- Repository stars
- 65
- Repository forks
- 12
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/mdhewei/bioinfor-claw/plot-heatmap)