Question: How can I Get png figures of UCSC genome browser automatically?
1
gravatar for tiago211287
2.6 years ago by
tiago2112871.0k
USA
tiago2112871.0k wrote:

I wanna to see the expression profile in the ucsc genome browser of several genes. I was thinking if someone know some way or script that can retrieve the png images automatically from the genome browser.

ADD COMMENTlink modified 2.5 years ago • written 2.6 years ago by tiago2112871.0k
12
gravatar for Alex Reynolds
2.6 years ago by
Alex Reynolds25k
Seattle, WA USA
Alex Reynolds25k wrote:

I posted a Python-based tool on Github called soda.py that creates a web-ready gallery of UCSC browser shots. You just give it your BED file of coordinates, build, and session ID, and you specify an output directory where PDF and PNG results get stored (as well as an index.html file that lets you browse through snapshots with a web browser).

If you want to do things by hand, you can do something like the following quick and dirty approach to get a nice PNG. You'll need ImageMagick convert installed in order to convert the PDF to PNG. You'll also need GNU wget to do web requests on the command line.

$!/bin/bash

chrom="chr1"
chromStart=1234567
chromEnd=1234987
sessionID=1234
genomeBrowserURL="genome.ucsc.edu"
dumpURL="http://${genomeBrowserURL}/cgi-bin/cartDump"
postData="hgsid=${sessionID}&hgt.psOutput=on&cartDump.varName=position&cartDump.newValue=${chrom}%3A${chromStart}-${chromEnd}&submit=submit"
wgetOpts="--no-directories --recursive --convert-links -l 1 -A hgt_*.pdf"
wgetWaitOpts="--wait=1 --random-wait --tries=2 --timeout=100"
wget ${wgetWaitOpts} --post-data "${postData}" "${dumpURL}"
wget ${wgetOpts} ${wgetWaitOpts} "$url&position=${chrom}%3A${chromStart}-${chromEnd}" 2> fetch.log
mv hgt_*.pdf ${sessionID}.pdf
convert -density 300 ${sessionID}.pdf -background white -flatten ${sessionID}.png

You'd fill out chrom, chromStart, chromEnd and sessionID. Or use placeholders $1 etc. and pass them in on the command line.

If you have a few regions to look at, this would just be a matter of modifying this approach to loop over their respective chromosome name and interval values, and naming the output files appropriately. (Or you can use soda.py for automation.)

ADD COMMENTlink modified 2.1 years ago • written 2.6 years ago by Alex Reynolds25k
2
gravatar for tiago211287
2.5 years ago by
tiago2112871.0k
USA
tiago2112871.0k wrote:

Well, I started to make a bash script but, was not necessary. Since a guy named Giovanni Marco Dall'Olio already made a python script that works very very well for doing this.

here is the website of the script: https://bitbucket.org/dalloliogm/ucsc-fetch/overview

and the biostarts link where I find it: How To Dynamically Embed The Ucsc Browser Image Of A Specific Gene On A Web

the blog : http://bioinfoblog.it/2011/12/a-script-to-fetch-images-from-the-ucsc-browser/

ADD COMMENTlink written 2.5 years ago by tiago2112871.0k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 747 users visited in the last hour