Search in sources :

Example 1 with Frequencies

use of beast.evolution.substitutionmodel.Frequencies in project beast2 by CompEvol.

the class UnorderedAlignmentsTest method getSiteModel.

public static SiteModel getSiteModel() throws Exception {
    Frequencies frequencies = new Frequencies();
    frequencies.initByName("frequencies", new RealParameter("0.25 0.25 0.25 0.25"));
    HKY hky = new HKY();
    hky.initByName("kappa", new RealParameter("1.0"), "frequencies", frequencies);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", new RealParameter("0.005"), "substModel", hky);
    return siteModel;
}
Also used : HKY(beast.evolution.substitutionmodel.HKY) RealParameter(beast.core.parameter.RealParameter) SiteModel(beast.evolution.sitemodel.SiteModel) Frequencies(beast.evolution.substitutionmodel.Frequencies)

Example 2 with Frequencies

use of beast.evolution.substitutionmodel.Frequencies in project beast2 by CompEvol.

the class F84Distance method setPatterns.

/**
 * set the pattern source
 */
@Override
public void setPatterns(Alignment patterns) {
    super.setPatterns(patterns);
    Frequencies frequencies = new Frequencies();
    try {
        frequencies.initByName("data", patterns, "estimate", true);
    } catch (Exception e) {
        e.printStackTrace();
    }
    double[] freqs = frequencies.getFreqs();
    stateCount = dataType.getStateCount();
    if (stateCount != 4) {
        throw new IllegalArgumentException("F84DistanceMatrix must have nucleotide patterns");
    }
    double freqA = freqs[0];
    double freqC = freqs[1];
    double freqG = freqs[2];
    double freqT = freqs[3];
    double freqR = freqA + freqG;
    double freqY = freqC + freqT;
    constA = ((freqA * freqG) / freqR) + ((freqC * freqT) / freqY);
    constB = (freqA * freqG) + (freqC * freqT);
    constC = (freqR * freqY);
}
Also used : Frequencies(beast.evolution.substitutionmodel.Frequencies)

Example 3 with Frequencies

use of beast.evolution.substitutionmodel.Frequencies 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 4 with Frequencies

use of beast.evolution.substitutionmodel.Frequencies 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 Frequencies

use of beast.evolution.substitutionmodel.Frequencies in project beast2 by CompEvol.

the class TreeLikelihoodTest method testAscertainedJC69Likelihood.

@Test
public void testAscertainedJC69Likelihood() throws Exception {
    // as testJC69Likelihood but with ascertained alignment
    Alignment data = BEASTTestCase.getAscertainedAlignment();
    Tree tree = BEASTTestCase.getTree(data);
    Frequencies freqs = new Frequencies();
    freqs.initByName("data", data, "estimate", false);
    HKY hky = new HKY();
    hky.initByName("kappa", "1.0", "frequencies", freqs);
    SiteModel siteModel = new SiteModel();
    siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", hky);
    TreeLikelihood likelihood = newTreeLikelihood();
    likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel);
    double logP = 0;
    logP = likelihood.calculateLogP();
    // the following number comes from Beast 1.6
    assertEquals(logP, -737.7140695360017, 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)

Aggregations

Frequencies (beast.evolution.substitutionmodel.Frequencies)21 SiteModel (beast.evolution.sitemodel.SiteModel)14 Alignment (beast.evolution.alignment.Alignment)13 BeagleTreeLikelihood (beast.evolution.likelihood.BeagleTreeLikelihood)13 TreeLikelihood (beast.evolution.likelihood.TreeLikelihood)13 Tree (beast.evolution.tree.Tree)13 Test (org.junit.Test)13 UncertainAlignmentTest (test.beast.evolution.alignment.UncertainAlignmentTest)13 RealParameter (beast.core.parameter.RealParameter)10 HKY (beast.evolution.substitutionmodel.HKY)8 GeneralSubstitutionModel (beast.evolution.substitutionmodel.GeneralSubstitutionModel)5 Sequence (beast.evolution.alignment.Sequence)3 BinaryCovarion (beast.evolution.substitutionmodel.BinaryCovarion)3 GTR (beast.evolution.substitutionmodel.GTR)2 UserDataType (beast.evolution.datatype.UserDataType)1 MutationDeathModel (beast.evolution.substitutionmodel.MutationDeathModel)1 JComboBox (javax.swing.JComboBox)1