Working with bx

Configuring Python on Compile
Overview of steps:
• Get account:
• 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 | 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
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
See also ENCODE at UCSC
A bx-python usage example
from 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
plot(x, y, linewidth = 1.0, color = 'green, label = "your_trackname" )
la = legend()
xlabel('genome position')
title('BigWig Data')
Bigwig data can be plotted with matplotlib…

similar documents