| name | bio-data-visualization-genome-browser-tracks |
| description | Generate genome browser visualizations using pyGenomeTracks or IGV batch scripting for publication figures. Use when creating publication figures of genomic regions with multiple data tracks. |
| tool_type | mixed |
| primary_tool | pyGenomeTracks |
Genome Browser Tracks
pyGenomeTracks INI Configuration
[x-axis]
where = top
[bigwig_coverage]
file = sample.bw
title = Coverage
height = 3
color =
min_value = 0
max_value = auto
[spacer]
height = 0.5
[peaks]
file = peaks.bed
title = Peaks
color =
height = 1
display = collapsed
[genes]
file = genes.gtf
title = Genes
height = 5
fontsize = 10
style = UCSC
color = navy
pyGenomeTracks Command
pyGenomeTracks --tracks tracks.ini --region chr1:1000000-2000000 \
--outFileName region.png --dpi 300
for region in chr1:1000000-2000000 chr2:5000000-6000000; do
pyGenomeTracks --tracks tracks.ini --region $region \
--outFileName "${region//:/_}.png" --dpi 300
done
pyGenomeTracks Python API
import pygenometracks.tracks as pygtk
from pygenometracks import plotTracks
tracks = '''
[x-axis]
where = top
[bigwig]
file = coverage.bw
title = ChIP-seq
height = 4
color = #4DBBD5
[bed]
file = peaks.narrowPeak
title = Peaks
height = 1
color = #E64B35
'''
with open('tracks.ini', 'w') as f:
f.write(tracks)
import subprocess
subprocess.run([
'pyGenomeTracks',
'--tracks', 'tracks.ini',
'--region', 'chr1:1000000-2000000',
'--outFileName', 'output.png',
'--dpi', '300'
])
Track Types
bigWig Coverage
[bigwig]
file = signal.bw
title = Coverage
height = 4
color =
min_value = 0
max_value = auto
number_of_bins = 700
nans_to_zeros = true
summary_method = mean
BED/narrowPeak
[bed]
file = peaks.narrowPeak
title = Peaks
height = 2
color =
display = collapsed
labels = false
[bed_links]
file = interactions.bedpe
title = Loops
height = 3
file_type = links
links_type = arcs
color = purple
line_width = 1
Gene Annotations
[genes]
file = genes.gtf
title = Genes
height = 6
fontsize = 10
style = UCSC
prefered_name = gene_name
merge_transcripts = false
color = navy
border_color = black
[genes_bed12]
file = genes.bed12
title = Transcripts
height = 5
fontsize = 8
color = darkblue
Hi-C Matrix
[hic_matrix]
file = matrix.cool
title = Hi-C
height = 10
depth = 1000000
min_value = 0
max_value = 100
transform = log1p
colormap = RdYlBu_r
show_masked_bins = false
IGV Batch Scripting
cat > igv_batch.txt << 'EOF'
new
genome hg38
load sample1.bam
load peaks.bed
snapshotDirectory ./snapshots
goto chr1:1000000-2000000
snapshot region1.png
goto chr2:5000000-6000000
snapshot region2.png
exit
EOF
igv -b igv_batch.txt
IGV Batch Commands
new
genome hg38
load file.bam
snapshotDirectory ./out
goto chr1:1000000-2000000
sort base
collapse
expand
squish
maxPanelHeight 500
snapshot file.png
exit
Gviz (R)
library(Gviz)
library(GenomicRanges)
axTrack <- GenomeAxisTrack()
library(TxDb.Hsapiens.UCSC.hg38.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene
grTrack <- GeneRegionTrack(txdb, chromosome = 'chr1', name = 'Genes')
dTrack <- DataTrack(range = 'coverage.bw', type = 'h',
chromosome = 'chr1', name = 'Coverage',
col = '#4DBBD5')
aTrack <- AnnotationTrack(range = 'peaks.bed', name = 'Peaks',
chromosome = 'chr1', fill
plotTracksaxTrack dTrack aTrack grTrack
from to
chromosome
pdf width height
plotTracksaxTrack dTrack aTrack grTrack
from to
dev.off
Multi-Sample Comparison
[x-axis]
[sample1_bw]
file = sample1.bw
title = Sample 1
height = 3
color =
min_value = 0
max_value = 100
[sample2_bw]
file = sample2.bw
title = Sample 2
height = 3
color =
min_value = 0
max_value = 100
overlay_previous = share-y
[spacer]
height = 0.3
[sample1_peaks]
file = sample1_peaks.bed
title = S1 Peaks
height = 1
color =
[sample2_peaks]
file = sample2_peaks.bed
title = S2 Peaks
height = 1
color =
Publication Export
pyGenomeTracks --tracks tracks.ini --region chr1:1-1000000 \
--outFileName figure.png --dpi 300 --width 40
pyGenomeTracks --tracks tracks.ini --region chr1:1-1000000 \
--outFileName figure.pdf --width 40
pyGenomeTracks --tracks tracks.ini --region chr1:1-1000000 \
--outFileName figure.svg --width 40
Related Skills
- alignment-files/bam-statistics - Input BAM processing
- chip-seq/peak-calling - Peak files for tracks
- hi-c-analysis/matrix-operations - Hi-C visualization
- data-visualization/multipanel-figures - Combining track figures