Loading...
Loading...
This skill should be used when the user needs to visualize BAM alignment files in IGV (Integrative Genomics Viewer). Triggers include requests to generate IGV screenshots, visualize genomic regions with multiple BAM tracks, or create batch visualizations for WGS analysis results.
npx skill4agent add dakesan/cc-dnawork-plugin bio-igv# macOS
brew install --cask igv
# Linux
wget https://data.broadinstitute.org/igv/projects/downloads/2.16/IGV_Linux_2.16.0_withJava.zip
unzip IGV_Linux_2.16.0_withJava.zip
# Windows
# Download from https://software.broadinstitute.org/software/igv/downloaduv pip install typer# Single region with multiple BAM files
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample1.bam sample2.bam sample3.bam \
--region chr1:1000-2000 \
--output-dir ./igv_snapshots
# Multiple regions from BED file
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample1.bam sample2.bam \
--bed regions.bed \
--output-dir ./igv_snapshots--genome TEXThg38hg19mm39--bam PATH--region TEXT--bed PATHchr1:1000-2000--output-dir PATH--igv-path TEXT--max-panel-height INT--java-heap TEXT2g--save-batch-scriptchr1_1000-2000.pngregion_name.png--save-batch-scriptigv_batch_script.txt# Visualize single region with 3 BAM files
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam control.bam treatment1.bam treatment2.bam \
--region chr1:1000-2000 \
--output-dir ./snapshots
# Visualize multiple regions from BED file
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam alignment.bam \
--bed regions_of_interest.bed \
--output-dir ./snapshots
# Custom IGV settings with larger panel height
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample.bam \
--region chr1:1000-2000 \
--output-dir ./snapshots \
--max-panel-height 800 \
--java-heap 4g
# Save batch script for debugging
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample.bam \
--region chr1:1000-2000 \
--output-dir ./snapshots \
--save-batch-script# Step 1: Extract BLAT hit regions to BED file
# (Assuming you have BLAT results in PSL or JSON format)
echo -e "chr1\t1000\t2000\tinsert1" > blat_hits.bed
echo -e "chr2\t5000\t6000\tinsert2" >> blat_hits.bed
# Step 2: Generate IGV snapshots
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam alignment.bam \
--bed blat_hits.bed \
--output-dir ./blat_visualizations# Generate snapshots with all samples loaded
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample1.bam sample2.bam sample3.bam \
--bed candidate_regions.bed \
--output-dir ./multi_sample_comparison# Step 1: Extract variant positions to BED
# (From VCF file using vcf-toolkit or bcftools)
bcftools query -f '%CHROM\t%POS0\t%END\t%ID\n' variants.vcf > variant_sites.bed
# Step 2: Visualize with flanking regions
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam alignment.bam \
--bed variant_sites.bed \
--output-dir ./variant_validation \
--max-panel-height 600new
genome hg38
load /path/to/sample1.bam
load /path/to/sample2.bam
snapshotDirectory /path/to/output
maxPanelHeight 500
goto chr1:1000-2000
snapshot chr1_1000-2000.png
goto chr2:5000-6000
snapshot chr2_5000-6000.png
exit$ python scripts/generate_igv_snapshots.py --genome hg38 --bam sample.bam --region chr1:1000-2000 --output-dir ./out
Error: IGV not found. Please install IGV or specify path with --igv-path.
Install: brew install --cask igv (macOS) or download from https://software.broadinstitute.org/software/igv/download# Install IGV
brew install --cask igv
# Or specify custom path
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample.bam \
--region chr1:1000-2000 \
--output-dir ./out \
--igv-path /path/to/igv.sh$ python scripts/generate_igv_snapshots.py --genome hg38 --bam sample.bam --region 1000-2000 --output-dir ./out
Error: Invalid region format: 1000-2000. Expected format: chr1:1000-2000chr:start-endpython scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample.bam \
--region chr1:1000-2000 \
--output-dir ./out$ python scripts/generate_igv_snapshots.py --genome hg38 --bam sample.bam --region chr1:1000-2000 --output-dir ./out
Snapshots generated successfully in: ./out
Total regions processed: 1
Warning: No snapshots found. Check IGV output for errors.samtools index--save-batch-script# Check BAM file is indexed
samtools index sample.bam
# Save batch script to debug IGV execution
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample.bam \
--region chr1:1000-2000 \
--output-dir ./out \
--save-batch-script
# Manually run batch script to see errors
igv.sh -b ./out/igv_batch_script.txt# ✅ Good: Index BAM files first
samtools index sample1.bam
samtools index sample2.bam
# Then generate snapshots
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample1.bam sample2.bam \
--region chr1:1000-2000 \
--output-dir ./snapshots# ✅ Good: Single call with BED file
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample.bam \
--bed regions.bed \
--output-dir ./snapshots
# ❌ Bad: Multiple script calls
python scripts/generate_igv_snapshots.py --bam sample.bam --region chr1:1000-2000 --output-dir ./out
python scripts/generate_igv_snapshots.py --bam sample.bam --region chr2:5000-6000 --output-dir ./out
# ... (inefficient, IGV starts/stops repeatedly)# ✅ Good: Larger panel for 5 BAM files
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam s1.bam s2.bam s3.bam s4.bam s5.bam \
--region chr1:1000-2000 \
--output-dir ./snapshots \
--max-panel-height 800# Check BAM header for reference genome
samtools view -H alignment.bam | grep @SQ
# Use matching genome assembly
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam alignment.bam \
--region chr1:1000-2000 \
--output-dir ./snapshots| Task | igv-integration | Manual IGV |
|---|---|---|
| Visualize many regions (>10) | ✅ generate_igv_snapshots.py | ❌ Too tedious |
| Generate publication figures | ✅ Reproducible batch mode | ✅ Fine-tuned manual control |
| Compare multiple samples | ✅ Load all BAMs at once | ✅ Interactive comparison |
| Validate variant calls | ✅ Automate with BED file | ✅ Interactive inspection |
| Explore data interactively | ❌ Use manual IGV | ✅ Full GUI control |
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam large_file.bam \
--region chr1:1000-2000 \
--output-dir ./out \
--java-heap 4g# Check chromosome names in BAM
samtools idxstats sample.bam | cut -f1
# Use correct chromosome name
# If BAM uses "1" instead of "chr1":
python scripts/generate_igv_snapshots.py \
--genome hg38 \
--bam sample.bam \
--region 1:1000-2000 \
--output-dir ./out# ✅ Good: Valid BED format
chr1 1000 2000
chr2 5000 6000 region_name
# ❌ Bad: Missing columns
chr1:1000-2000