This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Create Image From Mapping Region

I am looking for a way to generate an image for a set of mapping positions in a bam file.

Instead of browsing to each position by providing the coordinates in a tool like samtools tview, which is pretty cumbersome, I could then provide a list of such coordinates after which for each of them an image would be created.

Then I could browse these images to get a first impression of how the mapping looks like.

Does anyone know of a tool that could do something like that?

Thanks

samtools

4 answers

I wrote something like this for IGV: http://plindenbaum.blogspot.fr/2011/07/controlling-igv-through-port-my.html

and I also wrote a tool that takes a VCF input and a bam: see http://code.google.com/p/variationtoolkit/wiki/VcfTTView

$ echo -e "ref\t3\nref2\t2" |\
  vcfttview -x 3 -B toy.bam -R toy.fa

>ref:3

1         11              21        31         41        51        61           
AGCATGTTAGATAA****GATA**GCTGTGCTAGTAGGCAG*TCAGCGCCATNNNNNNNNNNNNNNNNNNNNNNNNNNNN
      ........    ....  ......K.K......K. ..........                            
      ........AGAG....***...      ,,,,,    ,,,,,,,,,                            
        ......GG**....AA                                                        
        ..C...**** ...**...>>>>>>>>>>>>>>T.....                                 



>ref2:2

1         11            21        31        41        51        61              
aggttttataaaac****aattaagtctacagagcaactacgcgNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
.............Y    ..W...................                                        
..............****..A...                                                        
 .............****..A...T.                                                      
     .........AAAT.............                                                 
         C...T****....................                                          
           ..T****.....................                                         
             T****......................

You can use IGV and talk to IGV via its port mechanism. If you are an R user, the SRAdb package has convenience functions to work with IGV to produce plots.

I've found that the best way to achieve what you want is using IGV batch script.

You can quickly generate a batch script as follows:

> echo "snapshotDirectory <some directory to put the images>" > igv_batch_script.txt
> cat file.bed | perl -lane 'print "goto $F[0]:$F[1]-$F[2]\nsnapshot";' >>  igv_batch_script.txt

Then you just load this file in IGV: "File" -> "Run Batch Script..."

For further info look at: http://www.broadinstitute.org/igv/batch

If you are familiar with the UCSC browser, you could load your reads into a custom track, add annotation tracks (if desired) and use UCSC Fetch to generate screenshots around regions-of-interest.

You could then use something like SimpleViewer to make a quickly-browsable gallery.

Log in to answer this question.