pax_global_header 0000666 0000000 0000000 00000000064 12536525416 0014523 g ustar 00root root 0000000 0000000 52 comment=e3dc48e8e86242ef54102446aadf6ba466406350
ClonalOrigin-1.0/ 0000775 0000000 0000000 00000000000 12536525416 0013743 5 ustar 00root root 0000000 0000000 ClonalOrigin-1.0/README.md 0000664 0000000 0000000 00000005755 12536525416 0015236 0 ustar 00root root 0000000 0000000 # ClonalOrigin
# Introduction #
Bacteria, unlike us, can reproduce on their own. They do however have mechanisms that transfer DNA between organisms, a process more formally known as recombination. The mechanisms by which recombination takes place have been studied extensively in the laboratory but much remains to be understood concerning how, when and where recombination takes place within natural populations of bacteria and how it helps them to adapt to new environments. ClonalOrigin performs a comparative analysis of the sequences of a sample of bacterial genomes in order to reconstruct the recombination events that have taken place in their ancestry.
ClonalOrigin is described in the following paper:
Didelot X, Lawson D, Darling A, Falush D (2010) Inference of homologous recombination in bacteria using whole genome sequences. Genetics 186 (4), 1435-1449 doi:10.1534/genetics.110.120121 http://www.genetics.org/cgi/content/abstract/genetics.110.120121v1
# Usage #
Instructions for how to download and install ClonalOrigin are available at:
https://github.com/xavierdidelot/ClonalOrigin/wiki/Install
Instructions for how to use ClonalOrigin once installed are available at:
https://github.com/xavierdidelot/ClonalOrigin/wiki/Usage
# Estimating strength of bias in the recombination process #
We define biased recombination in contrast to free recombination where all individuals in the population are equally likely to recombine. There are many factors contributing to recombination being biased rather than free. Laboratory experiments have shown that the recombination process is homology dependent whereby it tends to happen more often between individuals that are less diverged. Furthermore, the geographical and ecological structures observed in many bacterial populations implies a greater opportunity of recombination for pairs of cells that are closely related. Purifying selection may also effectively prevent recombination between distantly related bacteria. All these effects would clearly be hard to disentangle, and here we group them all under the single concept of biased recombination. The strength of this bias is an important factor to take into account in order to understand recombination in bacteria. In particular, this determines how often recombination happens within the diversity of the population under study rather than from other sources.
We have introduced a model for biased recombination which is based on the ClonalOrigin model. We use approximate Bayesian computation and whole genome data to infer the rate of bias in the recombination process in bacteria. The user guide and Matlab code can be downloaded from:
http://www.stats.ox.ac.uk/~ansari/BiasedRecV1.tgz
Full details of the biased recombination model have been published in the following paper:
Ansari MA, Didelot X. Inference of the Properties of the Recombination Process from Whole Bacterial Genomes. Genetics. 2014;196: 253–265. doi:10.1534/genetics.113.157172
http://www.genetics.org/content/early/2013/10/21/genetics.113.157172
ClonalOrigin-1.0/gui/ 0000775 0000000 0000000 00000000000 12536525416 0014527 5 ustar 00root root 0000000 0000000 ClonalOrigin-1.0/gui/coloured.ui 0000664 0000000 0000000 00000010331 12536525416 0016700 0 ustar 00root root 0000000 0000000
Dialog
0
0
414
376
Setup coloured plot
10
330
382
32
QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok
9
40
296
182
10
10
361
16
Double-click nodes on the tree to add groups.
311
80
82
124
-
Move up
-
Move down
-
Remove
-
Colour...
40
240
311
74
-
Show density of:
-
Qt::Vertical
-
Coloured according to:
-
Arrival
true
false
-
Arrival
false
-
Departure
false
-
Departure
true
false
ClonalOrigin-1.0/gui/colouredimpl.cpp 0000664 0000000 0000000 00000004473 12536525416 0017741 0 ustar 00root root 0000000 0000000 #include "colouredimpl.h"
//
ColouredImpl::ColouredImpl( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
setAttribute(Qt::WA_DeleteOnClose);
setupUi(this);
}
//
void ColouredImpl::on_buttonBox_accepted()
{
QStringList * nodes=new QStringList();
QStringList * colors=new QStringList();
for (int i=0;icount();i++) {
QListWidgetItem * item=listWidget->item(i);
nodes->append(item->text());
colors->append(item->textColor().name());
}
if (nodes->size()>0) ((MainWindowImpl*)parent())->doColourPlot(nodes,colors,denDep->isChecked(),colDep->isChecked());
close();
}
void ColouredImpl::on_buttonBox_rejected()
{
close();
}
void ColouredImpl::closeEvent(QCloseEvent * event)
{
event=0;
connect(((MainWindowImpl*)parent()),SIGNAL(wasDbClicked(int,QMouseEvent*)),((MainWindowImpl*)parent()),SLOT(computeAfterDbClick(int,QMouseEvent*)));
destroy();
}
void ColouredImpl::addGroup(int id)
{
QListWidgetItem * item=new QListWidgetItem(QString::number(id));
item->setTextColor(Qt::red);
listWidget->addItem(item);
}
void ColouredImpl::on_colour_clicked()
{
QListWidgetItem * item=listWidget->currentItem();
if (item==NULL) return;
QColor c0=item->textColor();
QColor c=QColorDialog::getColor(c0);
if (!c.isValid()) return;
item->setTextColor(c);
}
void ColouredImpl::on_moveUp_clicked()
{
QListWidgetItem * item=listWidget->currentItem();
if (item==NULL) return;
int c=listWidget->currentRow();
if (c==0) return;
item=listWidget->takeItem(listWidget->currentRow());
listWidget->insertItem(c-1,item);
listWidget->setCurrentRow(c-1);
}
void ColouredImpl::on_moveDown_clicked()
{
QListWidgetItem * item=listWidget->currentItem();
if (item==NULL) return;
int c=listWidget->currentRow();
if (c==listWidget->count()-1) return;
item=listWidget->takeItem(listWidget->currentRow());
listWidget->insertItem(c+1,item);
listWidget->setCurrentRow(c+1);
}
void ColouredImpl::on_remove_clicked()
{
QListWidgetItem * item=listWidget->currentItem();
if (item==NULL) return;
listWidget->takeItem(listWidget->currentRow());
}
void ColouredImpl::on_denArr_clicked()
{
denDep->setChecked(false);
}
void ColouredImpl::on_colArr_clicked()
{
colDep->setChecked(false);
}
void ColouredImpl::on_denDep_clicked()
{
denArr->setChecked(false);
}
void ColouredImpl::on_colDep_clicked()
{
colArr->setChecked(false);
}
ClonalOrigin-1.0/gui/colouredimpl.h 0000664 0000000 0000000 00000001201 12536525416 0017370 0 ustar 00root root 0000000 0000000 #ifndef COLOUREDIMPL_H
#define COLOUREDIMPL_H
//
#include
#include "ui_coloured.h"
#include "mainwindowimpl.h"
//
class ColouredImpl : public QDialog, public Ui::Dialog
{
Q_OBJECT
public:
ColouredImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
private:
void closeEvent(QCloseEvent * event);
private slots:
void on_denArr_clicked();
void on_colArr_clicked();
void on_denDep_clicked();
void on_colDep_clicked();
void on_moveUp_clicked();
void on_moveDown_clicked();
void on_remove_clicked();
void on_colour_clicked();
void addGroup(int id);
void on_buttonBox_accepted();
void on_buttonBox_rejected();
};
#endif
ClonalOrigin-1.0/gui/densityontree.cpp 0000664 0000000 0000000 00000007444 12536525416 0020140 0 ustar 00root root 0000000 0000000 #include "densityontree.h"
//
DensityOnTree::DensityOnTree(Tree * tree,double timeScale)
{
this->timeScale=timeScale;
precision=0.005*tree->getNode(tree->getN()*2-2)->getAge();
this->tree=tree;
int siz=0;
for (int i=0;igetN()*2-2;i++) siz+=floor(tree->getDist(i)/precision);
siz+=max(0.0,floor((timeScale-tree->getNode(tree->getN()*2-2)->getAge())/precision));
d=vector(siz,0.0);
above=0.0;
}
void DensityOnTree::add(int edge,double age,double relcon)
{
int which=0;
int n=tree->getN();
for (int e=0;egetDist(e)/precision);
int end=which;
which+=floor(age/precision);
if (edgegetDist(edge)/precision);if (which>=end) return;}
else
{end+=floor((timeScale-tree->getNode(n*2-2)->getAge())/precision);if (which>=end) {above++;return;};}
if(which>=d.size()) {d[d.size()-1]+=relcon;
}else d[which]+=relcon; //*** See below. There is a danger that something is wrong here because when mapping to a consensus tree sometimes end>d.size....
}
void DensityOnTree::smooth()
{
int n=tree->getN();
vector d2(d.size(),0);
vector count(d.size(),0);
for (int edge=0;edge<=n*2-1;edge++) {
int beg=0;
for (int e=0;egetDist(e)/precision);
int end=beg;
if (edgegetDist(edge)/precision);else end+=floor((timeScale-tree->getNode(n*2-2)->getAge())/precision);
for (int w=beg;w=end) {a-=w+b-end+1;}
for (int k=a;k<=b;k++) if (w+k>=beg && w+kd.size....
}
}
for (unsigned int i=0;i0) d.at(i)=d2.at(i)/count.at(i);//else cout<<"error in smoothing"<*x,vector*y,double scale,QBrush brush)
{
int n=tree->getN();
for (int i=0;igetDist(e)/precision);
for (unsigned int j=0;(i==n*2-2&&jgetNode(i)->getAge())/precision))||(igetDist(i)/precision));j++) {
double beg=x->at(i)-(j+1)*precision/timeScale;
painter->fillRect(QRectF(beg,y->at(i)+0.002*((scale<0)?-1:1),precision/timeScale*1.05,d[which]*scale/n),brush);
which++;
}
}
if (above>0) painter->fillRect(QRectF(0.0,y->at(n+n-2),-0.1,above*scale/n*precision/timeScale*10.0),brush);
}
void DensityOnTree::add2(RecTree *treefrom,int i,bool goingto,double relcon)
{
vector alle;
double distto=0;
if(goingto) alle =treefrom->getAllSampledSeqs(treefrom->getEdge(i)->getEdgeTo());
else alle =treefrom->getAllSampledSeqs(treefrom->getEdge(i)->getEdgeFrom());
vector allaffected=tree->getMinEdgeList(alle);
for(unsigned int j=0;jgetRoot()->getId()) distto=treefrom->getRecEdge(i)->getTimeTo();
else if(treefrom->getRecEdge(i)->getEdgeTo()==treefrom->getRoot()->getId()) {distto = tree->getNode(allaffected[j])->getDist()*0.99;}
else distto=treefrom->getRecEdge(i)->getTimeTo()/ treefrom->getNode(treefrom->getRecEdge(i)->getEdgeTo())->getDist() * tree->getNode(allaffected[j])->getDist();
}else {
if(allaffected[j]==tree->getRoot()->getId()) distto=treefrom->getRecEdge(i)->getTimeFrom();
else if(treefrom->getRecEdge(i)->getEdgeFrom()==treefrom->getRoot()->getId()) {distto = tree->getNode(allaffected[j])->getDist()*0.99;}
else distto=treefrom->getRecEdge(i)->getTimeFrom()/ treefrom->getNode(treefrom->getRecEdge(i)->getEdgeFrom())->getDist() * tree->getNode(allaffected[j])->getDist();
}
add(allaffected[j],distto,relcon/allaffected.size());
}
}
//
ClonalOrigin-1.0/gui/densityontree.h 0000664 0000000 0000000 00000001267 12536525416 0017602 0 ustar 00root root 0000000 0000000 #ifndef DENSITYONTREE_H
#define DENSITYONTREE_H
//
#include "gelmanrubinimpl.h"
//
class DensityOnTree
{
public:
DensityOnTree(Tree*tree,double timeScale);
void display(QPainter * painter,vector*x,vector*y,double scale,QBrush brush);
void add(int edge ,double age,double relcon=1.0);
void smooth();
//inline int maximum(){int max=0;for (unsigned int i=0;itree=tree;}
void add2(RecTree *treefrom,int i,bool goingto,double relcon=1.0);/// d;
double above;
double precision;
double timeScale;
};
#endif
ClonalOrigin-1.0/gui/gelmanrubin.ui 0000664 0000000 0000000 00000013141 12536525416 0017371 0 ustar 00root root 0000000 0000000
GelmanRubin
0
0
604
566
0
0
Gelman-Rubin test
9
9
9
9
6
6
-
0
0
0
0
6
6
-
Export...
-
Qt::Horizontal
QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok
-
0
0
5
4
-
Result of the Gelman-Rubin test:
-
true
0
100
0
100
Test options:
10
20
301
22
Parameters only (fastest)
10
40
301
22
Parameters + Edges (for constant trees)
true
10
60
361
22
Parameters + Pairwise Distances (for varying trees)
10
80
391
22
Parameters + Edges + Pairwise Distance (for fixed topology)
10
100
391
22
Branch lengths only
470
60
111
31
Perform Test
ClonalOrigin-1.0/gui/gelmanrubinimpl.cpp 0000664 0000000 0000000 00000031745 12536525416 0020432 0 ustar 00root root 0000000 0000000 #include "gelmanrubinimpl.h"
//
GelmanRubinImpl::GelmanRubinImpl( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f) {
setupUi(this);
param=NULL;
outputFile=NULL;
out=NULL;
sep=",";
doGR=true;
groupBox->setEnabled(true);
// groupBox->setMinimumSize(QSize(0, 0));
groupBox->setHidden(true);
//connect(pushGo,SIGNAL(wasDbClicked(int,QMouseEvent*)),this,SLOT(computeAfterClick(int,QMouseEv
//QObject::connect(pushGo, SIGNAL(clicked()), auxSignals, SLOT(buttonClicked()));
}
//
void GelmanRubinImpl::compute(ParamQt*param,OutputFile*outputFile,QStringList*others,ostream* out,bool getparams,bool getnumedges,bool getpairwisedists) {
vector< vector< vector > > v;//Store:file x iteration x property
int m=1+others->size();//Number of files
v.push_back(vector< vector >());
outputFile->startOver();
while (outputFile->getIt(param)) {
v[0].push_back(extractInfo(param,false,getparams,getnumedges,getpairwisedists));
}
for (int i=0;isize();i++) {
OutputFile * out2=new OutputFile(QStringList(others->at(i)),false);
v.push_back(vector< vector >());
while (out2->getIt(param)) {
v[i+1].push_back(extractInfo(param,false,getparams,getnumedges,getpairwisedists));
}
}
//Table headers
table->setRowCount(1+v[0][0].size());
table->setColumnCount(m+2);
table->setColumnWidth(0,table->columnWidth(0)*2);
table->setItem(0,0,new QTableWidgetItem(QString("Parameter")));
for (int i=1;i<=m;i++) table->setItem(0,i,new QTableWidgetItem(QString("File ")+QString::number(i)));
table->setItem(0,1+m,new QTableWidgetItem(QString("Gelman-Rubin")));
nameTable(param,getparams,getnumedges,getpairwisedists);
//Table
for (unsigned int whichP=0;whichP > data;
for (int i=0;i());
for (unsigned int j=0;jsetItem(whichP+1,i,new QTableWidgetItem(QString::number(mean)));
}
table->setItem(whichP+1,1+m,new QTableWidgetItem(QString::number(R)));
}
if(out!=NULL){
for(int i=0;irowCount();i++){
for(int j=0;jcolumnCount()-1;j++){
*out<item(i,j)->text().toStdString()<item(i,table->columnCount()-1)->text().toStdString()<size();//Number of files
int iso=param->getTree()->getN();//Number of isolates
QHash > hash;
for (int i=0;isize();i++) {
OutputFile * out2=new OutputFile(QStringList(files->at(i)),false);
int its=0;
while (out2->getIt(param)) {
its++;
for (int ii=iso;iigetTree()->getNode(ii);
QString key(iso,'0');
ParamTreeCons::makeKey(node,&key);
if (!hash.contains(key)) hash[key]=vector(m,0.0);
hash[key][i]++;
}
};
QStringList keys=hash.uniqueKeys();
for (int ii=0;ii > > v;//Store:file x iteration x property
v.push_back(vector< vector >());
QStringList keys=hash.uniqueKeys();
//Average standard deviation of split frequencies
double asdsf=0.0;
int cmp=0;
for (int i=0;isetText(QString("Average standard deviation of split frequencies=")+QString::number(asdsf));
//Table headers
table->setRowCount(keys.size()+1);
table->setColumnCount(m+1);
table->setColumnWidth(0,table->columnWidth(0)*2);
if(out!=NULL) *out<setItem(0,i,new QTableWidgetItem(QString("File ")+QString::number(i)));
if(out!=NULL) *out<<"File "<setItem(i+1,0,new QTableWidgetItem(keys[i]));
//Table
for (int i=0;isetItem(i+1,j+1,new QTableWidgetItem(QString::number(hash[keys[i]][j])));
if(out!=NULL) *out<getTree()->getN();//Number of isolates
if(getparams){
table->setItem(rownumber++,0,new QTableWidgetItem(QString("theta")));
table->setItem(rownumber++,0,new QTableWidgetItem(QString("rho")));
table->setItem(rownumber++,0,new QTableWidgetItem(QString("delta")));
table->setItem(rownumber++,0,new QTableWidgetItem(QString("Num Edges")));
table->setItem(rownumber++,0,new QTableWidgetItem(QString("Likelihood")));
table->setItem(rownumber++,0,new QTableWidgetItem(QString("TMRCA")));
table->setItem(rownumber++,0,new QTableWidgetItem(QString("SumBraLen")));
}
if(getnumedges){
for (int i=0;isetItem(rownumber++,0,new QTableWidgetItem(QString("Edges on branch ")+QString::number(i)));
}
if(getpairwisedists){
for (int i=0;isetItem(rownumber++,0,new QTableWidgetItem(QString("PairwiseDistance")+QString::number(i)+QString("to")+QString::number(j)));
}
}
vector GelmanRubinImpl::extractInfo(ParamQt*p, bool csv,bool getparams,bool getnumedges,bool getpairwisedists) {
vector v;
int ccount=0;
if (csv) ccount=p->countConv();
int iso=p->getTree()->getN();
if(getparams) { for (int whichP=0;whichP<7+ccount;whichP++) {
if (whichP==0) {v.push_back(p->getTheta());continue;}
if (whichP==1) {v.push_back(p->getRho ());continue;}
if (whichP==2) {v.push_back(p->getDelta());continue;}
if (whichP==3) {v.push_back(p->getTree()->numRecEdge());continue;}
if (whichP==4) {v.push_back(p->getLL());continue;}
if (whichP==5) {v.push_back(p->getTree()->getNode(iso+iso-2)->getAge());continue;}
if (whichP==6) {v.push_back(p->getTree()->getTTotal());continue;}
if (whichP>6 && whichP<7+ccount) {v.push_back(p->getConvData(whichP-7));continue;}
} }
if(getnumedges) {for (int whichP=0;whichP<(iso+iso-2);whichP++) {
v.push_back(p->getTree()->numRecEdgeOnBranch(whichP));
}}
if(getpairwisedists) {
vector vt=p->pairwiseDistanceList();
for(unsigned int c1=0;c1 vt;
p->consistentAgeList(&vt);
for(unsigned int c1=0;c1 >*data) {
vector means;
double mean;
unsigned int m=data->size();
unsigned int n=data->at(0).size();
for (unsigned int i=0;iat(i).size()at(i).size();
for (unsigned int i=0;iat(i).at(j);
}
mean/=n;
means.push_back(mean);
}
mean=0.0;
for (unsigned int j=0;jat(j).at(t)-means[j]),2.0);
W=W/m/(n-1.0);
double V=(n-1.0)/n*W+B/n;
return V/W;
}
void GelmanRubinImpl::on_exportButton_clicked() {
QString qstr = QFileDialog::getSaveFileName(this, tr("Save output file"),".","CSV files (*.csv);;All files (*)");
if (qstr==NULL) return;
QFile file(qstr);
if ( !file.open(QIODevice::WriteOnly)) return;
QTextStream ts( &file );
for (int i=0;irowCount();i++)
for (int j=0;jcolumnCount();j++) {
if (table->item(i,j)!=NULL) ts<item(i,j)->text();
if (jcolumnCount()-1) ts<<","; else ts< > v;//Store:iteration x property
int iso=param->getTree()->getN();//Number of isolates
outputfile->startOver();
while (outputfile->getIt(param)) {
v.push_back(extractInfo(param,csv,getparams,getnumedges,getpairwisedists));
}
//Write header
int ccount=0;
if (csv) ccount=param->countConv();
QFile file(*qstr);
if ( !file.open(QIODevice::WriteOnly)) return;
QTextStream ts( &file );
QString sep;
if (csv) sep=",";else sep="\t";
if (csv && getparams) {
ts<<"\"iter\",\"theta\",\"rho\",\"delta\",\"numrecedge\",\"likelihood\",\"TMRCA\",\"SumBraLen\",";
for (int i=0;igetConvName(i).c_str()<< "\"";
if (igetTree()->getN();//Number of isolates
QHash > hash;
//Analyze partitions in the output file
OutputFile * out2=new OutputFile(QStringList(outputfile),false);
int its=0;
while (out2->getIt(param)) {
its++;
for (int ii=iso;iigetTree()->getNode(ii);
QString key(iso,'0');
ParamTreeCons::makeKey(node,&key);
if (!hash.contains(key)) hash[key]=vector(2,0.0);
hash[key][0]++;
}
};
QStringList keys=hash.uniqueKeys();
for (int ii=0;iigetNode(ii);
QString key(iso,'0');
ParamTreeCons::makeKey(node,&key);
if (!hash.contains(key)) hash[key]=vector(2,0.0);
hash[key][1]=1.0;
}
//Calculate stats
keys=hash.uniqueKeys();
double score=0.0;
double efficiency=0.0;double eff2=0.0;
double accuracy=0.0;double acc2=0.0;
for (int ii=0;ii=0.5) efficiency++;};
if (hash[keys[ii]][0]>=0.5) {acc2++;if (hash[keys[ii]][1]==1.0) accuracy ++;};
}
return QString("Score=%1; Efficiency=%2; Accuracy=%3").arg(score).arg(efficiency/eff2).arg(accuracy/acc2);
}
void GelmanRubinImpl::on_buttonBox_accepted() {
if(!doGR) {
bool usecsv=true;
if(sep.compare(",")!=0)usecsv=false;
if(param==NULL) throw("Export not initalised!");
if(radioType1->isChecked()) outputTracer(param,outputFile,&(others[0]),usecsv,true,false,false);
else if(radioType2->isChecked()) outputTracer(param,outputFile,&(others[0]),usecsv,true,true,false);
else if(radioType3->isChecked()) outputTracer(param,outputFile,&(others[0]),usecsv,true,false,true);
else if(radioType4->isChecked()) outputTracer(param,outputFile,&(others[0]),usecsv,true,true,true);
else if(radioType5->isChecked()) outputTracer(param,outputFile,&(others[0]),usecsv,false,false,false);
}
close();
}
void GelmanRubinImpl::on_buttonBox_rejected() {
close();
}
void GelmanRubinImpl::on_pushGo_clicked()
{
if(param==NULL) throw("Gelman Rubin not initalised!");
if(radioType1->isChecked()) compute(param,outputFile,&others,NULL,true,false,false);
else if(radioType2->isChecked()) compute(param,outputFile,&others,NULL,true,true,false);
else if(radioType3->isChecked()) compute(param,outputFile,&others,NULL,true,false,true);
else compute(param,outputFile,&others,NULL,true,true,true);
groupBox->setEnabled(false);
}
ClonalOrigin-1.0/gui/gelmanrubinimpl.h 0000664 0000000 0000000 00000003762 12536525416 0020075 0 ustar 00root root 0000000 0000000 #ifndef GELMANRUBINIMPL_H
#define GELMANRUBINIMPL_H
//
#include "ui_gelmanrubin.h"
#include
#include
#include
#include
#include
#include
#include "paramqt.h"
#include "../warg/src/tree.h"
#include "../warg/src/rectree.h"
#include "../warg/src/param.h"
#include "../warg/src/data.h"
#include "outputfile.h"
#include "paramtreecons.h"
//
using namespace std;
class GelmanRubinImpl : public QDialog, public Ui::GelmanRubin
{
Q_OBJECT
public:
GelmanRubinImpl( QWidget * parent = 0, Qt::WFlags f = 0 );
void compute(ParamQt*param,OutputFile*outputFile,QStringList*others, ostream* out=NULL,bool getparams=true,bool getnumedges=true,bool getpairwisedists=false);
void computeTree(ParamQt*,QStringList*,ostream* out=NULL);
void outputTracer(ParamQt*param,OutputFile*outputfile,QString*qstr,bool csv=false,bool getparams=true,bool getnumedges=true,bool getpairwisedists=false);
static QString compareTrueTree(ParamQt*,QString,QString);
inline void setFiles(ParamQt*param,OutputFile*outputFile,QStringList others){
this->param=param;
this->outputFile=outputFile;
this->others=others;
}
inline void showOptions(){
groupBox->setHidden(false);
}
inline void setExport(){
groupBox->setHidden(false);
table->setHidden(true);
exportButton->setHidden(true);
label->setHidden(true);
pushGo->setHidden(true);
doGR=false;
this->setFixedHeight(170);
this->setWindowTitle(QString("Export"));
}
inline void setSep(string s){sep=s;}
protected:
void nameTable(ParamQt*p,bool getparams,bool getnumedges,bool getpairwisedists);
vector extractInfo(ParamQt*p, bool csv=false,bool getparams=true,bool getnumedges=true,bool getpairwisedists=false);
double test(vector< vector >*data);
ParamQt*param;
OutputFile*outputFile;
QStringList others;
ostream* out;
string sep;
bool doGR;
private slots:
void on_exportButton_clicked();
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_pushGo_clicked();
};
#endif
ClonalOrigin-1.0/gui/gui.cpp 0000664 0000000 0000000 00000016271 12536525416 0016026 0 ustar 00root root 0000000 0000000 #include
#include
#include "mainwindowimpl.h"
#include "../warg/src/rng.h"
#include "../warg/src/mpiutils.h"
#include "mainapplicationdbusadaptor.h"
#include
bool verbose=false;
namespace weakarg
{
//void opt() {};
ProgramOptions& opt() {static ProgramOptions po;return po;}
}
static const char * help=
"\n\
Usage: gui [OPTIONS] \n\
For graphical use, no options are necessary. \n\
To pre-run a limited set of functions, or use batch \n\
mode, the following options can be used.\n\
NOTE: They are processed IN ORDER, so be sure to open\n\
the file before using it, and set output names before\n\
producing the output!\n\
\n\
Options:\n\
-b Batch mode. Perform operations then quit \n\
without displaying the gui.\n\
-o Open the specified input XML file.\n\
-c <:num> \n\
Write a csv file of the main features. If\n\
:num is provided then it changes the variables\n\
in the output (default 2):\n\
:1 - Parameters only\n\
:2 - Parameters + Number of recedges\n\
:3 - Parameters + Clonal Pairwise Distances\n\
:4 - All of the above.\n\
-T Redirect the batch processed output \n\
from stdout to the file specified.\n\
Specify "" to display to the gui.\n\
-t Perform a convergence of trees test \n\
between the open file and the set of \n\
specified files (separated by commas).\n\
-g <:num> Perform a gelman-rubin test \n\
between the open file and the set of \n\
specified files (separated by commas). \n\
takes the same meaning as for -c.\n\
-S Redirect the Score against true tree output \n\
from stdout to the file specified.\n\
Specify "" to display to the gui.\n\
-s Perform a score against true tree test\n\
against the newick-format file specified.\n\
-C Performs a consensus-of-trees either with\n\
the specified cutoff (integer i=0-100) or \n\
an extended consensus if i<0.\n\
-H 0/1/2/3 Extract the heatmap. Pass 0 for no prior correction,\n\
1 for correction in number of std, 2 for correction\n\
measured in proportion or 3 for prior only.\n\
-d 0/1/2/3 Extract the pairwise clonal tree heatmap. Pass 0 for \n\
no prior correction,\n\
1 for correction in number of std, 2 for correction\n\
measured in proportion or 3 for prior only.\n\
-e ::\n\
Extract iterations and thin. is either\n\
either \"thin\" with value \"x\" to thin every\n\
x'th iteration, or \"extract\" with value \"x-y\" to extract\n\
iterations between x and y. The outputfile is after\n\
the final colon.\n\
-E :\n\
Combines the list of output files specified NOT \n\
including the current one, separated by commas, and\n\
outputs to the file after the colon.\n\
-n Start in the display mode without recombination (You must\n\
specify the outputfile with -o).\n\
-h This help message.\n\
\n\
Examples:\n\
\n\
-o test1.xml -t test2.xml -b:\n\
Performs a convergence of tree test between files\n\
test1.xml and test2.xml, printing the results to\n\
stdout and exiting the program.\n\
-o test1.xml -t test2.xml:\n\
As above, but leave the gui window open.\n\
-o test1.xml -T "" -t test2.xml:\n\
As above, but opens the results in the gui \n\
and with the gui window open.\n\
-o test1.xml -t test2.xml,test3.xml -b:\n\
Performs a convergence of tree test between files\n\
test1.xml, test2.xml and test3.xml.\n\
-t test1.xml -o test2.xml -b:\n\
Fails.\n\
";
int main(int argc, char *argv[])
{
srand(time(NULL));
QApplication app(argc, argv);
MainWindowImpl mainwindowimpl;
// register a DBus adaptor for communication with genome browser apps
MainApplicationAdaptor* maa = new MainApplicationAdaptor(&mainwindowimpl);
// connect to D-BUS and register as an object:
QDBusConnection qdbc = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "org.gel.mauve.remote.WargInterface");
qdbc.registerService("org.gel.mauve.remote.WargInterface");
qdbc.registerObject("/weakarg", maa, QDBusConnection::ExportAllContents);
int grmode=2;
int expmode=2;
optind=0;
bool batch=false;
int priorcorrectHM=0;
int priorcorrectPD=0;
int recstart=0;
QString sof("COUT"),tof("COUT"),tmp;
int c;
QStringList ts,ts2;
while ((c = getopt (argc, argv, "c:o:s:d:C:S:T:t:g:be:E:H:hn")) != -1)
switch (c)
{
cout<1){expmode=ts[1].toInt();}mainwindowimpl.on_actionExport_in_CSV_format_activated(ts[0],expmode);break;
case('S'):sof=QString(optarg);break;
case('s'):mainwindowimpl.on_actionScore_against_true_tree_activated(QString(optarg),sof);break;
case('C'):if(atoi(optarg)<0) { mainwindowimpl.on_actionExtended_consensus_of_trees_activated(tof); }else { mainwindowimpl.on_actionMajority_rule_consensus_of_trees_activated(atoi(optarg),tof);}; break;
case('T'):tof=QString(optarg);break;
case('t'):tmp=QString(optarg);ts=tmp.split(",");
mainwindowimpl.on_actionTest_convergence_of_trees_activated(ts,tof);break;
case('g'):tmp=QString(optarg);ts=tmp.split(":");if(ts.size()>1){grmode=ts[1].toInt();}
ts=ts[0].split(",");
mainwindowimpl.on_actionGelman_Rubin_test_activated(ts,tof,grmode);break;
case('H'):priorcorrectHM=atoi(optarg);
mainwindowimpl.on_actionHeat_map_activated(priorcorrectHM,tof);break;
case('d'):priorcorrectPD=atoi(optarg);
mainwindowimpl.on_actionPheat_map_activated(priorcorrectPD,tof);break;
case('e'):tmp=QString(optarg);ts2=tmp.split(":");
if(ts2.size()!=3){cout<<"Wrong arguments: Need to specify :: for -e"< for -e"<=1) {
QStringList qstrs;
for (int i=1;i