Search in sources :

Example 1 with TreeLikelihood

use of beast.evolution.likelihood.TreeLikelihood in project beast2 by CompEvol.

the class TreeLikelihoodTest method aminoacidModelTestI.

void aminoacidModelTestI(SubstitutionModel substModel, double expectedValue) throws Exception {
    Alignment data = BEASTTestCase.getAminoAcidAlignment();
    Tree tree = BEASTTestCase.getAminoAcidTree(data);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", substModel, "proportionInvariant", "0.2");
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(expectedValue, logP, BEASTTestCase.PRECISION);
}
Also used : Alignment(beast.evolution.alignment.Alignment) BeagleTreeLikelihood(beast.evolution.likelihood.BeagleTreeLikelihood) TreeLikelihood(beast.evolution.likelihood.TreeLikelihood) Tree(beast.evolution.tree.Tree) SiteModel(beast.evolution.sitemodel.SiteModel)

Example 2 with TreeLikelihood

use of beast.evolution.likelihood.TreeLikelihood in project beast2 by CompEvol.

the class TreeLikelihoodTest method testHKY85ILikelihood.

@Test
public void testHKY85ILikelihood() throws Exception {
    // Set up HKY85+I model: estimated freqs, kappa = 38.564672, 0 gamma categories, prop invariant = 0.701211
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);
    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);
    HKY hky = new HKY();
    hky.initByName("kappa", "38.564672", "frequencies", freqs);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "shape", "0.137064", "proportionInvariant", "0.701211", "substModel", hky);
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.912401996943, BEASTTestCase.PRECISION);
    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.912401996943, BEASTTestCase.PRECISION);
}
Also used : Alignment(beast.evolution.alignment.Alignment) HKY(beast.evolution.substitutionmodel.HKY) BeagleTreeLikelihood(beast.evolution.likelihood.BeagleTreeLikelihood) TreeLikelihood(beast.evolution.likelihood.TreeLikelihood) Tree(beast.evolution.tree.Tree) SiteModel(beast.evolution.sitemodel.SiteModel) Frequencies(beast.evolution.substitutionmodel.Frequencies) UncertainAlignmentTest(test.beast.evolution.alignment.UncertainAlignmentTest) Test(org.junit.Test)

Example 3 with TreeLikelihood

use of beast.evolution.likelihood.TreeLikelihood in project beast2 by CompEvol.

the class TreeLikelihoodTest method aminoacidModelTestIG.

void aminoacidModelTestIG(SubstitutionModel substModel, double expectedValue) throws Exception {
    Alignment data = BEASTTestCase.getAminoAcidAlignment();
    Tree tree = BEASTTestCase.getAminoAcidTree(data);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", substModel, "gammaCategoryCount", 4, "shape", "0.15", "proportionInvariant", "0.2");
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(expectedValue, logP, BEASTTestCase.PRECISION);
}
Also used : Alignment(beast.evolution.alignment.Alignment) BeagleTreeLikelihood(beast.evolution.likelihood.BeagleTreeLikelihood) TreeLikelihood(beast.evolution.likelihood.TreeLikelihood) Tree(beast.evolution.tree.Tree) SiteModel(beast.evolution.sitemodel.SiteModel)

Example 4 with TreeLikelihood

use of beast.evolution.likelihood.TreeLikelihood in project beast2 by CompEvol.

the class TreeLikelihoodTest method testHKY85GLikelihood.

@Test
public void testHKY85GLikelihood() throws Exception {
    // Set up HKY85+G model: estimated freqs, kappa = 38.82974, 4 gamma categories, shape = 0.137064
    Alignment data = BEASTTestCase.getAlignment();
    Tree tree = BEASTTestCase.getTree(data);
    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data);
    HKY hky = new HKY();
    hky.initByName("kappa", "38.82974", "frequencies", freqs);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 4, "shape", "0.137064", "proportionInvariant", "0.0", "substModel", hky);
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    System.err.println(logP - -1789.7593576610134);
    assertEquals(logP, -1789.7593576610134, BEASTTestCase.PRECISION);
    likelihood.initByName("useAmbiguities", true, "data", data, "tree", tree, "siteModel", siteModel);
    logP = likelihood.calculateLogP();
    assertEquals(logP, -1789.7593576610134, BEASTTestCase.PRECISION);
}
Also used : Alignment(beast.evolution.alignment.Alignment) HKY(beast.evolution.substitutionmodel.HKY) BeagleTreeLikelihood(beast.evolution.likelihood.BeagleTreeLikelihood) TreeLikelihood(beast.evolution.likelihood.TreeLikelihood) Tree(beast.evolution.tree.Tree) SiteModel(beast.evolution.sitemodel.SiteModel) Frequencies(beast.evolution.substitutionmodel.Frequencies) UncertainAlignmentTest(test.beast.evolution.alignment.UncertainAlignmentTest) Test(org.junit.Test)

Example 5 with TreeLikelihood

use of beast.evolution.likelihood.TreeLikelihood in project beast2 by CompEvol.

the class TreeLikelihoodTest method aminoacidModelTest.

void aminoacidModelTest(SubstitutionModel substModel, double expectedValue) throws Exception {
    Alignment data = BEASTTestCase.getAminoAcidAlignment();
    Tree tree = BEASTTestCase.getAminoAcidTree(data);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", substModel);
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    assertEquals(expectedValue, logP, BEASTTestCase.PRECISION);
}
Also used : Alignment(beast.evolution.alignment.Alignment) BeagleTreeLikelihood(beast.evolution.likelihood.BeagleTreeLikelihood) TreeLikelihood(beast.evolution.likelihood.TreeLikelihood) Tree(beast.evolution.tree.Tree) SiteModel(beast.evolution.sitemodel.SiteModel)

Aggregations

TreeLikelihood (beast.evolution.likelihood.TreeLikelihood)24 Alignment (beast.evolution.alignment.Alignment)22 SiteModel (beast.evolution.sitemodel.SiteModel)22 Tree (beast.evolution.tree.Tree)22 BeagleTreeLikelihood (beast.evolution.likelihood.BeagleTreeLikelihood)20 Test (org.junit.Test)17 UncertainAlignmentTest (test.beast.evolution.alignment.UncertainAlignmentTest)16 Frequencies (beast.evolution.substitutionmodel.Frequencies)13 HKY (beast.evolution.substitutionmodel.HKY)6 RealParameter (beast.core.parameter.RealParameter)5 GeneralSubstitutionModel (beast.evolution.substitutionmodel.GeneralSubstitutionModel)5 Sequence (beast.evolution.alignment.Sequence)4 JukesCantor (beast.evolution.substitutionmodel.JukesCantor)3 BEASTInterface (beast.core.BEASTInterface)2 MarginalTree (bacter.MarginalTree)1 Region (bacter.Region)1 SimulatedAlignment (beast.app.seqgen.SimulatedAlignment)1 Input (beast.core.Input)1 TaxonSet (beast.evolution.alignment.TaxonSet)1 BranchRateModel (beast.evolution.branchratemodel.BranchRateModel)1