This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Create a picture from a Bam file at specific position

I would like to make a picture of a bam file aligned at a specific region. Something similar than samtools tview but as a picture not as a text output :

enter image description here

Do you know any tools for doing this ?

bam alignment picture

Automated or interactive? Most genome browsers (IGV etc) will export images in various formats.

2 answers

ImageMagick is always the answer to anything image-automation related :)

samtools tview your.bam -p chr1:5477604 -d text | convert -background black -fill white label:@- out.png

if you don't have 'convert' then just install ImageMagick.On OSX that's brew install imagemagick

IGV can be driven by a batch script, and therefore command line. It's a little bit of work to get the script written where you need it, but then you get very nice diagrams how you like them. Should be doable in Bash.

Their scripting interface looks like a series of commands, open this bam, sort the reads that way, go to this location, then take a "screenshot". It can all happen behind the scenes, and result in just the picture you are looking for.

http://software.broadinstitute.org/software/igv/batch

I think this is probably a better solution in the long-run :)

Log in to answer this question.