diff --git a/phylonco-lphy/examples/SVS.lphy b/phylonco-lphy/examples/SVS.lphy index 627a6f6..d2e4927 100644 --- a/phylonco-lphy/examples/SVS.lphy +++ b/phylonco-lphy/examples/SVS.lphy @@ -5,25 +5,46 @@ b_exp ~ LogNormal(meanlog=-0.98, sdlog=0.35); N0_exp ~ LogNormal(meanlog=9.2, sdlog=0.2); exponentialPopFunc = exponentialPopFunc(GrowthRate=b_exp, N0=N0_exp); -t50_gom ~ LogNormal(meanlog=4, sdlog=1.2); +t50_gom ~ LogNormal(meanlog=4, sdlog=0.2); b_gom ~ LogNormal(meanlog=-0.98, sdlog=0.35); NInf_gomp ~ LogNormal(meanlog=9.2, sdlog=0.12); gompertzPopFunc = gompertzPopFunc_t50(NInfinity=NInf_gomp, t50=t50_gom, b=b_gom); -t50_log ~ LogNormal(meanlog=4, sdlog=1.2); +t50_log ~ LogNormal(meanlog=4, sdlog=0.2); b_log ~ LogNormal(meanlog=-0.98, sdlog=0.35); Ninf_log ~ LogNormal(meanlog=9.2, sdlog=0.12); logisticPopFunc = logisticPopFunc(t50=t50_log, nCarryingCapacity=Ninf_log, b=b_log); -models = [constantPopFunc, exponentialPopFunc, logisticPopFunc, gompertzPopFunc]; +tau_expansion ~ LogNormal(meanlog=4.0, sdlog=0.7); +r_expansion ~ LogNormal(meanlog=-3.0, sdlog=1.0); +NC_expansion ~ LogNormal(meanlog=8.0, sdlog=0.7); +N0_expansion ~ LogNormal(meanlog=5.15, sdlog=0.7); +expansionPopFunc = expansionPopFunc(tau=tau_expansion, N0=N0_expansion, r=r_expansion, NC=NC_expansion); + +models = [constantPopFunc, exponentialPopFunc, logisticPopFunc, gompertzPopFunc, expansionPopFunc]; I ~ UniformDiscrete(lower=0, upper=length(models)-1); SVSmodel = stochasticVariableSelection(indicator=I, models=models); tree ~CoalescentPopFunc(n=40, popFunc=SVSmodel); -D ~ PhyloCTMC(L=2000, Q=jukesCantor(),mu=0.01, tree=tree); +κ ~ LogNormal(meanlog=1.0, sdlog=0.5); +π ~ Dirichlet(conc=[2.0,2.0,2.0,2.0]); +D ~ PhyloCTMC(L=2000, Q=hky(kappa=κ, freq=π), mu=0.00079, tree=tree); height = tree.rootAge(); length = tree.treeLength(); + + + + + + + + + + + + + //π ~ Dirichlet(conc=[30.0, 3.0, 3.0, 3.0, 3.0, 30.0, 3.0, 3.0, 3.0, 3.0, 30.0, 3.0, 3.0, 3.0, 3.0, 30.0]); //rates ~ Dirichlet(conc=[1.0, 2.0, 1.0, 1.0, 2.0, 1.0]); //Q = gt16(rates=rates, freq=π); diff --git a/phylonco-lphy/examples/expansionCoal.lphy b/phylonco-lphy/examples/expansionCoal.lphy index 3918205..60c1170 100644 --- a/phylonco-lphy/examples/expansionCoal.lphy +++ b/phylonco-lphy/examples/expansionCoal.lphy @@ -1,8 +1,8 @@ model { -tau ~ LogNormal(meanlog=1.0, sdlog=0.2); -r ~ LogNormal(meanlog=-0.95, sdlog=0.2); -NC ~ LogNormal(meanlog=6.0, sdlog=0.2); -N0 ~ LogNormal(meanlog=0.15, sdlog=0.2); +tau ~ LogNormal(meanlog=4.0, sdlog=0.7); +r ~ LogNormal(meanlog=-3.0, sdlog=0.5); +NC ~ LogNormal(meanlog=8.0, sdlog=0.7); +N0 ~ LogNormal(meanlog=5.15, sdlog=0.7); expansionPopFunc = expansionPopFunc(tau=tau, N0=N0, r=r, NC=NC); tree ~CoalescentPopFunc(n=40, popFunc=expansionPopFunc); D ~ PhyloCTMC(L=1000, Q=jukesCantor(),mu=0.01, tree=tree); @@ -10,6 +10,9 @@ height = tree.rootAge(); length = tree.treeLength(); } + + + tau ~ LogNormal(meanlog=1.0, sdlog=0.2); r ~ LogNormal(meanlog=-0.95, sdlog=0.2); NC ~ LogNormal(meanlog=6.0, sdlog=0.2); diff --git a/phylonco-lphy/examples/gomp_f0_jc69.lphy b/phylonco-lphy/examples/gomp_f0_jc69.lphy index c6302e5..4f8db3d 100644 --- a/phylonco-lphy/examples/gomp_f0_jc69.lphy +++ b/phylonco-lphy/examples/gomp_f0_jc69.lphy @@ -9,4 +9,5 @@ model { tree ~ CoalescentPopFunc(n=40, popFunc=gompertzPopFunc); D ~ PhyloCTMC(L=L, Q=jukesCantor(), mu=0.01, tree=tree); //height = tree.rootAge(); -} \ No newline at end of file +} + diff --git a/phylonco-lphy/examples/gomp_t50_gt16.lphy b/phylonco-lphy/examples/gomp_t50_gt16.lphy index f16465a..52d972a 100644 --- a/phylonco-lphy/examples/gomp_t50_gt16.lphy +++ b/phylonco-lphy/examples/gomp_t50_gt16.lphy @@ -6,9 +6,9 @@ model { rates ~ Dirichlet(conc=[1.0, 2.0, 1.0, 1.0, 2.0, 1.0]); Q = gt16(rates=rates, freq=π); -t50 ~ LogNormal(meanlog=0.3, sdlog=0.1); -b ~ LogNormal(meanlog=2, sdlog=0.5); -NInfinity ~ LogNormal(meanlog=4.5, sdlog=0.5); +t50 ~ LogNormal(meanlog=4, sdlog=1.2); +b ~ LogNormal(meanlog=-0.98, sdlog=0.35); +NInfinity ~ LogNormal(meanlog=9.2, sdlog=0.12); gompertzPopFunc = gompertzPopFunc_t50(NInfinity=NInfinity,t50=t50, b=b); ψ ~ CoalescentPopFunc(n=40, popFunc=gompertzPopFunc); @@ -18,4 +18,6 @@ delta ~ Beta(alpha=1.5, beta=4.5); E ~ GT16ErrorModel(delta=delta, epsilon=epsilon, alignment=A); D = unphase(alignment=E); height = ψ.rootAge(); -} \ No newline at end of file +} + + diff --git a/phylonco-lphy/examples/gomp_t50_jc69.lphy b/phylonco-lphy/examples/gomp_t50_jc69.lphy index aa53250..419767f 100644 --- a/phylonco-lphy/examples/gomp_t50_jc69.lphy +++ b/phylonco-lphy/examples/gomp_t50_jc69.lphy @@ -2,13 +2,23 @@ data { L = 1000; } model { - t50 ~ LogNormal(meanlog=0.3, sdlog=0.1); - b ~ LogNormal(meanlog=2, sdlog=0.5); - NInfinity ~ LogNormal(meanlog=4.5, sdlog=0.5); + t50 =8.9; + b =0.226; + NInfinity =150.0; gompertzPopFunc = gompertzPopFunc_t50(NInfinity=NInfinity,t50=t50, b=b); - //n0 = gompertzPopFunc.getN0(); - //f0=n0/NInfinity; tree ~ CoalescentPopFunc(n=40, popFunc=gompertzPopFunc); D ~ PhyloCTMC(tree=tree, L=L, Q=jukesCantor(), mu=1e-2); height = tree.rootAge(); -} \ No newline at end of file + length = tree.treeLength(); +} + + +t50 ~ LogNormal(meanlog=4.0, sdlog=0.5); + b ~ LogNormal(meanlog=-0.98, sdlog=0.5); + NInfinity ~ LogNormal(meanlog=9.2, sdlog=1.7); + + + //n0 = gompertzPopFunc.getN0(); + //f0=n0/NInfinity; + + b ~ LogNormal(meanlog=0.4, sdlog=0.35); \ No newline at end of file diff --git a/phylonco-lphybeast/src/main/java/phylonco/lphybeast/spi/LBPhylonco.java b/phylonco-lphybeast/src/main/java/phylonco/lphybeast/spi/LBPhylonco.java index 1c8b4ce..f7040ff 100644 --- a/phylonco-lphybeast/src/main/java/phylonco/lphybeast/spi/LBPhylonco.java +++ b/phylonco-lphybeast/src/main/java/phylonco/lphybeast/spi/LBPhylonco.java @@ -77,7 +77,7 @@ public List> getExcludedGenerator() { SampleBranch.class, SubstituteClade.class, SubsampledTree.class, LabelClade.class, MRCA.class, PopulationFunctionCoalescent.class, - SVSFunction.class, + SVSPopulationFunction.class, GompertzPopulationFunction_f0.class, GompertzPopulationFunction_t50.class, ExponentialPopulationFunction.class, @@ -90,7 +90,7 @@ public List> getExcludedGenerator() { @Override public List getExcludedValueType() { return Arrays.asList(TimeTreeNode.class, - SVSPopulationFunction.class); + SVSPopulation.class); } } diff --git a/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/generators/PopFuncCoalescentToBEAST.java b/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/generators/PopFuncCoalescentToBEAST.java index 66e1755..ca76c7d 100644 --- a/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/generators/PopFuncCoalescentToBEAST.java +++ b/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/generators/PopFuncCoalescentToBEAST.java @@ -4,6 +4,7 @@ import beast.base.evolution.tree.TreeIntervals; import lphy.base.evolution.coalescent.PopulationFunction; import lphy.base.evolution.coalescent.PopulationFunctionCoalescent; +import lphy.base.evolution.coalescent.populationmodel.SVSPopulation; import lphy.base.evolution.coalescent.populationmodel.SVSPopulationFunction; import lphy.core.model.Value; import lphybeast.BEASTContext; @@ -29,7 +30,7 @@ public beast.base.evolution.tree.coalescent.Coalescent generatorToBEAST(Populati beast.base.evolution.tree.coalescent.PopulationFunction populationFunction; - if (beastObj instanceof SVSPopulationFunction) { + if (beastObj instanceof SVSPopulation) { populationFunction = convertSVSPopulationFunction((SVSPopulationFunction) beastObj, context); } else if (beastObj instanceof beast.base.evolution.tree.coalescent.PopulationFunction) { populationFunction = (beast.base.evolution.tree.coalescent.PopulationFunction) beastObj; @@ -58,7 +59,7 @@ public beast.base.evolution.tree.coalescent.Coalescent generatorToBEAST(Populati } private beast.base.evolution.tree.coalescent.PopulationFunction convertSVSPopulationFunction(SVSPopulationFunction svsPopFunc, BEASTContext context) { - PopulationFunction model = svsPopFunc.getModel(); + PopulationFunction model = (PopulationFunction) svsPopFunc.getModels(); Value modelValue = new Value<>(model, null); Object beastObj = context.getBEASTObject(modelValue); diff --git a/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/values/SVSPopulationFunctionToBEAST.java b/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/values/SVSPopulationFunctionToBEAST.java index a0f4cbc..7e5a64d 100644 --- a/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/values/SVSPopulationFunctionToBEAST.java +++ b/phylonco-lphybeast/src/main/java/phylonco/lphybeast/tobeast/values/SVSPopulationFunctionToBEAST.java @@ -2,7 +2,7 @@ import beast.base.inference.parameter.IntegerParameter; import lphy.base.evolution.coalescent.PopulationFunction; -import lphy.base.evolution.coalescent.populationmodel.SVSFunction; +import lphy.base.evolution.coalescent.populationmodel.SVSPopulation; import lphy.base.evolution.coalescent.populationmodel.SVSPopulationFunction; import lphy.core.model.GraphicalModelNode; import lphy.core.model.Value; @@ -13,14 +13,14 @@ import java.util.ArrayList; -public class SVSPopulationFunctionToBEAST implements ValueToBEAST { +public class SVSPopulationFunctionToBEAST implements ValueToBEAST { @Override - public StochasticVariableSelection valueToBEAST(Value lphyPopFuncVal, BEASTContext context) { + public StochasticVariableSelection valueToBEAST(Value lphyPopFuncVal, BEASTContext context) { StochasticVariableSelection beastPopFunc = new StochasticVariableSelection(); - SVSFunction gen = (SVSFunction) lphyPopFuncVal.getGenerator(); + SVSPopulationFunction gen = (SVSPopulationFunction) lphyPopFuncVal.getGenerator(); IntegerParameter indicatorParam = context.getAsIntegerParameter(gen.getIndicator()); @@ -68,7 +68,7 @@ public StochasticVariableSelection valueToBEAST(Value lph @Override public Class getValueClass() { - return SVSPopulationFunction.class; + return SVSPopulation.class; } @Override