Install Misopy
In [1]:
!pip install --user --quiet misopy
Restart the kernel (Kernel -> Restart), so that IPython finds Misopy
Get Samtools
In [1]:
from urllib import urlretrieve
urlretrieve("http://depot.galaxyproject.org/package/linux/x86_64/samtools/samtools-0.1.19-Linux-x86_64.tgz","samtools.tgz")
!tar -xf samtools.tgz
The samtools binary should now be in bin/samtools
Generate Indices of the bam Files
In [2]:
get(1)
get(2)
!mv 1 461177.bam
!mv 2 461178.bam
!bin/samtools index 461177.bam
!bin/samtools index 461178.bam
If everything went well there should now be index files (*.bai) next to the bam files.
In [3]:
!ls *.ba*
Generate Index of an Annotation File
An annotation file is needed.
In [4]:
get(3)
!mv 3 dm3.ensGene.gtf
A script for the conversion of gtf(gff2) to gff3 is needed
In [5]:
urlretrieve("http://genes.mit.edu/burgelab/miso/scripts/gtf2gff3.pl","gtf2gff3.pl")
Out[5]:
... to convert the annotation file to the newer gff3 standard
In [6]:
!perl gtf2gff3.pl dm3.ensGene.gtf > dm3.ensGene.gff3
Now misopy is needed to generate an index for this annotation file
The index will be stored in the 'indexed' folder
In [7]:
import misopy
from misopy import index_gff
index_gff.index_gff("dm3.ensGene.gff3", "indexed")
Now everything that is needed should be available to create a Sashimi plot
Generate Sashimi Plot
The function for the sashimi plot is imported
In [8]:
from misopy.sashimi_plot import sashimi_plot as sash_plot
help(sash_plot.plot_event)
A sashimi_settings file specifies aspects of the plot.
In [9]:
import ConfigParser
config = ConfigParser.RawConfigParser()
config.add_section('data')
config.set('data', 'bam_prefix', '/import')
config.set('data', 'bam_files', '["461177.bam", "461178.bam"]')
config.add_section('plotting')
config.set('plotting', 'fig_width', '7')
config.set('plotting', 'fig_height', '5')
config.set('plotting', 'intron_scale', '30')
config.set('plotting', 'exon_scale', '4')
config.set('plotting', 'logged', 'False')
config.set('plotting', 'font_size', '5')
config.set('plotting', 'ymax', '2500')
config.set('plotting', 'show_posteriors', 'False')
config.set('plotting', 'bar_posteriors', 'False')
config.set('plotting', 'number_junctions', 'True')
config.set('plotting', 'colors', '["#770022","#FF8800"]')
with open('sashimi_settings.txt', 'wb') as configfile:
config.write(configfile)
An output directory is created and a specific region of interest is plotted.
The ID of the event we want plotted comes from a valid name from the indexed gff file. (See last column of 'indexed/genes.gff')
In [10]:
!mkdir output
sash_plot.plot_event("FBgn0039909","indexed","sashimi_settings.txt","output")
Finally save the pdf back to the Galaxy history
In [20]:
put("output/FBgn0039909.pdf")
In [ ]: