Search in sources :

Example 56 with FrequencyModel

use of dr.evomodel.substmodel.FrequencyModel in project beast-mcmc by beast-dev.

the class VariableBranchCompleteHistorySimulatorTest method testHKYVariableSimulation.

public void testHKYVariableSimulation() {
    System.out.println("Starting HKY variable branch simulation");
    Parameter kappa = new Parameter.Default(1, 2.0);
    double[] pi = { 0.45, 0.05, 0.25, 0.25 };
    Parameter freqs = new Parameter.Default(pi);
    FrequencyModel f = new FrequencyModel(Nucleotides.INSTANCE, freqs);
    HKY hky = new HKY(kappa, f);
    int stateCount = hky.getDataType().getStateCount();
    Parameter mu = new Parameter.Default(1, 0.5);
    Parameter alpha = new Parameter.Default(1, 0.5);
    GammaSiteRateModel siteModel = new GammaSiteRateModel("gammaModel", mu, alpha, 4, null);
    siteModel.setSubstitutionModel(hky);
    BranchRateModel branchRateModel = new DefaultBranchRateModel();
    double analyticResult = TreeUtils.getTreeLength(tree, tree.getRoot()) * mu.getParameterValue(0);
    int nSites = 200;
    double[] register1 = new double[stateCount * stateCount];
    double[] register2 = new double[stateCount * stateCount];
    // Count all jumps
    MarkovJumpsCore.fillRegistrationMatrix(register1, stateCount);
    // Move some jumps from 1 to 2
    register1[1 * stateCount + 2] = 0;
    register2[1 * stateCount + 2] = 1;
    register1[1 * stateCount + 3] = 0;
    register2[1 * stateCount + 3] = 1;
    register1[2 * stateCount + 3] = 0;
    register2[2 * stateCount + 3] = 1;
    double[] branchValues = { 10.0, 10.0, 10.0, 10.0, 10.0 };
    Parameter branchValuesParam = new Parameter.Default(branchValues);
    runSimulation(N, tree, siteModel, branchRateModel, nSites, new double[][] { register1, register2 }, analyticResult, kappa, branchValuesParam);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) BranchRateModel(dr.evomodel.branchratemodel.BranchRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel) HKY(dr.evomodel.substmodel.nucleotide.HKY) Parameter(dr.inference.model.Parameter) GammaSiteRateModel(dr.evomodel.siteratemodel.GammaSiteRateModel) DefaultBranchRateModel(dr.evomodel.branchratemodel.DefaultBranchRateModel)

Example 57 with FrequencyModel

use of dr.evomodel.substmodel.FrequencyModel in project beast-mcmc by beast-dev.

the class UniformizedStateHistoryTest method setUp.

public void setUp() {
    MathUtils.setSeed(666);
    Parameter kappa = new Parameter.Default(1, 2.0);
    double[] pi = { 0.45, 0.05, 0.30, 0.20 };
    Parameter freqs = new Parameter.Default(pi);
    FrequencyModel f = new FrequencyModel(Nucleotides.INSTANCE, freqs);
    hky = new HKY(kappa, f);
    stateCount = hky.getDataType().getStateCount();
    double[] lambda = new double[stateCount * stateCount];
    hky.getInfinitesimalMatrix(lambda);
    process = new SubordinatedProcess(lambda, stateCount);
}
Also used : FrequencyModel(dr.evomodel.substmodel.FrequencyModel) HKY(dr.evomodel.substmodel.nucleotide.HKY) Parameter(dr.inference.model.Parameter)

Aggregations

FrequencyModel (dr.evomodel.substmodel.FrequencyModel)57 Parameter (dr.inference.model.Parameter)42 GammaSiteRateModel (dr.evomodel.siteratemodel.GammaSiteRateModel)23 BranchRateModel (dr.evomodel.branchratemodel.BranchRateModel)22 HKY (dr.evomodel.substmodel.nucleotide.HKY)21 HomogeneousBranchModel (dr.evomodel.branchmodel.HomogeneousBranchModel)19 TreeModel (dr.evomodel.tree.TreeModel)19 DefaultBranchRateModel (dr.evomodel.branchratemodel.DefaultBranchRateModel)17 ArrayList (java.util.ArrayList)14 BranchModel (dr.evomodel.branchmodel.BranchModel)12 Partition (dr.app.beagle.tools.Partition)11 SubstitutionModel (dr.evomodel.substmodel.SubstitutionModel)11 BeagleSequenceSimulator (dr.app.beagle.tools.BeagleSequenceSimulator)10 DataType (dr.evolution.datatype.DataType)10 NewickImporter (dr.evolution.io.NewickImporter)9 Tree (dr.evolution.tree.Tree)9 Vector (dr.math.matrixAlgebra.Vector)9 PatternList (dr.evolution.alignment.PatternList)7 ImportException (dr.evolution.io.Importer.ImportException)7 BeagleTreeLikelihood (dr.evomodel.treelikelihood.BeagleTreeLikelihood)7