| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evomodel.coalescent; |
| 27 |
|
| 28 |
import dr.evolution.coalescent.DemographicFunction; |
| 29 |
import dr.evolution.coalescent.ExpConstExpDemographic; |
| 30 |
import dr.evomodelxml.coalescent.ExpConstExpDemographicModelParser; |
| 31 |
import dr.inference.model.Parameter; |
| 32 |
import dr.util.Author; |
| 33 |
import dr.util.Citable; |
| 34 |
import dr.util.Citation; |
| 35 |
|
| 36 |
import java.util.Collections; |
| 37 |
import java.util.List; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public class ExpConstExpDemographicModel extends DemographicModel implements Citable { |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public ExpConstExpDemographicModel( |
| 56 |
Parameter N0Parameter, |
| 57 |
Parameter N1Parameter, |
| 58 |
Parameter growthRateParameter, |
| 59 |
Parameter timeParameter, |
| 60 |
Parameter relTimeParameter, |
| 61 |
Type units) { |
| 62 |
|
| 63 |
this(ExpConstExpDemographicModelParser.EXP_CONST_EXP_MODEL, N0Parameter, N1Parameter, growthRateParameter, timeParameter, relTimeParameter, units); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public ExpConstExpDemographicModel(String name, Parameter N0Parameter, Parameter N1Parameter, Parameter growthRateParameter, Parameter timeParameter, Parameter relTimeParameter, Type units) { |
| 70 |
|
| 71 |
super(name); |
| 72 |
|
| 73 |
expConstExp = new ExpConstExpDemographic(units); |
| 74 |
|
| 75 |
this.N0Parameter = N0Parameter; |
| 76 |
addVariable(N0Parameter); |
| 77 |
N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 78 |
|
| 79 |
this.N1Parameter = N1Parameter; |
| 80 |
addVariable(N1Parameter); |
| 81 |
N1Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 82 |
|
| 83 |
this.growthRateParameter = growthRateParameter; |
| 84 |
addVariable(growthRateParameter); |
| 85 |
growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.MIN_VALUE, 1)); |
| 86 |
|
| 87 |
this.timeParameter = timeParameter; |
| 88 |
addVariable(timeParameter); |
| 89 |
timeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.MIN_VALUE, 1)); |
| 90 |
|
| 91 |
this.relTimeParameter = relTimeParameter; |
| 92 |
addVariable(relTimeParameter); |
| 93 |
relTimeParameter.addBounds(new Parameter.DefaultBounds(1.0, Double.MIN_VALUE, 1)); |
| 94 |
|
| 95 |
setUnits(units); |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public DemographicFunction getDemographicFunction() { |
| 102 |
|
| 103 |
expConstExp.setN0(N0Parameter.getParameterValue(0)); |
| 104 |
|
| 105 |
double relTime = relTimeParameter.getParameterValue(0); |
| 106 |
double time2 = timeParameter.getParameterValue(0); |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
double timeInModernGrowthPhase = time2 * relTime; |
| 113 |
|
| 114 |
double r = -Math.log(N1Parameter.getParameterValue(0)) / timeInModernGrowthPhase; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
expConstExp.setGrowthRate(r); |
| 123 |
expConstExp.setGrowthRate2(growthRateParameter.getParameterValue(0)); |
| 124 |
|
| 125 |
expConstExp.setTime1(timeInModernGrowthPhase); |
| 126 |
expConstExp.setPlateauTime(time2 - timeInModernGrowthPhase); |
| 127 |
|
| 128 |
return expConstExp; |
| 129 |
} |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
Parameter N0Parameter = null; |
| 136 |
Parameter N1Parameter = null; |
| 137 |
Parameter growthRateParameter = null; |
| 138 |
Parameter timeParameter = null; |
| 139 |
Parameter relTimeParameter = null; |
| 140 |
ExpConstExpDemographic expConstExp = null; |
| 141 |
|
| 142 |
@Override |
| 143 |
public Citation.Category getCategory() { |
| 144 |
return Citation.Category.TREE_PRIORS; |
| 145 |
} |
| 146 |
|
| 147 |
@Override |
| 148 |
public String getDescription() { |
| 149 |
return "Exponential-Constant-Exponential Coalescent"; |
| 150 |
} |
| 151 |
|
| 152 |
@Override |
| 153 |
public List<Citation> getCitations() { |
| 154 |
return Collections.singletonList(CITATION); |
| 155 |
} |
| 156 |
|
| 157 |
public static Citation CITATION = new Citation( |
| 158 |
new Author[]{ |
| 159 |
new Author("OG", "Pybus"), |
| 160 |
new Author("A", "Rambaut") |
| 161 |
}, |
| 162 |
"GENIE: estimating demographic history from molecular phylogenies", |
| 163 |
2001, |
| 164 |
"Bioinformatics", |
| 165 |
18, 1404, 1405 |
| 166 |
); |
| 167 |
} |