1 /* 2 * consensus.h 3 * 4 * 5 * Part of TREE-PUZZLE 5.2 (July 2004) 6 * 7 * (c) 2003-2004 by Heiko A. Schmidt, Korbinian Strimmer, and Arndt von Haeseler 8 * (c) 1999-2003 by Heiko A. Schmidt, Korbinian Strimmer, 9 * M. Vingron, and Arndt von Haeseler 10 * (c) 1995-1999 by Korbinian Strimmer and Arndt von Haeseler 11 * 12 * All parts of the source except where indicated are distributed under 13 * the GNU public licence. See http://www.opensource.org for details. 14 * 15 * ($Id$) 16 * 17 */ 18 19 20 #ifndef CONSENSUS_H 21 #define CONSENSUS_H 22 23 #include "puzzle.h" 24 #include "util.h" 25 26 typedef struct { 27 uli fullres_pro; 28 uli fullres_con; 29 uli partres_pro; 30 uli partres_con; 31 uli unres; 32 uli missing; 33 uli qsum; 34 } qsupportarr_t; 35 36 EXTERN cmatrix biparts; /* bipartitions of tree of current puzzling step */ 37 EXTERN cmatrix consbiparts; /* bipartitions of majority rule consensus tree */ 38 39 EXTERN int xsize; /* depth of consensus tree picture */ 40 EXTERN ivector consconfid; /* confidence values of majority rule consensus tree */ 41 EXTERN ivector conssizes; /* partition sizes of majority rule consensus tree */ 42 EXTERN ivector xcor; /* x-coordinates of consensus tree nodes */ 43 EXTERN ivector ycor; /* y-coordinates of consensus tree nodes */ 44 EXTERN ivector ycormax; /* maximal y-coordinates of consensus tree nodes */ 45 EXTERN ivector ycormin; /* minimal y-coordinates of consensus tree nodes */ 46 47 /* splits for consensus */ 48 EXTERN int splitlength; /* length of one entry in splitpatterns */ 49 EXTERN uli maxbiparts; /* memory reserved for maxbiparts bipartitions */ 50 EXTERN uli numbiparts; /* number of different bipartitions */ 51 52 EXTERN int *splitsizes; /* size of all different splits of all trees */ 53 EXTERN uli *splitcomptemp; /* temp variable to compress bipartitions coding */ 54 EXTERN uli *splitfreqs; /* frequencies of different splits of all trees */ 55 EXTERN uli *splitpatterns; /* all different splits of all trees */ 56 57 EXTERN qsupportarr_t *qsupportarr; /* quartet support values per split */ 58 59 EXTERN int consincluded; /* number of included biparts in the consensus tree */ 60 EXTERN int consfifty; /* number of biparts >= 50% */ 61 EXTERN int conscongruent; /* number of first incongruent bipart */ 62 63 /******************************************************************************/ 64 /* functions for computing the consensus tree */ 65 /******************************************************************************/ 66 67 /* prepare for consensus tree analysis */ 68 void initconsensus(); 69 70 /* recursive function to get bipartitions */ 71 /* traversal should be optimazable (HAS) */ 72 void makepart_trueID(int i, /* */ 73 int curribrnch, /* in: current branch in traversal */ 74 ONEEDGE *edge, /* in: tree topology */ 75 int *edgeofleaf, /* in: ext. edge list */ 76 int *trueID, /* in: permutation list */ 77 cmatrix biparts, /* out: split strings, edge by edge */ 78 int Maxspc); /* in: number of species in tree */ 79 80 /* compute bipartitions of current puzzling step tree */ 81 void computebiparts(ONEEDGE *edge, /* in: tree topology */ 82 int *edgeofleaf, /* in: ext. edge list */ 83 int psteprootleaf, /* virtual root from pstep */ 84 cmatrix biparts, /* out: splits */ 85 int outgroup, /* in: outgroup of tree */ 86 int Maxspc); /* in: number of taxa in tree */ 87 88 /* print out the bipartition n of all different splitpatterns */ 89 void fprintfsplit(FILE *fp, /* outputfile stream */ 90 uli n, /* split number */ 91 uli *splitpatterns, /* splits */ 92 int splitlength, /* number of ulis per split */ 93 int Maxspc); /* number of taxa */ 94 95 /* make new entries for new different bipartitions and count frequencies */ 96 /* internal use: splitcomptemp */ 97 void makenewsplitentries(cmatrix bip, /* in: split string vector */ 98 int numspl, /* in: no. of new splits */ 99 uli **in_splitpatterns,/* io: known compr splits */ 100 int **in_splitsizes, /* io: kn. split sizes: '.'*/ 101 uli **in_splitfreqs, /* io: kn. split frequences*/ 102 uli *in_numbiparts, /* io: no. of splits so far*/ 103 uli *in_maxbiparts, /* io: reserved memory */ 104 int Maxspc); /* in: no. of species */ 105 106 /***************************************************************************/ 107 108 /* copy bipartition n of all different splitpatterns to consbiparts[k] */ 109 void copysplit(uli n, uli *splitpatterns, int k, cmatrix consbipartsvec); 110 111 /* <consbipartsvec> and the quartet topologies from the ML step. Values are */ 112 /* stored in <qsupparr[splitnum]> */ 113 /* missing parameter: quartetinfo */ 114 void quartsupport(int splitnum, cmatrix consbipartsvec, qsupportarr_t *qsupparr); 115 116 /* compute majority rule consensus tree */ 117 void makeconsensus(uli maxnumtrees, int qsupp_optn); 118 119 /* write node (writeconsensustree) */ 120 /* missing: column */ 121 void writenode(FILE *treefile, /* in: output stream */ 122 int node, /* current node */ 123 int qsupp_optn, /* 'print quartet support' flag */ 124 qsupportarr_t *qsupparr, /* quartet support values */ 125 int *column); /* current line position */ 126 127 /* write consensus tree */ 128 void writeconsensustree(FILE *treefile, /* in: output stream */ 129 int qsupp_optn, /* 'print quartsupp' flag */ 130 qsupportarr_t *qsupparr); /* quartet support values */ 131 132 /* establish node coordinates (plotconsensustree) */ 133 void nodecoordinates(int node); 134 135 /* drawnode (plotconsensustree) */ 136 void drawnode(int node, int xold); 137 138 /* plot consensus tree */ 139 void plotconsensustree(FILE *plotfp); 140 141 142 #endif /* CONSENSUS_H */ 143 144