Working with bx

advertisement
Configuring Python on Compile
Overview of steps:
• Get account: http://go.vcu.edu/compile
• Use pythonbrew to install correct version of Python
• Install numpy lib using pip
• Install bx-python using the easy installer
numpy must be installed before bx-python!
Installing pythonbrew
Install pythonbrew:
curl -kL http://xrl.us/pythonbrewinstall | bash
Add the following line to the end of your ~/.bashrc
[[ -s "$HOME/.pythonbrew/etc/bashrc" ]] && source "$HOME/.pythonbrew/etc/bashrc"
list versions of python available
pythonbrew list -k
install python version 2.7.3
pythonbrew install 2.7.3
switch the default version
pythonbrew switch 2.7.3
Installation can take awhile..
Installing numpy and bxpython
Confirm python version
python -V
Install numpy
pip install numpy
Install bx-python
(bitbucket.org/james_taylor/bx-python/wiki/Home)
easy_install https://bitbucket.org/james_taylor/bx-python/get/tip.tar.bz2
If easy_install fails, see bitbucket for manual instructions
Getting our Files
Original files for ENCODE and other projects are available
on their project sites. However, we’ve made a local mirror
of key files for your convenience for this class
http://mirror.vcu.edu/vcu/encode/
See also ENCODE at UCSC
A bx-python usage example
from bx.intervals.io import GenomicIntervalReader
from bx.bbi.bigwig_file import BigWigFile
import numpy as np
bw = BigWigFile(open('wgEncodeBroadHistoneNhaH3k04me2Sig.bigWig'))
mySummary = bw.query("chr1", 10000, 10500, 1)
myInterval = bw.get("chr1", 10000, 10500)
myArrayInterval = bw.get_as_array("chr1", 10000, 10500)
print mySummary
print myInterval
Documentation is sparse, but basic usage can usually be
inferred from the class defs present in the code
A bx-python usage example
figure()
plot(x, y, linewidth = 1.0, color = 'green, label = "your_trackname" )
la = legend()
xlabel('genome position')
ylabel('counts')
title('BigWig Data')
grid(True)
savefig("test.png")
show()
Bigwig data can be plotted with matplotlib…
Download