Skip to content

Latest commit

 

History

History
102 lines (88 loc) · 3.77 KB

File metadata and controls

102 lines (88 loc) · 3.77 KB

IGV-Batch-Script-Generator-for-bed-files

This script generates IGV batch scripts from bed files. The script can be loaded into IGV for automatic generation of images on the command line. More information on IGV batch files is located here: https://software.broadinstitute.org/software/igv/batch.

Usage

usage: IGV_snapshot_batch_generator_from_bed.py [-h] -i INPUT BED
                                                [-o OUTPUT IGV BATCH SCRIPT]
                                                -b BAM DIRECTORY -s SNAPSHOT
                                                DIRECTORY [-bp BP BUFFER]
                                                [-p PED FILE]

optional arguments:
  -h, --help            show this help message and exit
  -o OUTPUT IGV BATCH SCRIPT, --out OUTPUT IGV BATCH SCRIPT
                        output IGV batch script. Will default to stdout
  -bp BP BUFFER, --buffer BP BUFFER
                        bp buffer around locus in IGV
  -p PED FILE, --ped PED FILE
                        name/path to PED file for trio pictures

required named arguments:
  -i INPUT BED, --in INPUT BED
                        name/path to BED to convert into IGV batch script
  -b BAM DIRECTORY, --bam_dir BAM DIRECTORY
                        path to bam directory
  -s SNAPSHOT DIRECTORY, --snapshot_dir SNAPSHOT DIRECTORY
                        path to final IGV snapshot directory

The script requires column 4 of the bed file to be the name of the bam file (see example.bed). It is best to pre-sort the bed file by the bam names, because IGV runs faster when it doesn't have to reload the bam for each image.

locations.bed:
chr1 1000000 1000001 sample1.bam
chr5 800000 800001 sample2.bam
chr5 800000 800001 sample1.bam

sort -k4,1 locations.bed > locations_sorted.bed

locations_sorted.bed:
chr1 1000000 1000001 sample1.bam
chr5 800000 800001 sample1.bam
chr5 800000 800001 sample2.bam

Example

Example using a 500bp buffer around the bed region (recommended for looking at 1bp region):

python IGV_snapshot_batch_generator_from_bed.py -i /path/to/locations_sorted.bed -b /path/to/bam_directory/ -s /path/to/snapshot_directory/ -bp 500 -o locations_IGV_batch.txt

snapshotDirectory /path/to/snapshot_directory/
new
load /file/to/bams/sample1.bam
goto chr1:999500-1000501
sort
collapse
snapshot chr1:999500-1000501_sample1.png
goto chr5:799500-800501
sort
collapse
snapshot chr5:799500-800501_sample1.png
new
load /file/to/bams/sample2.bam
goto chr5:799500-800501
sort
collapse
snapshot chr5:799500-800501_sample2.png

Trio option

The option -p takes in a ped file and generates an IGV image of a trio (child, dad, mom)

example.ped
pedigree1 sample1 sample1_father sample1_mother 1 0
pedigree2 sample2 sample2_father sample2_mother 2 0

python IGV_snapshot_batch_generator_from_bed.py -i /path/to/locations_sorted.bed -b /path/to/bam_directory/ -s /path/to/snapshot_directory/ -bp 500 -o locations_IGV_batch.txt -p /path/to/example.ped

snapshotDirectory /path/to/snapshot_directory/
new
load /vbod2/CEPH_BAMs/sample1.bam
load /vbod2/CEPH_BAMs/sample1_father.bam
load /vbod2/CEPH_BAMs/sample1_mother.bam
goto chr1:999500-1000501
sort
collapse
snapshot chr1:999500-1000501_sample1_trio.png
goto chr5:799500-800501
sort
collapse
snapshot chr5:799500-800501_sample1_trio.png
new
load /file/to/bams/sample2.bam
load /file/to/bams/sample2_father.bam
load /file/to/bams/sample2_mother.bam
goto chr5:799500-800501
sort
collapse
snapshot chr5:799500-800501_sample2_trio.png