Skip to content
Commits on Source (5)
# TRANSIT 2.1.2
# TRANSIT 2.2.1
[![Build Status](https://travis-ci.org/mad-lab/transit.svg?branch=master)](https://travis-ci.org/mad-lab/transit) [![Documentation Status](https://readthedocs.org/projects/transit/badge/?version=latest)](http://transit.readthedocs.io/en/latest/?badge=latest)
**Version 2.2.0 changes (June, 2018)**
- Added analysis method for Genetic Interactions.
- Added Mann-Whitney U-test for comparative analysis.
- Made TRANSIT compatible with wxPython 4.0 (Phoenix).
- Datasets now automatically selected when they are added to TRANSIT.
- TRANSIT window now starts maximized.
- Updated documentation.
- Fixed bug with plots of finished results files.
- Fixed bug in packaging of TPP, causing problem with console mode in new setuptools.
- Other misc. bugs fixes
**Version 2.1.2 changes (May, 2018)**
- Improved resampling on comparisons with unbalanced number of replicates.
......@@ -56,6 +67,26 @@ Welcome! This is the distribution for the TRANSIT and TPP tools developed by the
TRANSIT is a tool for the analysis of Tn-Seq data. It provides an easy to use graphical interface and access to three different analysis methods that allow the user to determine essentiality in a single condition as well as between conditions.
## Features
TRANSIT offers a variety of features including:
- More than **8 analysis methods**, including methods for determining **conditional essentiality** as well as **genetic interactions**.
- Ability to analyze datasets from libraries constructed using **himar1 or tn5 transposons**.
- **TrackView** to help visualize read-counts accross the genome.
- Can **export datasets** into a variety of formats, including **IGV**.
- Includes a **variety of normalization methods**.
- **Quality Control** diagnostics, to idenfity poor quality datasets.
- Ability to install as a **python package**, to import and use in your own personal scripts.
## Mailing List
......
version: 2.1.2-1-gccf8-mod
version: 2.2.0-6-g2c24-mod
tnseq-transit (2.2.1-1) unstable; urgency=medium
* New upstream version
* Standards-Version: 4.2.1
-- Andreas Tille <tille@debian.org> Wed, 26 Sep 2018 21:02:59 +0200
tnseq-transit (2.1.2-1) unstable; urgency=medium
* New upstream version
......
......@@ -6,7 +6,7 @@ Priority: optional
Build-Depends: debhelper (>= 11~),
python-all-dev,
python-setuptools
Standards-Version: 4.1.4
Standards-Version: 4.2.1
Vcs-Browser: https://salsa.debian.org/med-team/tnseq-transit
Vcs-Git: https://salsa.debian.org/med-team/tnseq-transit.git
Homepage: http://pythonhosted.org/tnseq-transit/transit_overview.html
......
......@@ -78,7 +78,7 @@ setup(
# your project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/requirements.html
install_requires=['setuptools', 'numpy', 'scipy', 'pillow', 'matplotlib'],
install_requires=['setuptools', 'numpy', 'scipy', 'pillow', 'matplotlib', 'wxpython'],
#dependency_links = [
# "git+https://github.com/wxWidgets/wxPython.git#egg=wxPython"
......@@ -113,8 +113,8 @@ setup(
# pip to create the appropriate form of executable for the target platform.
entry_points={
'console_scripts': [
'transit=pytransit.__main__:main',
'tpp=pytpp.__main__:main',
'transit=pytransit.__main__:run_main',
'tpp=pytpp.__main__:run_main',
],
},
)
......
......@@ -34,11 +34,15 @@ from tpp_tools import *
from tpp_gui import *
def main(arguments=[]):
def run_main():
(args, kwargs) = cleanargs(sys.argv[1:])
main(*args, **kwargs)
vars = Globals()
def main(*args, **kwargs):
if len(arguments)==0 and hasWx:
vars = Globals()
# Check for arguements
if not args and not kwargs and hasWx:
app = wx.App(False)
form = MyForm(vars)
form.update_dataset_list()
......@@ -62,14 +66,13 @@ def main(arguments=[]):
else:
pass
elif len(arguments) <= 1 and not hasWx:
elif not args and not kwargs and not hasWx:
print "Please install wxPython to run in GUI Mode."
print "To run in Console Mode please follow these instructions:"
print ""
show_help()
else:
(args, kwargs) = cleanargs(arguments)
# Show help if needed
if "help" in kwargs or "-help" in kwargs:
......@@ -110,5 +113,5 @@ def main(arguments=[]):
if __name__ == "__main__":
main(sys.argv[1:])
run_main()
......@@ -2,6 +2,6 @@
__all__ = ["transit_tools", "tnseq_tools", "norm_tools", "stat_tools"]
__version__ = "v2.1.2"
__version__ = "v2.2.1"
prefix = "[TRANSIT]"
import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import pytransit
import pytransit.transit_tools as transit_tools
import pytransit.analysis
import pytransit.export
method_wrap_width = 250
methods = pytransit.analysis.methods
export_methods = pytransit.analysis.export_methods
export_methods = pytransit.export.methods
all_methods = {}
all_methods.update(methods)
all_methods.update(export_methods)
#all_methods.update(export_methods)
wildcard = "Python source (*.py)|*.py|" \
"All files (*.*)|*.*"
transit_prefix = "[TRANSIT]"
def main(args=None):
def run_main():
(args, kwargs) = transit_tools.cleanargs(sys.argv[1:])
main(*args, **kwargs)
def main(*args, **kwargs):
#If no arguments, show GUI:
DEBUG = "--debug" in sys.argv
if DEBUG:
sys.argv.remove("--debug")
kwargs.pop("-debug")
# Check if running in GUI Mode
if len(sys.argv) == 1 and hasWx:
if not (args or kwargs) and hasWx:
import matplotlib
matplotlib.use("WXAgg")
import matplotlib.pyplot
import pytransit.transit_gui as transit_gui
transit_tools.transit_message("Running in GUI Mode")
......@@ -48,11 +74,13 @@ def main(args=None):
frame = transit_gui.TnSeekFrame(None, DEBUG)
#show the frame
frame.Show(True)
frame.Maximize(True)
#start the applications
app.MainLoop()
# Tried GUI mode but has no wxPython
elif len(sys.argv) == 1 and not hasWx:
elif not (args or kwargs) and not hasWx:
print "Please install wxPython to run in GUI Mode."
print "To run in Console Mode please follow these instructions:"
print ""
......@@ -64,8 +92,24 @@ def main(args=None):
else:
import matplotlib
matplotlib.use("Agg")
method_name = sys.argv[1]
method_name = args[0]
if method_name not in all_methods:
if method_name.lower() == "export":
export_method_name = ""
if len(args) > 1:
export_method_name = args[1]
if export_method_name not in export_methods:
print "Error: Need to specify the export method."
print "Please use one of the known methods (or see documentation to add a new one):"
for m in export_methods:
print "\t - %s" % m
print "Usage: python %s export <method>" % sys.argv[0]
else:
methodobj = export_methods[export_method_name].method.fromconsole()
methodobj.Run()
else:
print "Error: The '%s' method is unknown." % method_name
print "Please use one of the known methods (or see documentation to add a new one):"
for m in all_methods:
......@@ -80,5 +124,5 @@ def main(args=None):
if __name__ == "__main__":
main()
sys.exit(1)
......@@ -15,7 +15,8 @@ import griffin
import resampling
import hmm
import rankproduct
import gi
import utest
methods = {}
methods["example"] = example.ExampleAnalysis()
......@@ -26,6 +27,8 @@ methods["hmm"] = hmm.HMMAnalysis()
methods["resampling"] = resampling.ResamplingAnalysis()
methods["tn5gaps"] = tn5gaps.Tn5GapsAnalysis()
methods["rankproduct"] = rankproduct.RankProductAnalysis()
methods["utest"] = utest.UTestAnalysis()
methods["gi"] = gi.GIAnalysis()
#methods["mcce"] = mcce.MCCEAnalysis()
#methods["mcce2"] = mcce2.MCCE2Analysis()
#methods["motifhmm"] = motifhmm.MotifHMMAnalysis()
......
......@@ -3,18 +3,31 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import traceback
import datetime
......@@ -22,12 +35,15 @@ import pytransit.transit_tools as transit_tools
file_prefix = "[FileDisplay]"
class InvalidArgumentException(Exception):
def __init__(self, message):
# Call the base class constructor with the parameters it needs
super(InvalidArgumentException, self).__init__(message)
#
if hasWx:
class InfoIcon(wx.StaticBitmap):
def __init__(self, panel, flag, bmp=None, tooltip=""):
......@@ -44,56 +60,76 @@ class TransitGUIBase:
self.wxobj = None
self.short_name = "TRANSIT"
self.long_name = "TRANSIT"
self.short_desc = "TRANSIT - Short Description"
self.long_desc = "TRANSIT - Long Description"
#
def status_message(self, text, time=-1):
#TODO: write docstring
if self.wxobj:
if newWx:
if WX_VERSION > 2:
wx.CallAfter(pub.sendMessage, "status", msg=(self.short_name, text, time))
else:
wx.CallAfter(pub.sendMessage, "status", (self.short_name, text, time))
wx.Yield()
#
def console_message(self, text):
#TODO: write docstring
sys.stdout.write("[%s] %s\n" % (self.short_name, text))
#
def console_message_inplace(self, text):
#TODO: write docstring
sys.stdout.write("[%s] %s \r" % (self.short_name, text) )
sys.stdout.flush()
#
def transit_message(self, text):
#TODO: write docstring
self.console_message(text)
self.status_message(text)
#
def transit_message_inplace(self, text):
#TODO: write docstring
self.console_message_inplace(text)
self.status_message(text)
#
def transit_error(self,text):
self.transit_message(text)
if self.wxobj:
transit_tools.ShowError(text)
#
def transit_warning(self,text):
self.transit_message(text)
if self.wxobj:
transit_tools.ShowWarning(text)
#
class TransitFile (TransitGUIBase):
#TODO write docstring
#
def __init__(self, identifier="#Unknown", colnames=[]):
#TODO write docstring
TransitGUIBase.__init__(self)
self.identifier = identifier
self.colnames = colnames
#
def getData(self, path, colnames):
#TODO write docstring
row = 0
......@@ -116,15 +152,20 @@ class TransitFile (TransitGUIBase):
row+=1
return data
#
def getHeader(self, path):
#TODO write docstring
return "Generic Transit File Type."
#
def getMenus(self):
menus = [("Display in Track View", self.displayInTrackView)]
return menus
#
def displayInTrackView(self, displayFrame, event):
#print "Self:", self
......@@ -137,6 +178,8 @@ class TransitFile (TransitGUIBase):
except Exception as e:
print file_prefix, "Error occurred: %s" % e
#
class AnalysisGUI:
def __init__(self):
......@@ -145,16 +188,22 @@ class AnalysisGUI:
self.LABELSIZE = (100,-1)
self.WIDGETSIZE = (100,-1)
#
def Hide(self):
self.panel.Hide()
#
def Show(self):
self.panel.Show()
#
def Enable(self):
self.panel.Enable()
#
def definePanel(self, wxobj):
#TODO: write docstring
......@@ -164,8 +213,8 @@ class AnalysisGUI:
Section = wx.BoxSizer( wx.VERTICAL )
Label = wx.StaticText(wPanel, id=wx.ID_ANY, label=str("Options"), pos=wx.DefaultPosition, size=wx.DefaultSize, style=0 )
Label.Wrap( -1 )
Label = wx.StaticText(wPanel, id=wx.ID_ANY, label=str("Method Options"), pos=wx.DefaultPosition, size=(130, -1), style=0 )
Label.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
Section.Add( Label, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
Sizer1 = wx.BoxSizer( wx.HORIZONTAL )
......@@ -182,6 +231,8 @@ class AnalysisGUI:
Button.Bind( wx.EVT_BUTTON, self.wxobj.RunMethod )
self.panel = wPanel
#
def defineTextBox(self, panel, labelText="", widgetText="", tooltipText="", labSize=None, widgetSize=None):
if not labSize: labSize = self.LABELSIZE
if not widgetSize: widgetSize = self.WIDGETSIZE
......@@ -195,6 +246,8 @@ class AnalysisGUI:
sizer.Add(InfoIcon(panel, wx.ID_ANY, tooltip=tooltipText), 0, wx.ALIGN_CENTER_VERTICAL, 5 )
return (label, textBox, sizer)
#
def defineChoiceBox(self, panel, labelText="", widgetChoice=[""], tooltipText="", labSize=None, widgetSize=None):
if not labSize: labSize = self.LABELSIZE
if not widgetSize: widgetSize = self.WIDGETSIZE
......@@ -209,6 +262,8 @@ class AnalysisGUI:
sizer.Add(InfoIcon(panel, wx.ID_ANY, tooltip=tooltipText), 0, wx.ALIGN_CENTER_VERTICAL, 5 )
return (label, choiceBox, sizer)
#
def defineCheckBox(self, panel, labelText="", widgetCheck=False, tooltipText="", widgetSize=None):
if not widgetSize: widgetSize = self.WIDGETSIZE
sizer = wx.BoxSizer( wx.HORIZONTAL )
......@@ -218,33 +273,40 @@ class AnalysisGUI:
sizer.Add(InfoIcon(panel, wx.ID_ANY, tooltip=tooltipText), 0, wx.ALIGN_CENTER_VERTICAL, 5 )
return (checkBox, sizer)
#
class AnalysisMethod:
'''
Basic class for analysis methods. Inherited by SingleMethod and ComparisonMethod.
'''
def __init__(self, short_name, long_name, description, output, annotation_path, wxobj=None):
def __init__(self, short_name, long_name, short_desc, long_desc, output, annotation_path, wxobj=None):
self.short_name = short_name
self.long_name = long_name
self.description = description
self.short_desc = short_desc
self.long_desc = long_desc
self.output = output
self.annotation_path = annotation_path
self.newWx = newWx
self.WX_VERSION = WX_VERSION
self.wxobj = wxobj
#
@classmethod
def fromGUI(self, wxobj):
#TODO: write docstring
raise NotImplementedError
#
@classmethod
def fromargs(self, rawargs):
#TODO: write docstring
raise NotImplementedError
#
@classmethod
def fromconsole(self):
#TODO: write docstring
......@@ -270,15 +332,20 @@ class AnalysisMethod:
print self.usage_string()
sys.exit()
#
@classmethod
def usage_string(self):
#TODO: write docstring
raise NotImplementedError
#
def Run(self):
#TODO write docstring
raise NotImplementedError
#
def print_members(self):
#TODO: write docstring
......@@ -286,6 +353,7 @@ class AnalysisMethod:
for m in members:
print "%s = %s" % (m, getattr(self, m))
#
def add_file(self, path=None, filetype=None):
......@@ -298,73 +366,91 @@ class AnalysisMethod:
data = {"path":path, "type":filetype, "date": datetime.datetime.today().strftime("%B %d, %Y %I:%M%p")}
if self.wxobj:
if newWx:
if WX_VERSION > 2:
wx.CallAfter(pub.sendMessage, "file", data=data)
else:
wx.CallAfter(pub.sendMessage, "file", data)
#
def finish(self):
#TODO: write docstring
if self.wxobj:
if newWx:
if WX_VERSION > 2:
wx.CallAfter(pub.sendMessage,"finish", msg=self.short_name.lower())
else:
wx.CallAfter(pub.sendMessage,"finish", self.short_name.lower())
#
def progress_update(self, text, count):
#TODO: write docstring
if self.wxobj:
if newWx:
if WX_VERSION > 2:
wx.CallAfter(pub.sendMessage, "progress", msg=(self.short_name, count))
else:
wx.CallAfter(pub.sendMessage, "progress", (self.short_name, count))
wx.Yield()
self.transit_message_inplace(text)
#
def progress_range(self, count):
#TODO: write docstring
if self.wxobj:
if newWx:
if WX_VERSION > 2:
wx.CallAfter(pub.sendMessage, "progressrange", msg=count)
else:
wx.CallAfter(pub.sendMessage, "progressrange", count)
wx.Yield()
#
def status_message(self, text, time=-1):
#TODO: write docstring
if self.wxobj:
if newWx:
if WX_VERSION > 2:
wx.CallAfter(pub.sendMessage, "status", msg=(self.short_name, text, time))
else:
wx.CallAfter(pub.sendMessage, "status", (self.short_name, text, time))
wx.Yield()
#
def console_message(self, text):
#TODO: write docstring
sys.stdout.write("[%s] %s\n" % (self.short_name, text))
#
def console_message_inplace(self, text):
#TODO: write docstring
sys.stdout.write("[%s] %s \r" % (self.short_name, text) )
sys.stdout.flush()
#
def transit_message(self, text):
#TODO: write docstring
self.console_message(text)
self.status_message(text)
#
def transit_message_inplace(self, text):
#TODO: write docstring
self.console_message_inplace(text)
self.status_message(text)
#
def transit_error(self,text):
self.transit_message(text)
if self.wxobj:
transit_tools.ShowError(text)
#
def transit_warning(self,text):
self.transit_message(text)
if self.wxobj:
......@@ -376,8 +462,9 @@ class SingleConditionMethod(AnalysisMethod):
Class to be inherited by analysis methods that determine essentiality in a single condition (e.g. Gumbel, Binomial, HMM).
'''
def __init__(self, short_name, long_name, description, ctrldata, annotation_path, output, replicates="Sum", normalization=None, LOESS=False, ignoreCodon=True, NTerminus=0.0, CTerminus=0.0, wxobj=None):
AnalysisMethod.__init__(self, short_name, long_name, description, output, annotation_path, wxobj)
def __init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output, replicates="Sum", normalization=None, LOESS=False, ignoreCodon=True, NTerminus=0.0, CTerminus=0.0, wxobj=None):
AnalysisMethod.__init__(self, short_name, long_name, short_desc, long_desc, output,
annotation_path, wxobj)
self.ctrldata = ctrldata
self.replicates = replicates
self.normalization = normalization
......@@ -386,15 +473,16 @@ class SingleConditionMethod(AnalysisMethod):
self.NTerminus = NTerminus
self.CTerminus = CTerminus
#
class DualConditionMethod(AnalysisMethod):
'''
Class to be inherited by analysis methods that determine changes in essentiality between two conditions (e.g. Resampling, DEHMM).
'''
def __init__(self, short_name, long_name, description, ctrldata, expdata, annotation_path, output, normalization, replicates="Sum", LOESS=False, ignoreCodon=True, NTerminus=0.0, CTerminus=0.0, wxobj=None):
AnalysisMethod.__init__(self, short_name, long_name, description, output, annotation_path, wxobj)
def __init__(self, short_name, long_name, short_desc, long_desc, ctrldata, expdata, annotation_path, output, normalization, replicates="Sum", LOESS=False, ignoreCodon=True, NTerminus=0.0, CTerminus=0.0, wxobj=None):
AnalysisMethod.__init__(self, short_name, long_name, short_desc, long_desc,
output, annotation_path, wxobj)
self.ctrldata = ctrldata
self.expdata = expdata
self.normalization = normalization
......@@ -404,36 +492,67 @@ class DualConditionMethod(AnalysisMethod):
self.NTerminus = NTerminus
self.CTerminus = CTerminus
#
class QuadConditionMethod(AnalysisMethod):
'''
Class to be inherited by analysis methods that determine changes in essentiality between four conditions (e.g. GI).
'''
def __init__(self, short_name, long_name, short_desc, long_desc, ctrldataA, ctrldataB, expdataA, expdataB, annotation_path, output, normalization, replicates="Sum", LOESS=False, ignoreCodon=True, NTerminus=0.0, CTerminus=0.0, wxobj=None):
AnalysisMethod.__init__(self, short_name, long_name, short_desc, long_desc,
output, annotation_path, wxobj)
self.ctrldataA = ctrldataA
self.ctrldataB = ctrldataB
self.expdataA = expdataA
self.expdataB = expdataB
self.normalization = normalization
self.replicates = replicates
self.LOESS = LOESS
self.ignoreCodon = ignoreCodon
self.NTerminus = NTerminus
self.CTerminus = CTerminus
#
class TransitAnalysis:
def __init__(self, sn, ln, desc, tn, method_class=AnalysisMethod, gui_class=AnalysisGUI, filetypes=[TransitFile]):
def __init__(self, sn, ln, short_desc, long_desc, tn, method_class=AnalysisMethod, gui_class=AnalysisGUI, filetypes=[TransitFile]):
self.short_name = sn
self.long_name = ln
self.description = desc
self.short_desc = short_desc
self.long_desc = long_desc
self.transposons = tn
self.method = method_class
self.gui = gui_class()
self.filetypes = filetypes
#
def __str__(self):
return """Analysis Method:
Short Name: %s
Long Name: %s
Description: %s
Short Desc: %s
Long Desc: %s
Method: %s
GUI: %s""" % (self.short_name, self.long_name, self.description, self.method, self.gui)
GUI: %s""" % (self.short_name, self.long_name, self.short_desc, self.long_desc, self.method, self.gui)
#
def fullname(self):
return "[%s] - %s" % (self.short_name, self.long_name)
return "[%s] - %s" % (self.short_name, self.short_desc)
#
def getInstructionsText(self):
return ""
#
def getDescriptionText(self):
return self.description
return self.long_desc
#
def getTransposonsText(self):
if len(self.transposons) == 0:
......@@ -446,6 +565,7 @@ class TransitAnalysis:
return "Intended for " + ", ".join(self.transposons[:-1]) + ", and " + self.transposons[-1]
#
if __name__ == "__main__":
pass
......
......@@ -2,18 +2,31 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
import time
......@@ -34,8 +47,9 @@ import pytransit.stat_tools as stat_tools
############# GUI ELEMENTS ##################
short_name = "binomial"
long_name = "Hierarchical binomial model of essentiality with individual frequencies."
description = """Hierarchical bayesian model of essentiality based on the binomial distribution. Estimates individual probabilities for insertion, leading to more conservative predictions.
long_name = "Binomial"
short_desc = "Hierarchical binomial model of essentiality with individual frequencies."
long_desc = """Hierarchical bayesian model of essentiality based on the binomial distribution. Estimates individual probabilities for insertion, leading to more conservative predictions.
Reference: DeJesus and Ioerger (2014; IEEE TCBB)
"""
......@@ -46,7 +60,7 @@ columns = ["Orf","Name","Description","Mean Insertion","Sites per Replicate","To
class BinomialAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, BinomialMethod, BinomialGUI, [BinomialFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, BinomialMethod, BinomialGUI, [BinomialFile])
################## FILE ###################
......@@ -83,8 +97,8 @@ class BinomialGUI(base.AnalysisGUI):
binomialSection = wx.BoxSizer( wx.VERTICAL )
binomialLabel = wx.StaticText( binomialPanel, wx.ID_ANY, u"Binomial Options", wx.DefaultPosition, wx.DefaultSize, 0 )
binomialLabel.Wrap( -1 )
binomialLabel = wx.StaticText( binomialPanel, wx.ID_ANY, u"Binomial Options", wx.DefaultPosition, (130, -1), 0 )
binomialLabel.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
binomialSection.Add( binomialLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
binomialSizer1 = wx.BoxSizer( wx.HORIZONTAL )
......@@ -161,7 +175,7 @@ class BinomialMethod(base.SingleConditionMethod):
beta_w=0.5,
wxobj=None):
base.SingleConditionMethod.__init__(self, short_name, long_name, description, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.SingleConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
self.samples = samples
self.burnin = burnin
......@@ -453,9 +467,8 @@ class BinomialMethod(base.SingleConditionMethod):
#Update progress
text = "Running Binomial Method... %2.0f%%" % (100.0*(i+1)/(sample_size))
text = "Running Binomial Method... %5.1f%%" % (100.0*(i+1)/(sample_size))
self.progress_update(text, i)
self.transit_message_inplace(text)
numpy.seterr(divide='warn')
......
import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
import time
......@@ -32,8 +46,9 @@ import pytransit.stat_tools as stat_tools
############# Description ##################
short_name = "example"
long_name = "Example method that calculates mean read-counts per gene."
description = "A method made to serve as an example to implementing other methods."
long_name = "Example"
short_desc = "Example method that calculates mean read-counts per gene."
long_desc = "A method made to serve as an example to implementing other methods."
transposons = ["himar1", "tn5"]
columns = ["Orf","Name","Desc","k","n","mean","nzmean"]
......@@ -41,7 +56,7 @@ columns = ["Orf","Name","Desc","k","n","mean","nzmean"]
class ExampleAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, ExampleMethod, ExampleGUI, [ExampleFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, ExampleMethod, ExampleGUI, [ExampleFile])
################## FILE ###################
......@@ -81,7 +96,7 @@ class ExampleMethod(base.SingleConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.SingleConditionMethod.__init__(self, short_name, long_name, description, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.SingleConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
......@@ -194,8 +209,9 @@ class ExampleMethod(base.SingleConditionMethod):
data.append("%s\t%s\t%s\t%s\t%s\t%1.2f\t%1.2f\n" % (gene.orf, gene.name, gene.desc, gene.k, gene.n, mean, nzmean))
self.progress_update("gumbel", count)
self.transit_message_inplace("Running Example Method... %1.1f%%" % (100.0*count/N))
# Update Progress
text = "Running Example Method... %5.1f%%" % (100.0*count/N)
self.progress_update(text, count)
self.output.write("#Example\n")
......
This diff is collapsed.
......@@ -2,18 +2,31 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
import time
......@@ -35,8 +48,9 @@ import pytransit.stat_tools as stat_tools
############# GUI ELEMENTS ##################
short_name = "griffin"
long_name = "Basic frequentist analysis of essentiality using gaps."
description = "Analysis of gaps used in Griffin et al. 2011"
long_name = "Griffin"
short_desc = "Basic frequentist analysis of essentiality using gaps."
long_desc = "Analysis of gaps used in Griffin et al. 2011"
transposons = ["himar1"]
columns = ["Orf","Name","Desc","k","n","r","s","t","Expected Run","p-value", "p-adjusted"]
......@@ -46,7 +60,7 @@ columns = ["Orf","Name","Desc","k","n","r","s","t","Expected Run","p-value", "p-
class GriffinAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, GriffinMethod, GriffinGUI, [GriffinFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, GriffinMethod, GriffinGUI, [GriffinFile])
################## FILE ###################
......@@ -83,8 +97,8 @@ class GriffinGUI(base.AnalysisGUI):
griffinSection = wx.BoxSizer( wx.VERTICAL )
griffinLabel = wx.StaticText( griffinPanel, wx.ID_ANY, u"griffin Options", wx.DefaultPosition, wx.DefaultSize, 0 )
griffinLabel.Wrap( -1 )
griffinLabel = wx.StaticText( griffinPanel, wx.ID_ANY, u"griffin Options", wx.DefaultPosition, (120,-1), 0 )
griffinLabel.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
griffinSection.Add( griffinLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
griffinSizer1 = wx.BoxSizer( wx.HORIZONTAL )
......@@ -126,7 +140,7 @@ class GriffinMethod(base.SingleConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.SingleConditionMethod.__init__(self, short_name, long_name, description, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, ignoreCodon=ignoreCodon, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.SingleConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, ignoreCodon=ignoreCodon, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
self.minread = minread
......@@ -249,9 +263,8 @@ class GriffinMethod(base.SingleConditionMethod):
pval = 1.0 - tnseq_tools.GumbelCDF(gene.r, u, B)
results.append([gene, exprun, pval])
text = "Running Griffin Method... %2.0f%%" % (100.0*(count+1)/(N))
text = "Running Griffin Method... %5.1f%%" % (100.0*(count+1)/(N))
self.progress_update(text, count)
self.transit_message_inplace(text)
count+=1
......
......@@ -2,18 +2,31 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
import time
......@@ -34,8 +47,9 @@ import pytransit.stat_tools as stat_tools
############# GUI ELEMENTS ##################
short_name = "gumbel"
long_name = "Bayesian analysis of essentiality based on long gaps."
description = """Bayesian methods of analyzing longest runs of non-insertions in a row. Estimates the parameters using the MCMC sampling, and estimates posterior probabilities of essentiality.
long_name = "Gumbel"
short_desc = "Bayesian analysis of essentiality based on long gaps."
long_desc = """Bayesian methods of analyzing longest runs of non-insertions in a row. Estimates the parameters using the MCMC sampling, and estimates posterior probabilities of essentiality.
Reference: DeJesus et al. (2013; Bioinformatics)"""
transposons = ["himar1"]
......@@ -46,7 +60,7 @@ columns = ["Orf","Name","Desc","k","n","r","s","zbar", "Call"]
class GumbelAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, GumbelMethod, GumbelGUI, [GumbelFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, GumbelMethod, GumbelGUI, [GumbelFile])
################## FILE ###################
......@@ -88,8 +102,9 @@ class GumbelGUI(base.AnalysisGUI):
gumbelSection = wx.BoxSizer( wx.VERTICAL )
gumbelLabel = wx.StaticText( gumbelPanel, wx.ID_ANY, u"Gumbel Options", wx.DefaultPosition, wx.DefaultSize, 0 )
gumbelLabel.Wrap( -1 )
gumbelLabel = wx.StaticText( gumbelPanel, wx.ID_ANY, u"Gumbel Options", wx.DefaultPosition, (130,20))
gumbelLabel.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
gumbelSection.Add( gumbelLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
mainSizer1 = wx.BoxSizer( wx.VERTICAL )
......@@ -140,6 +155,8 @@ class GumbelGUI(base.AnalysisGUI):
########## METHOD #######################
EXACT = 20
ALPHA = 1
BETA = 1
class GumbelMethod(base.SingleConditionMethod):
......@@ -162,7 +179,7 @@ class GumbelMethod(base.SingleConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.SingleConditionMethod.__init__(self, short_name, long_name, description, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.SingleConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
self.samples = samples
self.burnin = burnin
self.trim = trim
......@@ -170,8 +187,7 @@ class GumbelMethod(base.SingleConditionMethod):
self.cache_nn = {}
self.cache_expruns = {}
@classmethod
def fromGUI(self, wxobj):
......@@ -365,6 +381,10 @@ class GumbelMethod(base.SingleConditionMethod):
SIG = numpy.array([self.sigmoid(g.s, g.t) * scipy.stats.norm.pdf(g.r, mu_r*g.s, sigma_r) for g in G if self.good_orf(g)])
# idxG,idxN = -1,0
# for i in range(len(G)):
# if G[i].name=="glf": idxG = i
# if ii_good[i]==True: idxN += 1 # could do sum(ii_good[:idxG])
i = 1; count = 0;
while i < self.samples:
......@@ -393,6 +413,7 @@ class GumbelMethod(base.SingleConditionMethod):
phi_sample[i] = phi_new
Z_sample[:,i] = Z
i+=1
except ValueError as e:
self.transit_message("Error: %s" % e)
self.transit_message("This is likely to have been caused by poor data (e.g. too sparse).")
......@@ -400,12 +421,12 @@ class GumbelMethod(base.SingleConditionMethod):
self.transit_message("Quitting.")
return
# print i,phi_new,w1,G[idxG].name,N[idxN],R[idxN],Z[idxN]
phi_old = phi_new
#Update progress
text = "Running Gumbel Method... %2.0f%%" % (100.0*(count+1)/(self.samples+self.burnin))
text = "Running Gumbel Method... %5.1f%%" % (100.0*(count+1)/(self.samples+self.burnin))
self.progress_update(text, count)
self.transit_message_inplace(text)
ZBAR = numpy.apply_along_axis(numpy.mean, 1, Z_sample)
......@@ -476,28 +497,44 @@ class GumbelMethod(base.SingleConditionMethod):
def good_orf(self, gene):
return (gene.n >= 3 and gene.t >= 150)
def ExpectedRuns_cached(self,n,q):
if (n,q) not in self.cache_expruns: self.cache_expruns[(n,q)] = tnseq_tools.ExpectedRuns(n,q)
return self.cache_expruns[(n,q)]
def classify(self, n,r,p):
if n == 0: return 0
q = 1-p; B = 1/math.log(1/p); u = math.log(n*q,1/p);
pval = 1 - scipy.stats.gumbel_r.cdf(r,u,B)
q = 1-p; B = 1/math.log(1/p); u = math.log(n*q,1/p)
BetaGamma = B*tnseq_tools.getGamma()
if n<EXACT: # estimate more accurately based on expected run len, using exact calc for small genes
exprun = self.ExpectedRuns_cached(n,p)
u = exprun-BetaGamma # u is mu of Gumbel (mean=mu+gamma*beta); matching of moments
pval = 1 - scipy.exp(scipy.stats.gumbel_r.logcdf(r,u,B))
if pval < 0.05: return(1)
else: return(0)
def F_non(self, p, N, R):
q = 1.0 - p
def F_non(self, p, N, R): # pass in P_nonins as p
q = 1.0 - p;
BetaGamma = tnseq_tools.getGamma()/math.log(1/p)
total = numpy.log(scipy.stats.beta.pdf(p,ALPHA,BETA))
mu = numpy.log(N*q) / numpy.log(1/p)
for i in range(len(N)): # estimate more accurately based on expected run len, using exact calc for small genes
if N[i]<EXACT: mu[i] = self.ExpectedRuns_cached(int(N[i]),p)-BetaGamma
sigma = 1/math.log(1/p);
total+= numpy.sum(numpy.log(scipy.stats.gumbel_r.pdf(R, mu, sigma)))
#for i in range(len(N)): print '\t'.join([str(x) for x in N[i],R[i],self.ExpectedRuns_cached(int(N[i]),q),mu[i],scipy.stats.gumbel_r.pdf(R[i], mu[i], sigma)])
total += numpy.sum(scipy.stats.gumbel_r.logpdf(R, mu, sigma))
return(total)
def sample_Z(self, p, w1, N, R, S, T, mu_s, sigma_s, SIG):
G = len(N)
q = 1.0-p
mu = numpy.log(N*q) / numpy.log(1.0/p)
BetaGamma = tnseq_tools.getGamma()/math.log(1/p)
mu = numpy.log(N*q) / numpy.log(1/p)
for i in range(len(N)): # estimate more accurately based on expected run len, using exact calc for small genes
if N[i]<EXACT: mu[i] = self.ExpectedRuns_cached(int(N[i]),p)-BetaGamma
sigma = 1.0/math.log(1.0/p);
h0 = ((scipy.stats.gumbel_r.pdf(R,mu,sigma)) * scipy.stats.norm.pdf(S, mu_s*R, sigma_s) * (1-w1))
h0 = ((scipy.exp(scipy.stats.gumbel_r.logpdf(R,mu,sigma))) * scipy.stats.norm.pdf(S, mu_s*R, sigma_s) * (1-w1))
h1 = SIG * w1
h1 += 1e-10; h0 += 1e-10 # to prevent div-by-zero; if neither class is probable, p(z1) should be ~0.5
p_z1 = h1/(h0+h1)
return scipy.stats.binom.rvs(1, p_z1, size=G)
......
......@@ -2,18 +2,31 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
import time
......@@ -35,8 +48,9 @@ import pytransit.stat_tools as stat_tools
############# GUI ELEMENTS ##################
short_name = "hmm"
long_name = "Analysis of genomic regions using a Hidden Markov Model"
description = """Analysis of essentiality in the entire genome using a Hidden Markov Model. Capable of determining regions with different levels of essentiality representing Essential, Growth-Defect, Non-Essential and Growth-Advantage regions.
long_name = "HMM"
short_desc = "Analysis of genomic regions using a Hidden Markov Model"
long_desc = """Analysis of essentiality in the entire genome using a Hidden Markov Model. Capable of determining regions with different levels of essentiality representing Essential, Growth-Defect, Non-Essential and Growth-Advantage regions.
Reference: DeJesus et al. (2013; BMC Bioinformatics)
"""
......@@ -49,7 +63,7 @@ columns_genes = ["Orf","Name","Description","Total Sites","Num. ES","Num. GD","N
class HMMAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, HMMMethod, HMMGUI, [HMMSitesFile, HMMGenesFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, HMMMethod, HMMGUI, [HMMSitesFile, HMMGenesFile])
################## FILE ###################
......@@ -121,8 +135,8 @@ class HMMGUI(base.AnalysisGUI):
hmmSection = wx.BoxSizer( wx.VERTICAL )
hmmLabel = wx.StaticText( hmmPanel, wx.ID_ANY, u"HMM Options", wx.DefaultPosition, wx.DefaultSize, 0 )
hmmLabel.Wrap( -1 )
hmmLabel = wx.StaticText( hmmPanel, wx.ID_ANY, u"HMM Options", wx.DefaultPosition, (110,-1), 0 )
hmmLabel.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
hmmSection.Add( hmmLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
hmmSizer1 = wx.BoxSizer( wx.VERTICAL )
......@@ -143,7 +157,7 @@ class HMMGUI(base.AnalysisGUI):
# LOESS
(self.wxobj.hmmLoessCheck, loessCheckSizer) = self.defineCheckBox(hmmPanel, labelText="Correct for Genome Positional Bias", widgetCheck=False, widgetSize=(230,-1), tooltipText="Check to correct read-counts for possible regional biase using LOESS. Clicking on the button below will plot a preview, which is helpful to visualize the possible bias in the counts.")
(self.wxobj.hmmLoessCheck, loessCheckSizer) = self.defineCheckBox(hmmPanel, labelText="Correct for Genome Positional Bias", widgetCheck=False, widgetSize=(-1,-1), tooltipText="Check to correct read-counts for possible regional biase using LOESS. Clicking on the button below will plot a preview, which is helpful to visualize the possible bias in the counts.")
hmmSizer1.Add( loessCheckSizer, 0, wx.EXPAND, 5 )
# LOESS Button
......@@ -187,7 +201,7 @@ class HMMMethod(base.SingleConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.SingleConditionMethod.__init__(self, short_name, long_name, description, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.SingleConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
try:
T = len([1 for line in open(ctrldata[0]).readlines() if not line.startswith("#")])
......@@ -460,8 +474,8 @@ class HMMMethod(base.SingleConditionMethod):
if numpy.sum(alpha[:,t]) == 0:
alpha[:,t] = 0.0000000000001
self.progress_update("hmm", self.count)
self.transit_message_inplace("Running HMM Method... %1.1f%%" % (100.0*self.count/self.maxiterations))
text = "Running HMM Method... %1.1f%%" % (100.0*self.count/self.maxiterations)
self.progress_update(text, self.count)
self.count+=1
#print t, O[:,t], alpha[:,t]
......@@ -490,8 +504,8 @@ class HMMMethod(base.SingleConditionMethod):
if C.any():
beta[:,t] = beta[:,t] * C[t]
self.progress_update("hmm", self.count)
self.transit_message_inplace("Running HMM Method... %1.1f%%" % (100.0*self.count/self.maxiterations))
text = "Running HMM Method... %1.1f%%" % (100.0*self.count/self.maxiterations)
self.progress_update(text, self.count)
self.count+=1
return(beta)
......@@ -515,20 +529,21 @@ class HMMMethod(base.SingleConditionMethod):
nus = delta[:, t-1] + A
delta[:,t] = nus.max(1) + numpy.log(b_o)
Q[:,t] = nus.argmax(1)
self.progress_update("hmm", self.count)
self.transit_message_inplace("Running HMM Method... %1.1f%%" % (100.0*self.count/self.maxiterations))
text = "Running HMM Method... %5.1f%%" % (100.0*self.count/self.maxiterations)
self.progress_update(text, self.count)
self.count+=1
Q_opt = [int(numpy.argmax(delta[:,T-1]))]
for t in xrange(T-2, -1, -1):
Q_opt.insert(0, Q[Q_opt[0],t+1])
self.progress_update("hmm", self.count)
self.transit_message_inplace("Running HMM Method... %1.1f%%" % (100.0*self.count/self.maxiterations))
text = "Running HMM Method... %5.1f%%" % (100.0*self.count/self.maxiterations)
self.progress_update(text, self.count)
self.count+=1
numpy.seterr(divide='warn')
self.progress_update("hmm", self.count)
self.transit_message_inplace("Running HMM Method... %1.1f%%" % (100.0*self.count/self.maxiterations))
text = "Running HMM Method... %5.1f%%" % (100.0*self.count/self.maxiterations)
self.progress_update(text, self.count)
return((Q_opt, delta, Q))
......
import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
import time
......@@ -32,8 +46,9 @@ import pytransit.stat_tools as stat_tools
############# Description ##################
short_name = "norm"
long_name = "Normalization method"
description = "Method for normalizing datasets and outputting into CombinedWig file."
long_name = "Normalization"
short_desc = "Normalization method"
long_desc = "Method for normalizing datasets and outputting into CombinedWig file."
transposons = ["himar1", "tn5"]
columns = ["Position","Reads","Genes"]
......@@ -42,7 +57,7 @@ columns = ["Position","Reads","Genes"]
class NormAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, NormMethod, NormGUI, [NormFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, NormMethod, NormGUI, [NormFile])
################## FILE ###################
......@@ -83,7 +98,7 @@ class NormMethod(base.SingleConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.SingleConditionMethod.__init__(self, short_name, long_name, description, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.SingleConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
@classmethod
......
......@@ -2,18 +2,30 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
......@@ -36,8 +48,9 @@ import pytransit.stat_tools as stat_tools
############# GUI ELEMENTS ##################
short_name = "rankproduct"
long_name = "Rank Product test for determining conditional essentiality."
description = "Differential Comparison based on ranks"
long_name = "Rank Product"
short_desc = "Rank Product test for determining conditional essentiality."
long_desc = "Differential Comparison based on ranks"
transposons = ["himar1", "tn5"]
columns = ["Orf","Name","Desc","Sites","Mean Ctrl","Mean Exp","log2FC","Obs RP","Expected RP","q-value"]
......@@ -47,7 +60,7 @@ columns = ["Orf","Name","Desc","Sites","Mean Ctrl","Mean Exp","log2FC","Obs RP",
class RankProductAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, RankProductMethod, RankProductGUI, [RankProductFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, RankProductMethod, RankProductGUI, [RankProductFile])
################## FILE ###################
......@@ -68,8 +81,8 @@ class RankProductGUI(base.AnalysisGUI):
rankproductSizer = wx.BoxSizer( wx.VERTICAL )
rankproductLabel = wx.StaticText( rankproductPanel, wx.ID_ANY, u"rankproduct Options", wx.DefaultPosition, wx.DefaultSize, 0 )
rankproductLabel.Wrap( -1 )
rankproductLabel = wx.StaticText( rankproductPanel, wx.ID_ANY, u"rankproduct Options", wx.DefaultPosition, (160,-1), 0 )
rankproductLabel.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
rankproductSizer.Add( rankproductLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
rankproductLabelSizer = wx.BoxSizer( wx.VERTICAL )
......@@ -127,7 +140,7 @@ class RankProductMethod(base.DualConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.DualConditionMethod.__init__(self, short_name, long_name, description, ctrldata, expdata, annotation_path, output_file, normalization=normalization, replicates=replicates, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.DualConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, expdata, annotation_path, output_file, normalization=normalization, replicates=replicates, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
self.samples = samples
self.adaptive = adaptive
......@@ -308,8 +321,10 @@ class RankProductMethod(base.DualConditionMethod):
q_paper = e_val/float(rankRP[i])
data.append([gene.orf, gene.name, gene.desc, gene.n, meanctrl, meanexp, log2fc, obsRP[i], e_val, q_paper, pval])
self.progress_update("rankproduct", count)
self.transit_message_inplace("Running rankproduct Method... %1.1f%%" % (100.0*count/Ngenes))
# Update Progress
text = "Running rankproduct Method... %5.1f%%" % (100.0*count/Ngenes)
self.progress_update(text, count)
#
......
......@@ -2,18 +2,30 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
......@@ -37,15 +49,16 @@ import pytransit.stat_tools as stat_tools
############# GUI ELEMENTS ##################
short_name = "resampling"
long_name = "Resampling test of conditional essentiality between two conditions"
description = """Method for determining conditional essentiality based on resampling (i.e. permutation test). Identifies significant changes in mean read-counts for each gene after normalization."""
long_name = "Resampling (Permutation test)"
short_desc = "Resampling test of conditional essentiality between two conditions"
long_desc = """Method for determining conditional essentiality based on resampling (i.e. permutation test). Identifies significant changes in mean read-counts for each gene after normalization."""
transposons = ["himar1", "tn5"]
columns = ["Orf","Name","Desc","Sites","Mean Ctrl","Mean Exp","log2FC", "Sum Ctrl", "Sum Exp", "Delta Mean","p-value","Adj. p-value"]
class ResamplingAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, ResamplingMethod, ResamplingGUI, [ResamplingFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, ResamplingMethod, ResamplingGUI, [ResamplingFile])
......@@ -106,8 +119,8 @@ class ResamplingGUI(base.AnalysisGUI):
resamplingSizer = wx.BoxSizer( wx.VERTICAL )
resamplingLabel = wx.StaticText( resamplingPanel, wx.ID_ANY, u"resampling Options", wx.DefaultPosition, wx.DefaultSize, 0 )
resamplingLabel.Wrap( -1 )
resamplingLabel = wx.StaticText( resamplingPanel, wx.ID_ANY, u"resampling Options", wx.DefaultPosition, (160,-1), 0 )
resamplingLabel.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
resamplingSizer.Add( resamplingLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
resamplingTopSizer = wx.BoxSizer( wx.HORIZONTAL )
......@@ -139,7 +152,7 @@ class ResamplingGUI(base.AnalysisGUI):
# LOESS Check
(self.wxobj.resamplingLoessCheck, loessCheckSizer) = self.defineCheckBox(resamplingPanel, labelText="Correct for Genome Positional Bias", widgetCheck=False, widgetSize=(230,-1), tooltipText="Check to correct read-counts for possible regional biase using LOESS. Clicking on the button below will plot a preview, which is helpful to visualize the possible bias in the counts.")
(self.wxobj.resamplingLoessCheck, loessCheckSizer) = self.defineCheckBox(resamplingPanel, labelText="Correct for Genome Positional Bias", widgetCheck=False, widgetSize=(-1,-1), tooltipText="Check to correct read-counts for possible regional biase using LOESS. Clicking on the button below will plot a preview, which is helpful to visualize the possible bias in the counts.")
resamplingSizer.Add( loessCheckSizer, 0, wx.EXPAND, 5 )
# LOESS Button
......@@ -147,16 +160,16 @@ class ResamplingGUI(base.AnalysisGUI):
resamplingSizer.Add( self.wxobj.resamplingLoessPrev, 0, wx.ALL|wx.CENTER, 5 )
# Adaptive Check
(self.wxobj.resamplingAdaptiveCheckBox, adaptiveSizer) = self.defineCheckBox(resamplingPanel, labelText="Adaptive Resampling (Faster)", widgetCheck=False, widgetSize=(200,-1), tooltipText="Dynamically stops permutations early if it is unlikely the ORF will be significant given the results so far. Improves performance, though p-value calculations for genes that are not differentially essential will be less accurate.")
(self.wxobj.resamplingAdaptiveCheckBox, adaptiveSizer) = self.defineCheckBox(resamplingPanel, labelText="Adaptive Resampling (Faster)", widgetCheck=False, widgetSize=(-1,-1), tooltipText="Dynamically stops permutations early if it is unlikely the ORF will be significant given the results so far. Improves performance, though p-value calculations for genes that are not differentially essential will be less accurate.")
resamplingSizer.Add( adaptiveSizer, 0, wx.EXPAND, 5 )
# Histogram Check
(self.wxobj.resamplingHistogramCheckBox, histSizer) = self.defineCheckBox(resamplingPanel, labelText="Generate Resampling Histograms", widgetCheck=False, widgetSize=(225,-1), tooltipText="Creates .png images with the resampling histogram for each of the ORFs. Histogram images are created in a folder with the same name as the output file.")
(self.wxobj.resamplingHistogramCheckBox, histSizer) = self.defineCheckBox(resamplingPanel, labelText="Generate Resampling Histograms", widgetCheck=False, widgetSize=(-1,-1), tooltipText="Creates .png images with the resampling histogram for each of the ORFs. Histogram images are created in a folder with the same name as the output file.")
resamplingSizer.Add(histSizer, 0, wx.EXPAND, 5 )
# Zeros Check
(self.wxobj.resamplingZeroCheckBox, zeroSizer) = self.defineCheckBox(resamplingPanel, labelText="Include sites with all zeros", widgetCheck=True, widgetSize=(180,-1), tooltipText="Includes sites that are empty (zero) accross all datasets. Unchecking this may be useful for tn5 datasets, where all nucleotides are possible insertion sites and will have a large number of empty sites (significantly slowing down computation and affecting estimates).")
(self.wxobj.resamplingZeroCheckBox, zeroSizer) = self.defineCheckBox(resamplingPanel, labelText="Include sites with all zeros", widgetCheck=True, widgetSize=(-1,-1), tooltipText="Includes sites that are empty (zero) accross all datasets. Unchecking this may be useful for tn5 datasets, where all nucleotides are possible insertion sites and will have a large number of empty sites (significantly slowing down computation and affecting estimates).")
resamplingSizer.Add(zeroSizer, 0, wx.EXPAND, 5 )
......@@ -200,7 +213,7 @@ class ResamplingMethod(base.DualConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.DualConditionMethod.__init__(self, short_name, long_name, description, ctrldata, expdata, annotation_path, output_file, normalization=normalization, replicates=replicates, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.DualConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, expdata, annotation_path, output_file, normalization=normalization, replicates=replicates, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
self.samples = samples
self.adaptive = adaptive
......@@ -392,9 +405,9 @@ class ResamplingMethod(base.DualConditionMethod):
if self.doHistogram:
import matplotlib.pyplot as plt
if testlist:
n, bins, patches = plt.hist(testlist, normed=1, facecolor='c', alpha=0.75, bins=100)
n, bins, patches = plt.hist(testlist, density=1, facecolor='c', alpha=0.75, bins=100)
else:
n, bins, patches = plt.hist([0,0], normed=1, facecolor='c', alpha=0.75, bins=100)
n, bins, patches = plt.hist([0,0], density=1, facecolor='c', alpha=0.75, bins=100)
plt.xlabel('Delta Mean')
plt.ylabel('Probability')
plt.title('%s - Histogram of Delta Mean' % gene.orf)
......@@ -410,8 +423,10 @@ class ResamplingMethod(base.DualConditionMethod):
sum1 = numpy.sum(data1)
sum2 = numpy.sum(data2)
data.append([gene.orf, gene.name, gene.desc, gene.n, mean1, mean2, sum1, sum2, test_obs, log2FC, pval_2tail])
self.progress_update("resampling", count)
self.transit_message_inplace("Running Resampling Method... %1.1f%%" % (100.0*count/N))
# Update progress
text = "Running Resampling Method... %5.1f%%" % (100.0*count/N)
self.progress_update(text, count)
#
......
......@@ -2,18 +2,31 @@ import sys
try:
import wx
WX_VERSION = int(wx.version()[0])
hasWx = True
#Check if wx is the newest 3.0+ version:
try:
from wx.lib.pubsub import pub
pub.subscribe
newWx = True
except AttributeError as e:
from wx.lib.pubsub import Publisher as pub
newWx = False
except Exception as e:
hasWx = False
newWx = False
WX_VERSION = 0
print "EXCEPTION:", str(e)
if hasWx:
import wx.xrc
from wx.lib.buttons import GenBitmapTextButton
#Imports depending on version:
if WX_VERSION == 2:
from wx.lib.pubsub import Publisher as pub
if WX_VERSION == 3:
from wx.lib.pubsub import pub
pub.subscribe
if WX_VERSION == 4:
from wx.lib.pubsub import pub
pub.subscribe
import wx.adv
import os
import time
......@@ -35,8 +48,9 @@ import pytransit.stat_tools as stat_tools
############# GUI ELEMENTS ##################
short_name = "tn5gaps"
long_name = "Analysis of essentiality on gaps in entire genome (Tn5)."
description = "A analysis method based on the extreme value (Gumbel) distribution that considers longest runs over the whole genome instead of individual genes."
long_name = "Tn5 Gaps"
short_desc = "Analysis of essentiality on gaps in entire genome (Tn5)."
long_desc = "A analysis method based on the extreme value (Gumbel) distribution that considers longest runs over the whole genome instead of individual genes."
transposons = ["tn5"]
columns = ["Orf","Name","Desc","k","n","r","ovr","lenovr","pval","padj","call"]
......@@ -46,7 +60,7 @@ columns = ["Orf","Name","Desc","k","n","r","ovr","lenovr","pval","padj","call"]
class Tn5GapsAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, description, transposons, Tn5GapsMethod, Tn5GapsGUI, [Tn5GapsFile])
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, Tn5GapsMethod, Tn5GapsGUI, [Tn5GapsFile])
################## FILE ###################
......@@ -81,8 +95,8 @@ class Tn5GapsGUI(base.AnalysisGUI):
tn5GapsSection = wx.BoxSizer( wx.VERTICAL )
tn5GapsLabel = wx.StaticText( tn5GapsPanel, wx.ID_ANY, u"Tn5 Gaps Options", wx.DefaultPosition, wx.DefaultSize, 0 )
tn5GapsLabel.Wrap( -1 )
tn5GapsLabel = wx.StaticText( tn5GapsPanel, wx.ID_ANY, u"Tn5 Gaps Options", wx.DefaultPosition, (150,-1), 0 )
tn5GapsLabel.SetFont( wx.Font( 10, wx.DEFAULT, wx.NORMAL, wx.BOLD) )
tn5GapsSection.Add( tn5GapsLabel, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 )
mainSizer1 = wx.BoxSizer( wx.VERTICAL )
......@@ -139,7 +153,7 @@ class Tn5GapsMethod(base.SingleConditionMethod):
NTerminus=0.0,
CTerminus=0.0, wxobj=None):
base.SingleConditionMethod.__init__(self, short_name, long_name, description, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
base.SingleConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, ctrldata, annotation_path, output_file, replicates=replicates, normalization=normalization, LOESS=LOESS, NTerminus=NTerminus, CTerminus=CTerminus, wxobj=wxobj)
self.minread = minread
......@@ -286,8 +300,10 @@ class Tn5GapsMethod(base.SingleConditionMethod):
curr_len = curr_val[7]
if inter_sz > curr_inter_sz:
results_per_gene[gene.orf] = [gene.orf, gene.name, gene.desc, gene.k, gene.n, gene.r, inter_sz, run_len, pval]
self.progress_update("tn5gaps", count)
self.transit_message_inplace("Running Tn5Gaps method... %1.1f%%" % (100.0*count/N))
# Update Progress
text = "Running Tn5Gaps method... %1.1f%%" % (100.0*count/N)
self.progress_update(text, count)
data = list(results_per_gene.values())
exp_run_len = float(accum)/N
......