This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Quick Visual Inspection Of Mapping Images For A List Of Regions

Hi,

I would like to quickly have a look to a few hundred images of reads mapped to a reference, for a list of a few hundred regions.

What I've got so far is a file with a list of regions "chrname:start-end", and I am simply using samtools tview for them like this:

cat peaks.txt | while read i; do echo -e "g$i\n." | samtools tview my.bam my.ref.fa.gz; done

The "." at the end is to switch of the dots in the tview configuration. I use Ctrl+C to go to the next region.

Is there a better way to do this? Maybe something that generates image files?

Cheers

visualization mapping

4 answers

Take a look at the IGV browser. In particular, it has some nice scripting functionality:

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

and

http://www.broadinstitute.org/software/igv/PortCommands

bedtools has a script called bedToIgv that will create an IGV batch script for generating images for each interval in a BED/GFF/VCF file.

Since you already have BAM files, you can use Bio::DB::Sam with GBrowse and gbrowse_img to generate images. It could easily be scripted using wget or curl and shell scripting and gbrowse_img will return graphics like GBrowse would use. Alternatively, you could skip the webserver and do the image generation with Bio::Graphics and perl. For more information, you can take a look at:

GBrowse2 Install Doc

Bio::DB::Sam

Bio::Graphics

BioPerl

same answer as for other thread

most genome browsers have scripting capability IGB and IGV.[?] GBrowse2 also allows linking and by this scripting.

If you want something really small:[?]

  1. download the two files from lookseq lookseq
  2. and compile them: g++ render_image.cpp -O3 -o render_image -lpng -L . -lbam
  3. create image with: ./render_image --bam=mybam.bam --options=snps,pairs,arrows,single,faceaway,inversions,linkpairs,colordepth --ref=myref.fa --region="2L:1-200000" --png=2L.a.png

This way you can quickly create small images with the reads from your bam file with many viewing options. like this example (click on one button on the right).

IIRC now I copied the lookseq files into the folder of the samtools and compile there for correct linkage with libbam YMMV.

For different level of zoomed-out views as bitmaps, Lookseq's render_image is great. In combination with ImageMagick's montage tool, it does pretty much all I want:

montage -tile 1 -geometry +0+0 $i/*.png $i.png

For nucleotide-level textual views, I've just been made aware about Pierre's bamttview, which is a modification of samtools tview:

http://plindenbaum.blogspot.com/2011/07/text-alignment-viewer-using-samtools.html

many thanks to the LookSeq people and @Pierre Lindenbaum for both solutions.

Log in to answer this question.