Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set burnin and credible set size as percentages #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/beast/app/tools/SATreeTraceAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

public class SATreeTraceAnalysis extends TreeTraceAnalysis {

FrequencySet<String> pairs = new FrequencySet<String>();

public SATreeTraceAnalysis(List<Tree> posteriorTreeList, double burninFraction) {
Expand Down Expand Up @@ -79,7 +78,7 @@ public List<String> getNewickTrees () {
* @return a report string
* @throws Exception
*/
public String toReportString(boolean printCladeFrequencies, boolean printPairs, boolean printFrequencies, boolean printTopologyCredibleSet, boolean isHTML) throws Exception {
public String toReportString(boolean printCladeFrequencies, boolean printPairs, boolean printFrequencies, boolean printTopologyCredibleSet, Double credSetProbability, boolean isHTML) throws Exception {
FrequencySet<String> clades = new FrequencySet<String>();
ArrayList<String> tmp = new ArrayList<String>();

Expand Down Expand Up @@ -168,7 +167,7 @@ public String toReportString(boolean printCladeFrequencies, boolean printPairs,
}

if (printTopologyCredibleSet) {
countTopologies(output);
countTopologies(output, credSetProbability);
}

ps.flush();
Expand Down Expand Up @@ -324,8 +323,9 @@ public FrequencySet<String> countSAFrequencies(boolean print, boolean useRanking
/**
*
*/
public void countTopologies(ResultsOutput output) {
public void countTopologies(ResultsOutput output, Double credSetProbability) {
FrequencySet<String> topologies = new FrequencySet<String>();
topologies.setCredSetProbability(credSetProbability);
List<String> trees;
trees = getNewickTrees(true);

Expand Down
26 changes: 24 additions & 2 deletions src/beast/app/tools/SampledAncestorTreeAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ public class SampledAncestorTreeAnalyser extends beast.core.Runnable {
private Boolean printCladeFrequencies = false;
private Boolean printTopologyCredibleSet = false;
private Boolean toStandardOutput = true;
private Double credibleSetProportion = 0.95;
private Double burninProportion = 0.1;

public SampledAncestorTreeAnalyser() {}
public SampledAncestorTreeAnalyser(@Param(name="file", description="tree file containing set of ancestral ancestor trees") File file,
@Param(name="burnin", description="percentage of trees to be discarded as burn-in", defaultValue="10.0") Double burninPercentage,
@Param(name="printFrequencies", description="show sampled ancestor frequencies in output table", defaultValue="true") Boolean printFrequencies,
@Param(name="printPairs", description="show ancestor-descendant pair frequencies in output table", defaultValue="false") Boolean printPairs,
@Param(name="printCladeFrequencies", description="show sampled ancestor clade frequencies in output table", defaultValue="false") Boolean printCladeFrequencies,
@Param(name="printTopologyCredibleSet", description="show sampled ancestor tree topology frequencies in output table", defaultValue="false") Boolean printTopologyCredibleSet,
@Param(name="credibleSet", description="percent coverage of the credible set (used for printTopologyCredibleSet)", defaultValue="95.0") Double credibleSetPercentage,
@Param(name="toStandardOutput", description="print to standard output", defaultValue="true") Boolean toStdOut) {
this.file = file;
this.burninProportion = burninPercentage / 100.0;
this.printFrequencies = printFrequencies;
this.printPairs = printPairs;
this.printCladeFrequencies = printCladeFrequencies;
this.printTopologyCredibleSet = printTopologyCredibleSet;
this.credibleSetProportion = credibleSetPercentage / 100.0;
this.toStandardOutput = toStdOut;
}

Expand Down Expand Up @@ -87,7 +93,23 @@ public Boolean getPrintTopologyCredibleSet() {
public void setPrintTopologyCredibleSet(Boolean printTopologyCredibleSet) {
this.printTopologyCredibleSet = printTopologyCredibleSet;
}

public Double getBurnin() {
return this.burninProportion * 100.0;
}

public void setBurnin(Double burnin) {
this.burninProportion = burnin / 100.0;
}

public Double getCredibleSet() {
return this.credibleSetProportion * 100.0;
}

public void setCredibleSet(Double credibleSet) {
this.credibleSetProportion = credibleSet / 100.0;
}

public void run() throws Exception {

FileReader reader = null;
Expand All @@ -96,9 +118,9 @@ public void run() throws Exception {
System.out.println("Reading file " + file.getName());
reader = new FileReader(file);
List<Tree> trees = SATreeTraceAnalysis.Utils.getTrees(file);
SATreeTraceAnalysis analysis = new SATreeTraceAnalysis(trees, 0.1);
SATreeTraceAnalysis analysis = new SATreeTraceAnalysis(trees, burninProportion);

String result = analysis.toReportString(printCladeFrequencies, printPairs, printFrequencies, printTopologyCredibleSet, !toStandardOutput);
String result = analysis.toReportString(printCladeFrequencies, printPairs, printFrequencies, printTopologyCredibleSet, credibleSetProportion, !toStandardOutput);

if (toStandardOutput) {
System.out.println(result);
Expand Down