Skip to content
Commits on Source (2)
......@@ -53,6 +53,7 @@ coverage.xml
# Sphinx documentation
docs/_build/
**/doc/_build/
#Data files
*.wig
......@@ -61,3 +62,10 @@ docs/_build/
*.png
*.out
NOTES
*~
#Test output ignore
tests/testoutput.txt
tests/testoutput_genes.txt
......@@ -6,8 +6,8 @@ matrix:
dist: trusty
sudo: required
python: 2.7
before_install: "sudo apt-get install -y -f python python-dev python-pip pkg-config python-wxgtk2.8 libpng-dev libjpeg8-dev libfreetype6-dev"
install: "pip install --upgrade pip setuptools numpy scipy pillow matplotlib pytest"
before_install: "sudo apt-get install -y -f python python-dev python-pip pkg-config libpng-dev libjpeg8-dev libfreetype6-dev"
install: "pip install --upgrade pip setuptools numpy scipy pillow matplotlib pytest statsmodels"
DISPLAY: 0.0
notifications:
......
# Change log
All notable changes to this project will be documented in this file.
## Version 2.3.2 2018-11-09
- TRANSIT:
- Minor bug fixes related to changing parameters in TPP GUI
## Version 2.3.1 2018-10-19
- TRANSIT:
- Removed dependence on PyPubSub (can run Transit in command-line mode without it, but needed for GUI)
## Version 2.3.0 2018-10-10
- TRANSIT:
- Added calculation of Pathway Enrichment as post-processing for resampling, to determine if conditionally essential genes over-represent a particular functional category or pathway (such as for GO terms)
- Added ANOVA analysis for identifying genes with significant variability of counts across multiple conditions
- Updated Documentation - especially for "Quality Control/TnSeq Statistics"; also added more command-line examples under "Analysis Methods"
- Fixed bugs (including TrackView in the GUI)
- Upgraded dependencies, including wxPython 4.0 (required)
## Version 2.2.0 - 2018-06-04
- TRANSIT:
- 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.
- Fixed bug in packaging of TPP, causing problem with console mode in new setuptools.
- Miscellaneous bugs fixes
## Version 2.1.0 - 2017-06-23
......
# TRANSIT 2.2.1
# TRANSIT 2.3.2
[![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.
- Improved speed of TPP.
- Added Barseq functionality to TPP.
- Fixed bug with creating resampling histograms on GUI mode.
- Miscellaneous code improvements.
**Version 2.1.1 changes (July, 2017)**
- Miscellaneous bug fixes
**Version 2.1.0 changes (June, 2017)**
- Added tooltips next to most parameters to explain their functionality.
- Added Quality Control window, with choice for normalization method.
- Added more normalization options to the HMM method.
- Added LOESS correction functionality back to TRANSIT
- Added ability to scale Track View based on mean-count of the window.
- Added ability to scale individual tracks in Track View.
- Added ability to add tracks of features to Track View.
- Better status messages for TrackView
- TPP can now accept empty primer prefix (in case reads have been trimmed).
- TPP can now process reads obtained using Mme1 enzyme and protocol.
- TPP can now pass flags to BWA.
- Lots of bug fixes.
**Version 2.0.2 changes (August, 2016)**
- Added support for for custom primers in TPP.
- Added support for annotations in GFF3 format.
- Ability to specify pseudocounts in resampling.
- Misc. Bug fixes
- **New [mailing list](https://groups.google.com/forum/#!forum/tnseq-transit/join)**
**New in Version 2.0+**
- Support for Tn5 datasets.
- New analysis methods.
- New way to export normalized datasets.
Welcome! This is the distribution for the TRANSIT and TPP tools developed by the Ioerger Lab.
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.
[Changelog](https://github.com/mad-lab/transit/blob/master/CHANGELOG.md)
## Features
TRANSIT offers a variety of features including:
......@@ -86,20 +30,16 @@ TRANSIT offers a variety of features including:
## Support
## Mailing List
You can join our mailing list to get announcements of new versions, discuss any bugs, or request features! Just head over to the following site and enter your email address:
https://groups.google.com/forum/#!forum/tnseq-transit/join
For any questions or comments, please contact Dr. Thomas Ioerger, ioerger@cs.tamu.edu.
## Instructions
For full instructions on how to install and run TRANSIT (and the optional pre-processor, TPP), please see the documentation included in this distribution ("doc" folder) or visit the following web page:
For full instructions on how to install and run TRANSIT (and the optional pre-processor, TPP), please see the documentation included in this distribution ("src/pytransit/doc" folder) or visit the following web page:
http://saclab.tamu.edu/essentiality/transit/transit.html
......
version: 2.2.0-6-g2c24-mod
version: 2.2.1-9-ge742-mod
......@@ -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', 'wxpython'],
install_requires=['setuptools', 'numpy~=1.15', 'scipy~=1.1', 'matplotlib~=2.2', 'pillow~=5.0', 'statsmodels~=0.9'],
#dependency_links = [
# "git+https://github.com/wxWidgets/wxPython.git#egg=wxPython"
......
......@@ -99,7 +99,7 @@ if hasWx:
sizer3 = wx.BoxSizer(wx.HORIZONTAL)
label3 = wx.StaticText(panel, label='Choose a reference genome (FASTA):',size=(330,-1))
sizer3.Add(label3,0,wx.ALIGN_CENTER_VERTICAL,0)
self.picker3 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the reference genome', fileMode=wx.OPEN, fileMask='*.fna;*.fasta;*.fa', size=(400,30), startDirectory=os.path.dirname(vars.ref), initialValue=vars.ref, labelText='')
self.picker3 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the reference genome', fileMode=wx.FD_OPEN, fileMask='*.fna;*.fasta;*.fa', size=(400,30), startDirectory=os.path.dirname(vars.ref), initialValue=vars.ref, labelText='')
sizer3.Add(self.picker3, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
sizer3.Add(TPPIcon(panel, wx.ID_ANY, bmp, "Select a reference genome in FASTA format."), flag=wx.CENTER, border=0)
sizer3.Add((10, 1), 0, wx.EXPAND)
......@@ -109,7 +109,7 @@ if hasWx:
sizer1 = wx.BoxSizer(wx.HORIZONTAL)
label1 = wx.StaticText(panel, label='Choose the Fastq file for read 1:',size=(330,-1))
sizer1.Add(label1,0,wx.ALIGN_CENTER_VERTICAL,0)
self.picker1 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the .fastq file for read 1', fileMode=wx.OPEN, fileMask='*.fastq;*.fq;*.reads;*.fasta;*.fa;*.fastq.gz', size=(400,30), startDirectory=os.path.dirname(vars.fq1), initialValue=vars.fq1, labelText='',changeCallback=self.OnChanged2)
self.picker1 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the .fastq file for read 1', fileMode=wx.FD_OPEN, fileMask='*.fastq;*.fq;*.reads;*.fasta;*.fa;*.fastq.gz', size=(400,30), startDirectory=os.path.dirname(vars.fq1), initialValue=vars.fq1, labelText='',changeCallback=self.OnChanged2)
sizer1.Add(self.picker1, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
sizer1.Add(TPPIcon(panel, wx.ID_ANY, bmp, "Select a file containing the reads in .FASTQ (or compressed FASTQ) format."), flag=wx.CENTER, border=0)
sizer1.Add((10, 1), 0, wx.EXPAND)
......@@ -120,7 +120,7 @@ if hasWx:
sizer2 = wx.BoxSizer(wx.HORIZONTAL)
label2 = wx.StaticText(panel, label='Choose the Fastq file for read 2:',size=(330,-1))
sizer2.Add(label2,0,wx.ALIGN_CENTER_VERTICAL,0)
self.picker2 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the .fastq file for read 2', fileMode=wx.OPEN, fileMask='*.fastq;*.fq;*.reads;*.fasta;*.fa;*.fastq.gz', size=(400,30), startDirectory=os.path.dirname(vars.fq2), initialValue=vars.fq2, labelText='', changeCallback=self.OnChanged2)
self.picker2 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the .fastq file for read 2', fileMode=wx.FD_OPEN, fileMask='*.fastq;*.fq;*.reads;*.fasta;*.fa;*.fastq.gz', size=(400,30), startDirectory=os.path.dirname(vars.fq2), initialValue=vars.fq2, labelText='', changeCallback=self.OnChanged2)
sizer2.Add(self.picker2, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
sizer2.Add(TPPIcon(panel, wx.ID_ANY, bmp, "Select a file containing the pair-end reads in .FASTQ (or compressed FASTQ) format. Optional."), flag=wx.CENTER, border=0)
sizer2.Add((10, 1), 0, wx.EXPAND)
......@@ -207,7 +207,7 @@ The Mme1 protocol generally assumes reads do NOT include the primer prefix, and
label0 = wx.StaticText(panel, label='BWA executable:',size=(330,-1))
sizer0.Add(label0,0,wx.ALIGN_CENTER_VERTICAL,0)
self.picker0 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id = wx.ID_ANY, size=(400,30), dialogTitle='Path to BWA', fileMode=wx.OPEN, fileMask='bwa*', startDirectory=os.path.dirname(vars.bwa), initialValue=vars.bwa, labelText='')
self.picker0 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id = wx.ID_ANY, size=(400,30), dialogTitle='Path to BWA', fileMode=wx.FD_OPEN, fileMask='bwa*', startDirectory=os.path.dirname(vars.bwa), initialValue=vars.bwa, labelText='')
sizer0.Add(self.picker0, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
......@@ -235,7 +235,7 @@ The Mme1 protocol generally assumes reads do NOT include the primer prefix, and
self.barseq_select.SetSelection(0)
sizer9.Add(self.barseq_select, proportion=0.5, flag=wx.EXPAND|wx.ALL, border=5) ##
self.picker9 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the Barseq catalog filename', fileMode=wx.OPEN, size=(400,30), startDirectory=os.path.dirname(vars.fq2), initialValue="", labelText='', ) # no need for this: changeCallback=self.OnChanged9 ; initialValue set below ; no file mask
self.picker9 = wx.lib.filebrowsebutton.FileBrowseButton(panel, id=wx.ID_ANY, dialogTitle='Please select the Barseq catalog filename', fileMode=wx.FD_OPEN, size=(400,30), startDirectory=os.path.dirname(vars.fq2), initialValue="", labelText='', ) # no need for this: changeCallback=self.OnChanged9 ; initialValue set below ; no file mask
sizer9.Add(self.picker9, proportion=1, flag=wx.EXPAND|wx.ALL, border=5)
if vars.barseq_catalog_in!=None:
......@@ -306,7 +306,8 @@ The Mme1 protocol generally assumes reads do NOT include the primer prefix, and
#
def OnChangePrimerPrefix(self, event):
self.transposon.SetValue("[Custom]")
#self.transposon.SetValue("[Custom]")
pass
#
......@@ -348,7 +349,7 @@ The Mme1 protocol generally assumes reads do NOT include the primer prefix, and
defaultDir=".",
defaultFile="",
wildcard="*.wig",
style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
style=wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_CHANGE_DIR
)
if dlg.ShowModal() == wx.ID_OK:
paths = dlg.GetPaths()
......
......@@ -233,7 +233,8 @@ def extract_staggered(infile,outfile,vars):
lenADAP = len(ADAPTER2)
#P,Q = 5,10 # 1-based inclusive positions to look for start of Tn prefix
P,Q = 0,15
#P,Q = 0,15
P,Q = 0,50 # relax this, because it has caused problems for various users; shouldn't matter, if prefix is long enough to make random occurences unlikely
if vars.barseq_catalog_out!=None: Q = 100 # relax for barseq
vars.tot_tgtta = 0
......@@ -424,7 +425,9 @@ def template_counts(ref,sam,bcfile,vars):
sites = []
for i in range(len(genome)-1):
if genome[i:i+2].upper()=="TA":
#if genome[i:i+2].upper()=="TA":
if vars.transposon=="Himar1" and genome[i:i+2].upper()!="TA": continue
else:
pos = i+1
h = hits.get(pos,[])
f = filter(lambda x: x[0]=='F',h)
......@@ -460,7 +463,8 @@ def read_counts(ref,sam,vars):
genome = read_genome(ref)
sites = {}
for i in range(len(genome)-1):
if genome[i:i+2]=="TA" or vars.transposon=='Tn5':
#if genome[i:i+2]=="TA" or vars.transposon=='Tn5':
if vars.transposon=='Himar1' and genome[i:i+2]!="TA": continue
pos = i+1
sites[pos] = [pos,0,0,0,0,0,0]
......@@ -980,7 +984,7 @@ def warning(s):
def set_defaults(vars, protocol):
def set_protocol_defaults(vars, protocol):
#protocol = kwargs.get("protocol", "sassetti")
if protocol == "sassetti":
set_sassetti_defaults(vars)
......
......@@ -2,6 +2,6 @@
__all__ = ["transit_tools", "tnseq_tools", "norm_tools", "stat_tools"]
__version__ = "v2.2.1"
__version__ = "v2.3.2"
prefix = "[TRANSIT]"
......@@ -9,23 +9,11 @@ try:
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
from pubsub import pub
import wx.adv
......@@ -60,6 +48,13 @@ def main(*args, **kwargs):
sys.argv.remove("--debug")
kwargs.pop("-debug")
if (not args and 'h' in kwargs):
print "For commandline mode, please use one of the known methods (or see documentation to add a new one):"
for m in all_methods:
print "\t - %s" % m
print "Usage: python %s <method>" % sys.argv[0]
sys.exit(0)
# Check if running in GUI Mode
if not (args or kwargs) and hasWx:
......
......@@ -17,6 +17,10 @@ import hmm
import rankproduct
import gi
import utest
import normalize
import pathway_enrichment #08/22/2018 by Ivan
import anova
import tnseq_stats
methods = {}
methods["example"] = example.ExampleAnalysis()
......@@ -28,16 +32,17 @@ methods["resampling"] = resampling.ResamplingAnalysis()
methods["tn5gaps"] = tn5gaps.Tn5GapsAnalysis()
methods["rankproduct"] = rankproduct.RankProductAnalysis()
methods["utest"] = utest.UTestAnalysis()
methods["gi"] = gi.GIAnalysis()
methods["GI"] = gi.GIAnalysis()
methods["anova"] = anova.AnovaAnalysis()
#methods["mcce"] = mcce.MCCEAnalysis()
#methods["mcce2"] = mcce2.MCCE2Analysis()
#methods["motifhmm"] = motifhmm.MotifHMMAnalysis()
methods["normalize"] = normalize.Normalize()
methods["pathway_enrichment"]=pathway_enrichment.GSEAAnalysis()
methods["tnseq_stats"]=tnseq_stats.TnseqStats()
# EXPORT METHODS
import norm
export_methods = {}
export_methods["norm"] = norm.NormAnalysis()
import scipy
import numpy
import statsmodels.stats.multitest
import time
import sys
import collections
import base
import pytransit
import pytransit.transit_tools as transit_tools
import pytransit.tnseq_tools as tnseq_tools
import pytransit.norm_tools as norm_tools
############# GUI ELEMENTS ##################
short_name = "anova"
long_name = "anova"
short_desc = "Perform Anova analysis"
long_desc = """Perform Anova analysis"""
EOL = "\n"
transposons = ["", ""]
columns = []
class AnovaAnalysis(base.TransitAnalysis):
def __init__(self):
base.TransitAnalysis.__init__(self, short_name, long_name, short_desc, long_desc, transposons, AnovaMethod)
def main():
print("ANOVA example")
class AnovaMethod(base.MultiConditionMethod):
"""
anova
"""
def __init__(self, combined_wig, metadata, annotation, normalization, output_file, ignored_conditions=set()):
base.MultiConditionMethod.__init__(self, short_name, long_name, short_desc, long_desc, combined_wig, metadata, annotation, output_file, normalization=normalization)
self.ignored_conditions = ignored_conditions
@classmethod
def fromargs(self, rawargs):
(args, kwargs) = transit_tools.cleanargs(rawargs)
if (kwargs.get('-help', False) or kwargs.get('h', False)):
print(AnovaMethod.usage_string())
sys.exit(0)
combined_wig = args[0]
annotation = args[1]
metadata = args[2]
output_file = args[3]
normalization = kwargs.get("n", "TTR")
ignored_conditions = set(kwargs.get("-ignore-conditions", "Unknown").split(","))
return self(combined_wig, metadata, annotation, normalization, output_file, ignored_conditions)
def wigs_to_conditions(self, conditionsByFile, filenamesInCombWig):
"""
Returns list of conditions corresponding to given wigfiles.
({FileName: Condition}, [FileName]) -> [Condition]
Condition :: [String]
"""
return [conditionsByFile.get(f, "Unknown") for f in filenamesInCombWig]
def means_by_condition_for_gene(self, sites, conditions, data):
"""
Returns a dictionary of {Condition: Mean} for each condition.
([Site], [Condition]) -> {Condition: Number}
Site :: Number
Condition :: String
"""
wigsByConditions = collections.defaultdict(lambda: [])
for i, c in enumerate(conditions):
wigsByConditions[c].append(i)
return { c: numpy.mean(data[wigIndex][:, sites]) for (c, wigIndex) in wigsByConditions.items() }
def filter_by_conditions_blacklist(self, data, conditions, ignored_conditions):
"""
Filters out wigfiles, with ignored conditions.
([[Wigdata]], [Condition]) -> Tuple([[Wigdata]], [Condition])
"""
d_filtered, cond_filtered = [], [];
for i, c in enumerate(conditions):
if c not in ignored_conditions:
d_filtered.append(data[i])
cond_filtered.append(conditions[i])
return (numpy.array(d_filtered), numpy.array(cond_filtered))
def read_samples_metadata(self, metadata_file):
"""
Filename -> ConditionMap
ConditionMap :: {Filename: Condition}
"""
wigFiles = []
conditionsByFile = {}
headersToRead = ["condition", "filename"]
with open(metadata_file) as mfile:
lines = mfile.readlines()
headIndexes = [i
for h in headersToRead
for i, c in enumerate(lines[0].split())
if c.lower() == h]
for line in lines:
if line[0]=='#': continue
vals = line.split()
[condition, wfile] = vals[headIndexes[0]], vals[headIndexes[1]]
conditionsByFile[wfile] = condition
return conditionsByFile
def means_by_rv(self, data, RvSiteindexesMap, genes, conditions):
"""
Returns Dictionary of mean values by condition
([[Wigdata]], {Rv: SiteIndex}, [Gene], [Condition]) -> {Rv: {Condition: Number}}
Wigdata :: [Number]
SiteIndex :: Number
Gene :: {start, end, rv, gene, strand}
Condition :: String
"""
MeansByRv = {}
for gene in genes:
Rv = gene["rv"]
if len(RvSiteindexesMap[gene["rv"]]) > 0: # skip genes with no TA sites
MeansByRv[Rv] = self.means_by_condition_for_gene(RvSiteindexesMap[Rv], conditions, data)
return MeansByRv
def group_by_condition(self, wigList, conditions):
"""
Returns array of datasets, where each dataset corresponds to one condition.
([[Wigdata]], [Condition]) -> [[DataForCondition]]
Wigdata :: [Number]
Condition :: String
DataForCondition :: [Number]
"""
countsByCondition = collections.defaultdict(lambda: [])
for i, c in enumerate(conditions):
countsByCondition[c].append(wigList[i])
return [numpy.array(v).flatten() for v in countsByCondition.values()]
def run_anova(self, data, genes, MeansByRv, RvSiteindexesMap, conditions):
"""
Runs Anova (grouping data by condition) and returns p and q values
([[Wigdata]], [Gene], {Rv: {Condition: Mean}}, {Rv: [SiteIndex]}, [Condition]) -> Tuple([Number], [Number])
Wigdata :: [Number]
Gene :: {start, end, rv, gene, strand}
Mean :: Number
SiteIndex: Integer
Condition :: String
"""
count = 0
self.progress_range(len(genes))
pvals,Rvs = [],[]
for gene in genes:
count += 1
Rv = gene["rv"]
if Rv in MeansByRv:
countsvec = self.group_by_condition(map(lambda wigData: wigData[RvSiteindexesMap[Rv]], data), conditions)
stat,pval = scipy.stats.f_oneway(*countsvec)
pvals.append(pval)
Rvs.append(Rv)
# Update progress
text = "Running Anova Method... %5.1f%%" % (100.0*count/len(genes))
self.progress_update(text, count)
pvals = numpy.array(pvals)
mask = numpy.isfinite(pvals)
qvals = numpy.full(pvals.shape, numpy.nan)
qvals[mask] = statsmodels.stats.multitest.fdrcorrection(pvals[mask])[1] # BH, alpha=0.05
p,q = {},{}
for i,rv in enumerate(Rvs):
p[rv],q[rv] = pvals[i],qvals[i]
return (p, q)
def Run(self):
self.transit_message("Starting Anova analysis")
start_time = time.time()
self.transit_message("Getting Data")
(sites, data, filenamesInCombWig) = tnseq_tools.read_combined_wig(self.combined_wig)
self.transit_message("Normalizing using: %s" % self.normalization)
(data, factors) = norm_tools.normalize_data(data, self.normalization)
conditions = self.wigs_to_conditions(
self.read_samples_metadata(self.metadata),
filenamesInCombWig)
data, conditions = self.filter_by_conditions_blacklist(data, conditions, self.ignored_conditions)
genes = tnseq_tools.read_genes(self.annotation_path)
TASiteindexMap = {TA: i for i, TA in enumerate(sites)}
RvSiteindexesMap = tnseq_tools.rv_siteindexes_map(genes, TASiteindexMap)
MeansByRv = self.means_by_rv(data, RvSiteindexesMap, genes, conditions)
self.transit_message("Running Anova")
pvals,qvals = self.run_anova(data, genes, MeansByRv, RvSiteindexesMap, conditions)
self.transit_message("Adding File: %s" % (self.output))
file = open(self.output,"w")
conditionsList = list(set(conditions))
vals = "Rv Gene TAs".split() + conditionsList + "pval padj".split()
file.write('\t'.join(vals)+EOL)
for gene in genes:
Rv = gene["rv"]
if Rv in MeansByRv:
vals = ([Rv, gene["gene"], str(len(RvSiteindexesMap[Rv]))] +
["%0.1f" % MeansByRv[Rv][c] for c in conditionsList] +
["%f" % x for x in [pvals[Rv], qvals[Rv]]])
file.write('\t'.join(vals)+EOL)
file.close()
self.transit_message("Finished Anova analysis")
@classmethod
def usage_string(self):
return """python %s anova <combined wig file> <annotation .prot_table> <samples_metadata file> <output file> [Optional Arguments]
Optional Arguments:
-n <string> := Normalization method. Default: -n TTR
--ignore-conditions <cond1,cond2> := Comma seperated list of conditions to ignore, for the analysis. Default --ignore-conditions Unknown
""" % (sys.argv[0])
if __name__ == "__main__":
main()
......@@ -9,26 +9,13 @@ try:
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
from pubsub import pub
import wx.adv
import traceback
import datetime
import pytransit.transit_tools as transit_tools
......@@ -68,10 +55,7 @@ class TransitGUIBase:
def status_message(self, text, time=-1):
#TODO: write docstring
if self.wxobj:
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()
#
......@@ -203,6 +187,26 @@ class AnalysisGUI:
def Enable(self):
self.panel.Enable()
#
def GlobalEnable(self):
pass
#
def GlobalHide(self):
pass
#
def GlobalShow(self):
pass
#
def GlobalDisable(self):
pass
#
def definePanel(self, wxobj):
......@@ -366,30 +370,21 @@ class AnalysisMethod:
data = {"path":path, "type":filetype, "date": datetime.datetime.today().strftime("%B %d, %Y %I:%M%p")}
if self.wxobj:
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 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 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)
......@@ -398,10 +393,7 @@ class AnalysisMethod:
def progress_range(self, count):
#TODO: write docstring
if self.wxobj:
if WX_VERSION > 2:
wx.CallAfter(pub.sendMessage, "progressrange", msg=count)
else:
wx.CallAfter(pub.sendMessage, "progressrange", count)
wx.Yield()
#
......@@ -409,10 +401,7 @@ class AnalysisMethod:
def status_message(self, text, time=-1):
#TODO: write docstring
if self.wxobj:
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()
#
......@@ -512,6 +501,21 @@ class QuadConditionMethod(AnalysisMethod):
self.ignoreCodon = ignoreCodon
self.NTerminus = NTerminus
self.CTerminus = CTerminus
#
class MultiConditionMethod(AnalysisMethod):
'''
Class to be inherited by analysis methods that compare essentiality between multiple conditions (e.g Anova).
'''
def __init__(self, short_name, long_name, short_desc, long_desc, combined_wig, metadata, annotation_path, output, normalization=None, LOESS=False, ignoreCodon=True, wxobj=None):
AnalysisMethod.__init__(self, short_name, long_name, short_desc, long_desc, output,
annotation_path, wxobj)
self.combined_wig = combined_wig
self.metadata = metadata
self.normalization = normalization
self.LOESS = LOESS
self.ignoreCodon = ignoreCodon
#
......
......@@ -8,25 +8,11 @@ try:
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
from pubsub import pub
import os
import time
......
......@@ -8,26 +8,13 @@ try:
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
from pubsub import pub
import wx.adv
import os
import time
import math
......
......@@ -8,26 +8,13 @@ try:
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
from pubsub import pub
import wx.adv
import os
import time
import ntpath
......@@ -56,7 +43,7 @@ long_desc = """Method for determining genetic interactions based on changes in e
NOTE: This method requires 4 groups of datasets. Use the main interface to add datasets for the two strain backgrounds under the first condition. A window will allow you to add the datasets under the second condition.
"""
transposons = ["himar1", "tn5"]
transposons = []
columns = ["Orf","Name","Number of TA Sites","Mean count (Strain A Condition 1)","Mean count (Strain A Condition 2)","Mean count (Strain B Condition 1)","Mean count (Strain B Condition 2)", "Mean logFC (Strain A)", "Mean logFC (Strain B)", "Mean delta logFC","Lower Bound delta logFC","Upper Bound delta logFC", "Prob. of delta-logFC being within ROPE", "Adjusted Probability (BFDR)", "Is HDI outside ROPE?", "Type of Interaction"]
......@@ -419,21 +406,12 @@ if hasWx:
name = transit_tools.basename(fullpath)
(density, meanrd, nzmeanrd, nzmedianrd, maxrd, totalrd, skew, kurtosis) = tnseq_tools.get_wig_stats(fullpath)
if WX_VERSION > 3:
self.list_ctrl.InsertItem(self.index_ctrl, name)
self.list_ctrl.SetItem(self.index_ctrl, 1, "%1.1f" % (totalrd))
self.list_ctrl.SetItem(self.index_ctrl, 2, "%2.1f" % (density*100))
self.list_ctrl.SetItem(self.index_ctrl, 3, "%1.1f" % (meanrd))
self.list_ctrl.SetItem(self.index_ctrl, 4, "%d" % (maxrd))
self.list_ctrl.SetItem(self.index_ctrl, 5, "%s" % (fullpath))
else:
self.list_ctrl.InsertStringItem(self.index_ctrl, name)
self.list_ctrl.SetStringItem(self.index_ctrl, 1, "%1.1f" % (totalrd))
self.list_ctrl.SetStringItem(self.index_ctrl, 2, "%2.1f" % (density*100))
self.list_ctrl.SetStringItem(self.index_ctrl, 3, "%1.1f" % (meanrd))
self.list_ctrl.SetStringItem(self.index_ctrl, 4, "%d" % (maxrd))
self.list_ctrl.SetStringItem(self.index_ctrl, 5, "%s" % (fullpath))
self.list_ctrl.Select(self.index_ctrl)
self.list_ctrl.Select(self.index_ctrl)
self.index_ctrl+=1
......@@ -443,21 +421,12 @@ if hasWx:
name = transit_tools.basename(fullpath)
(density, meanrd, nzmeanrd, nzmedianrd, maxrd, totalrd, skew, kurtosis) = tnseq_tools.get_wig_stats(fullpath)
if WX_VERSION > 3:
self.list_exp.InsertItem(self.index_exp, name)
self.list_exp.SetItem(self.index_exp, 1, "%1.1f" % (totalrd))
self.list_exp.SetItem(self.index_exp, 2, "%2.1f" % (density*100))
self.list_exp.SetItem(self.index_exp, 3, "%1.1f" % (meanrd))
self.list_exp.SetItem(self.index_exp, 4, "%d" % (maxrd))
self.list_exp.SetItem(self.index_exp, 5, "%s" % (fullpath))
else:
self.list_exp.InsertStringItem(self.index_exp, name)
self.list_exp.SetStringItem(self.index_exp, 1, "%1.1f" % (totalrd))
self.list_exp.SetStringItem(self.index_exp, 2, "%2.1f" % (density*100))
self.list_exp.SetStringItem(self.index_exp, 3, "%1.1f" % (meanrd))
self.list_exp.SetStringItem(self.index_exp, 4, "%d" % (maxrd))
self.list_exp.SetStringItem(self.index_exp, 5, "%s" % (fullpath))
self.list_exp.Select(self.index_exp)
self.index_exp+=1
......@@ -517,9 +486,10 @@ class GIMethod(base.QuadConditionMethod):
self.samples = samples
self.includeZeros = includeZeros
self.rope = rope
self.doBFDR = False
self.doFWER = False
self.doBFDR = True # TRI
self.doFWER = True # TRI
self.NTerminus = NTerminus
self.CTerminus = CTerminus
@classmethod
def fromGUI(self, wxobj):
......@@ -620,7 +590,7 @@ class GIMethod(base.QuadConditionMethod):
normalization = kwargs.get("n", "TTR")
samples = int(kwargs.get("s", 10000))
rope = int(kwargs.get("-rope", 0.5))
rope = float(kwargs.get("-rope", 0.5)) # fixed! changed int to float
replicates = kwargs.get("r", "Sum")
includeZeros = kwargs.get("iz", False)
......@@ -680,10 +650,10 @@ class GIMethod(base.QuadConditionMethod):
data[j] = stat_tools.loess_correction(position, data[j])
# Get Gene objects for each condition
G_A1 = tnseq_tools.Genes([], self.annotation_path, data=data[:Na1], position=position)
G_B1 = tnseq_tools.Genes([], self.annotation_path, data=data[Na1:(Na1+Nb1)], position=position)
G_A2 = tnseq_tools.Genes([], self.annotation_path, data=data[(Na1+Nb1):(Na1+Nb1+Na2)], position=position)
G_B2 = tnseq_tools.Genes([], self.annotation_path, data=data[(Na1+Nb1+Na2):], position=position)
G_A1 = tnseq_tools.Genes([], self.annotation_path, data=data[:Na1], position=position,nterm=self.NTerminus,cterm=self.CTerminus)
G_B1 = tnseq_tools.Genes([], self.annotation_path, data=data[Na1:(Na1+Nb1)], position=position,nterm=self.NTerminus,cterm=self.CTerminus)
G_A2 = tnseq_tools.Genes([], self.annotation_path, data=data[(Na1+Nb1):(Na1+Nb1+Na2)], position=position,nterm=self.NTerminus,cterm=self.CTerminus)
G_B2 = tnseq_tools.Genes([], self.annotation_path, data=data[(Na1+Nb1+Na2):], position=position,nterm=self.NTerminus,cterm=self.CTerminus)
means_list_a1 = []
means_list_b1 = []
......
......@@ -8,23 +8,11 @@ try:
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
from pubsub import pub
import wx.adv
......
......@@ -8,26 +8,13 @@ try:
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
from pubsub import pub
import wx.adv
import os
import time
import math
......
......@@ -8,26 +8,13 @@ try:
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
from pubsub import pub
import wx.adv
import os
import time
import math
......
......@@ -8,26 +8,13 @@ try:
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
from pubsub import pub
import wx.adv
import os
import time
import math
......