Search in sources :

Example 1 with DemographicModel

use of dr.evomodel.coalescent.demographicmodel.DemographicModel in project beast-mcmc by beast-dev.

the class BNPRSamplingLikelihood method main.

public static void main(String[] args) throws Exception {
    NewickImporter importer = new NewickImporter("(((t93_0:0.1823217653,t94_0:0.08702282874):0.853414946,t95_0:0.5591826007):16.46923208,((t96_0:4.730080227,(t97_0:3.316833,((t98_0:1.117259784,((t84_0:0.02918861288,((((t77_0:0.6269405877,t78_0:0.1883673111):0.1035487414,(((((t58_0:0.366605532,(t59_0:0.2902223473,t60_0:0.09330035051):0.05814249819):0.2687774288,(t61_0:0.03909732613,((((t31_0:0.4925976152,(t1_0:1.543243834,(t2_0:0.3786992111,t3_0:0.286843186):0.9369069124):1.84806174):1.388380979,(((((t4_0:1.57060332,t5_0:1.565578151):0.9340116213,(t6_0:0.6129297388,t7_0:0.5252059248):1.883951667):1.298791879,(t8_0:3.070277733,((t9_0:2.351705269,t10_0:2.318654989):0.03364809509,t11_0:1.986711821):0.6207718581):0.558736892):0.1439273897,((((t12_0:0.3565815494,t13_0:0.2420866743):1.027508236,t14_0:1.128497322):0.1217011969,t15_0:1.211013892):0.5793893699,((t16_0:0.4746827902,t17_0:0.4609704827):1.049116131,t18_0:1.497407856):0.1530705075):1.000179818):0.0008681768441,(t19_0:2.204632212,((t20_0:1.857557731,(t21_0:1.005514944,t22_0:0.9291487706):0.6230458901):0.1109842512,t23_0:1.582286036):0.1992671825):0.4433270097):0.3343580536):0.6454071651,(((t24_0:0.815171935,t25_0:0.6918964743):0.2147852872,(t26_0:0.1228387289,t27_0:0.05280374254):0.5882964168):2.025084596,(t28_0:0.2705161616,t29_0:0.2642467551):2.230464942):0.1103642803):6.832809449,(((t30_0:0.9906878227,t32_0:0.1856034526):1.311909106,t33_0:0.3458898346):6.842038256,t34_0:4.353598435):0.2887890018):0.414867716):0.05823058913):0.3120716399,(t35_0:1.623697863,((t36_0:1.029267152,t37_0:0.9940333973):0.2630810985,t38_0:1.077299678):0.2899006266):2.324485801):1.915577302,(t39_0:1.748484212,t40_0:1.720294263):3.606542332):0.6429878862,(t41_0:5.650860772,((t42_0:0.8033637796,t43_0:0.3493332566):3.763664014,(t44_0:0.8778820702,(t45_0:0.5483027215,t46_0:0.4562980629):0.1491010534):3.197472308):0.8000617359):0.2857177615):0.4150148533):0.7376635867,(((t47_0:0.3446780656,t48_0:0.3130649187):3.810586451,(((((t49_0:0.9994210908,t50_0:0.8953272412):0.5705160932,(t51_0:0.7994882815,t52_0:0.7164389879):0.6268954443):0.34752079,t53_0:1.598405188):0.2494469601,(t54_0:1.508633144,t55_0:1.473482952):0.05756852234):0.6596007127,(t56_0:1.076711525,t57_0:1.070680706):1.008030326):1.241809834):0.7439478609,((t62_0:0.1842275742,t63_0:0.1339199725):1.294985145,(t64_0:1.040418148,t65_0:0.7556259274):0.3408415617):1.72091551):0.5986199428):2.461710024,(((t66_0:3.108881856,((t67_0:2.000699305,((t68_0:1.382538601,t69_0:1.246844479):0.249533307,t70_0:1.366941817):0.176205828):0.5708242903,(t71_0:0.9490874836,t72_0:0.7691535035):0.8078785817):0.475066817):0.06683807466,((t73_0:0.7617022066,t74_0:0.7482687036):0.1047558487,t75_0:0.7677691921):0.8692021164):0.1592569402,t76_0:1.722131386):2.262393917):2.572913635):2.595279242,(t79_0:3.600210891,(t80_0:0.7070684518,t81_0:0.3253173205):2.684283986):2.510617438):0.5734740762):1.936674132,t82_0:6.475760804):0.2353584188):1.216419756):0.9696225718,(((t83_0:0.4830428417,t85_0:0.214507183):4.223119782,(((t86_0:1.283242236,t87_0:1.278786271):1.710456,t88_0:2.295501437):0.6485241096,(t89_0:1.619761915,t90_0:1.575819491):1.230444387):0.7762895827):1.668960635,(t91_0:4.403654576,t92_0:4.367902389):0.7940511151):1.277021867):11.16032274)");
    Tree tree = importer.importNextTree();
    Parameter betas = new Parameter.Default(new double[] { 2.430198, 1.121209, 18.963120 });
    Parameter N0 = new Parameter.Default(new double[] { 0.957477459020635, 2.43878447702397, 1.16178606305887, 2.47803465457009, 3.59425875085121, 5.99484118979476, 8.45281123199342, 5.32731462686442, 2.14530385537217, 1.32838970512892, 1.57682364008761, 2.06977561883114, 0.975318782259623, 0.729019262672561, 0.528122712339147, 1.73826551939609, 1.59115234812228, 0.991767268014354, 1.19544144384689, 4.2431612093277, 9.68837537548171, 21.7809958450516, 72.9542238498992, 67.4709298097791, 17.5930802539968, 17.9641115502897, 20.2230985692042, 18.5751760066478, 15.316828425915, 53.4144639187011, 20.6589204576208, 11.4695515805863, 25.1358546005526, 41.1222703999958, 36.0749583093113, 43.5582733013315, 191.509377345225, 60.2774566116462, 13.6461065289052, 29.0150510257721, 11.8060344563918, 14.0771159483723, 17.2536924114547, 15.3833722037801, 46.48760509832, 41.881067569086, 27.6941667792898, 55.4922963887114, 253.986328605972, 305.304267851333, 243.190770701089, 144.095172595153, 172.765640994598, 174.182113284746, 454.771916114004, 514.94845166669, 266.355413273477, 2039.89326970745, 972.728248184194, 305.635176732534, 227.134976673311, 143.297859235514, 74.5162610231541, 45.3481762741632, 32.1527697118794, 7.6456190280646, 12.1418530975389, 9.48239531687115, 7.37481430050462, 4.49432342829254, 14.6077380251641, 13.5858667415758, 11.2001057413539, 4.12650576804321, 3.83168028086946, 5.56705828329053, 7.86450990980968, 5.6493737041167, 4.76307833501312, 6.45317992085796, 9.78615502142029, 13.8294443012538, 22.5127519861243, 28.9164141530354, 85.3528130029434, 34.8658623017608, 47.1574370857575, 40.2205642235078, 57.50963654004, 65.3719036601996, 44.8775886163862, 17.6951867195527, 9.07043638586854, 18.663530289391, 15.6125065593161, 2.12354416497279, 4.96867966440677, 3.63537271117703, 2.09626570198215, 1.03533797751651 });
    double[] epochLengths = new double[] { 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317, 0.404760913356317 };
    Parameter covariate1 = new Parameter.Default(new double[] { -0.00505951141695401, -0.015178534250862, -0.0252975570847698, -0.0354165799186778, -0.0455356027525857, -0.0556546255864937, -0.0657736484204016, -0.0758926712543096, -0.0860116940882175, -0.0961307169221254, -0.106249739756033, -0.116368762589941, -0.126487785423849, -0.136606808257757, -0.146725831091665, -0.156844853925573, -0.166963876759481, -0.177082899593389, -0.187201922427297, -0.197320945261205, -0.207439968095113, -0.217558990929021, -0.227678013762929, -0.237797036596836, -0.247916059430744, -0.258035082264652, -0.26815410509856, -0.278273127932468, -0.288392150766376, -0.298511173600284, -0.308630196434192, -0.3187492192681, -0.328868242102008, -0.338987264935916, -0.349106287769824, -0.359225310603732, -0.36934433343764, -0.379463356271548, -0.389582379105455, -0.399701401939363, -0.409820424773271, -0.419939447607179, -0.430058470441087, -0.440177493274995, -0.450296516108903, -0.460415538942811, -0.470534561776719, -0.480653584610627, -0.490772607444535, -0.500891630278443, -0.511010653112351, -0.521129675946259, -0.531248698780167, -0.541367721614075, -0.551486744447982, -0.56160576728189, -0.571724790115798, -0.581843812949706, -0.591962835783614, -0.602081858617522, -0.61220088145143, -0.622319904285338, -0.632438927119246, -0.642557949953154, -0.652676972787062, -0.66279599562097, -0.672915018454878, -0.683034041288786, -0.693153064122694, -0.703272086956601, -0.713391109790509, -0.723510132624417, -0.733629155458325, -0.743748178292233, -0.753867201126141, -0.763986223960049, -0.774105246793957, -0.784224269627865, -0.794343292461773, -0.804462315295681, -0.814581338129589, -0.824700360963497, -0.834819383797405, -0.844938406631313, -0.85505742946522, -0.865176452299128, -0.875295475133036, -0.885414497966944, -0.895533520800852, -0.90565254363476, -0.915771566468668, -0.925890589302576, -0.936009612136484, -0.946128634970392, -0.9562476578043, -0.966366680638208, -0.976485703472116, -0.986604726306024, -0.996723749139932, -1.00684277197384 });
    MatrixParameter covariates = new MatrixParameter("Covariates", new Parameter[] { covariate1 });
    DemographicModel Ne = new PiecewisePopulationModel("Ne(t)", N0, epochLengths, false, Units.Type.DAYS);
    BNPRSamplingLikelihood samplingLikelihood = new BNPRSamplingLikelihood(tree, betas, Ne, epochLengths, covariates);
    System.out.println("Sampling likelihood: " + samplingLikelihood.getLogLikelihood());
}
Also used : NewickImporter(dr.evolution.io.NewickImporter) Tree(dr.evolution.tree.Tree) DemographicModel(dr.evomodel.coalescent.demographicmodel.DemographicModel) PiecewisePopulationModel(dr.evomodel.coalescent.demographicmodel.PiecewisePopulationModel)

Example 2 with DemographicModel

use of dr.evomodel.coalescent.demographicmodel.DemographicModel in project beast-mcmc by beast-dev.

the class CoalescentLikelihoodParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(MODEL);
    PopulationSizeModel populationSizeModel = (PopulationSizeModel) cxo.getChild(PopulationSizeModel.class);
    DemographicModel demographicModel = null;
    if (populationSizeModel == null) {
        demographicModel = (DemographicModel) cxo.getChild(DemographicModel.class);
    }
    List<TreeModel> trees = new ArrayList<TreeModel>();
    List<Double> popFactors = new ArrayList<Double>();
    MultiLociTreeSet treesSet = (demographicModel instanceof MultiLociTreeSet ? (MultiLociTreeSet) demographicModel : null);
    IntervalList intervalList = null;
    for (int k = 0; k < xo.getChildCount(); ++k) {
        final Object child = xo.getChild(k);
        if (child instanceof XMLObject) {
            cxo = (XMLObject) child;
            if (cxo.getName().equals(POPULATION_TREE)) {
                final TreeModel t = (TreeModel) cxo.getChild(TreeModel.class);
                assert t != null;
                trees.add(t);
                popFactors.add(cxo.getAttribute(POPULATION_FACTOR, 1.0));
            } else if (cxo.getName().equals(INTERVALS)) {
                intervalList = (IntervalList) cxo.getChild(IntervalList.class);
            }
        }
    // in the future we may have arbitrary multi-loci element
    // else if( child instanceof MultiLociTreeSet )  {
    // treesSet = (MultiLociTreeSet)child;
    // }
    }
    TreeModel treeModel = null;
    if (trees.size() == 1 && popFactors.get(0) == 1.0) {
        treeModel = trees.get(0);
    } else if (trees.size() > 1) {
        treesSet = new MultiLociTreeSet.Default(trees, popFactors);
    } else if (!(trees.size() == 0 && treesSet != null) && intervalList == null) {
        throw new XMLParseException("Incorrectly constructed likelihood element");
    }
    if (treeModel != null) {
        TaxonList includeSubtree = null;
        if (xo.hasChildNamed(INCLUDE)) {
            includeSubtree = (TaxonList) xo.getElementFirstChild(INCLUDE);
        }
        List<TaxonList> excludeSubtrees = new ArrayList<TaxonList>();
        if (xo.hasChildNamed(EXCLUDE)) {
            cxo = xo.getChild(EXCLUDE);
            for (int i = 0; i < cxo.getChildCount(); i++) {
                excludeSubtrees.add((TaxonList) cxo.getChild(i));
            }
        }
        try {
            intervalList = new TreeIntervals(treeModel, includeSubtree, excludeSubtrees);
        // TreeIntervals now deals with all the interval stuff
        // return new CoalescentLikelihood(treeModel, includeSubtree, excludeSubtrees, demoModel);
        } catch (TreeUtils.MissingTaxonException mte) {
            throw new XMLParseException("treeModel missing a taxon from taxon list in " + getParserName() + " element");
        }
    }
    if (intervalList != null) {
        if (demographicModel != null) {
            return new CoalescentLikelihood(intervalList, demographicModel);
        }
        return new CoalescentLikelihood(intervalList, populationSizeModel);
    } else {
        if (xo.hasChildNamed(INCLUDE) || xo.hasChildNamed(EXCLUDE)) {
            throw new XMLParseException("Include/Exclude taxa not supported for multi locus sets");
        }
        // a base - and modifing it will probsbly result in a bigger mess.
        return new OldAbstractCoalescentLikelihood(treesSet, demographicModel);
    }
}
Also used : TaxonList(dr.evolution.util.TaxonList) ArrayList(java.util.ArrayList) DemographicModel(dr.evomodel.coalescent.demographicmodel.DemographicModel) TreeModel(dr.evomodel.tree.TreeModel) IntervalList(dr.evolution.coalescent.IntervalList) TreeUtils(dr.evolution.tree.TreeUtils)

Example 3 with DemographicModel

use of dr.evomodel.coalescent.demographicmodel.DemographicModel in project beast-mcmc by beast-dev.

the class TwoEpochDemographicModelParser method parseXMLObject.

public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    Units.Type units = XMLUnits.Utils.getUnitsAttr(xo);
    XMLObject cxo = xo.getChild(EPOCH_1);
    DemographicModel demo1 = (DemographicModel) cxo.getChild(DemographicModel.class);
    cxo = xo.getChild(EPOCH_2);
    DemographicModel demo2 = (DemographicModel) cxo.getChild(DemographicModel.class);
    cxo = xo.getChild(TRANSITION_TIME);
    Parameter timeParameter = (Parameter) cxo.getChild(Parameter.class);
    return new TwoEpochDemographicModel(demo1, demo2, timeParameter, units);
}
Also used : DemographicModel(dr.evomodel.coalescent.demographicmodel.DemographicModel) TwoEpochDemographicModel(dr.evomodel.coalescent.demographicmodel.TwoEpochDemographicModel) Parameter(dr.inference.model.Parameter) Units(dr.evolution.util.Units) XMLUnits(dr.evoxml.util.XMLUnits) TwoEpochDemographicModel(dr.evomodel.coalescent.demographicmodel.TwoEpochDemographicModel)

Example 4 with DemographicModel

use of dr.evomodel.coalescent.demographicmodel.DemographicModel in project beast-mcmc by beast-dev.

the class BNPRSamplingLikelihoodParser method parseXMLObject.

// ************************************************************************
// AbstractXMLObjectParser implementation
// ************************************************************************
@Override
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
    XMLObject cxo = xo.getChild(MODEL);
    DemographicModel demoModel = (DemographicModel) cxo.getChild(DemographicModel.class);
    cxo = xo.getChild(BETAS);
    Parameter betas = (Parameter) cxo.getChild(Parameter.class);
    // May need to adapt to multiple trees, a la CoalescentLikelihoodParser
    cxo = xo.getChild(POPULATION_TREE);
    TreeModel tree = (TreeModel) cxo.getChild(TreeModel.class);
    double[] epochWidths = null;
    if (xo.hasChildNamed(EPOCH_WIDTHS)) {
        cxo = xo.getChild(EPOCH_WIDTHS);
        epochWidths = cxo.getDoubleArrayAttribute(WIDTHS);
    }
    MatrixParameter covariates = null;
    if (xo.hasChildNamed(COVARIATES)) {
        cxo = xo.getChild(COVARIATES);
        covariates = (MatrixParameter) cxo.getChild(MatrixParameter.class);
    }
    MatrixParameter powerCovariates = null;
    if (xo.hasChildNamed(POWER_COVARIATES)) {
        cxo = xo.getChild(POWER_COVARIATES);
        powerCovariates = (MatrixParameter) cxo.getChild(MatrixParameter.class);
    }
    Parameter powerBetas = null;
    if (xo.hasChildNamed(POWER_BETAS)) {
        cxo = xo.getChild(POWER_BETAS);
        powerBetas = (Parameter) cxo.getChild(Parameter.class);
    }
    return new BNPRSamplingLikelihood(tree, betas, demoModel, epochWidths, covariates, powerCovariates, powerBetas);
}
Also used : TreeModel(dr.evomodel.tree.TreeModel) MatrixParameter(dr.inference.model.MatrixParameter) DemographicModel(dr.evomodel.coalescent.demographicmodel.DemographicModel) Parameter(dr.inference.model.Parameter) MatrixParameter(dr.inference.model.MatrixParameter) BNPRSamplingLikelihood(dr.evomodel.coalescent.BNPRSamplingLikelihood)

Example 5 with DemographicModel

use of dr.evomodel.coalescent.demographicmodel.DemographicModel in project beast-mcmc by beast-dev.

the class RandomWalkGenerator method main.

public static void main(String[] args) throws Exception {
    // Parameter data = new Parameter.Default(100);
    // Parameter firstElemPrec = new Parameter.Default(0.25);
    // Parameter prec = new Parameter.Default(4.0);
    // RandomWalkGenerator gen = new RandomWalkGenerator(data, firstElemPrec, prec);
    // 
    // System.out.println("Data = " + Arrays.toString(data.getParameterValues()));
    // 
    // double[] newData = gen.nextRandom();
    // 
    // System.out.println("New Data = " + Arrays.toString(newData));
    // 
    // System.out.print("dat = c(");
    // for (int i = 0; i < newData.length; i++) {
    // data.setParameterValue(i, newData[i]);
    // System.out.printf("%.3f,", newData[i]);
    // }
    // System.out.println();
    // 
    // System.out.println("New Data too = " + Arrays.toString(data.getParameterValues()));
    // 
    // System.out.println("Log-likelihood = " + gen.getLogLikelihood());
    // 
    // double[] values = new double[5];
    // System.out.println("New Data = " + Arrays.toString(values));
    NewickImporter importer = new NewickImporter("((((t75_0:8.196509369,(t76_0:5.19700607,t77_0:5.117706795):2.208323646):3.611573553,(t78_0:10.09414276,(t79_0:1.555758051,t80_0:0.6394209368):8.440019033):0.7958799608):36.90916229,(t81_0:6.965230429,t82_0:6.660700811):39.60826152):84.84805599,(((((t83_0:8.461009149,(((t84_0:6.681657444,t85_0:6.329850896):0.4970932551,(t86_0:5.709749921,t87_0:5.207473638):1.032134073):0.2907208781,t88_0:5.860923226):0.6714693579):0.9286485984,(t89_0:4.35176728,(t90_0:3.383962439,t91_0:2.365432603):0.5895519359):2.156672574):0.8045815339,(((t92_0:2.347375928,(t93_0:1.806692774,t95_0:0.2737786494):0.06086363256):1.778880139,t96_0:1.745952006):0.1290466242,t97_0:1.831227907):1.231195333):2.445021787,((t98_0:0.8797524272,t99_0:0.8146248384):2.02910329,t100_0:2.379928659):2.546864865):8.217636348,(t94_0:0.1096345611,(((((t72_0:3.137047799,(t65_0:0.7428752174,(((t54_0:2.298056151,t55_0:1.386634319):0.07055842264,(t56_0:0.6211411999,t57_0:0.5106794843):0.7290213103):1.302958439,(((t32_0:0.01892218578,(((t28_0:0.8330661569,((((t25_0:0.1067751399,t1_0:9.307914765):0.2959298825,t2_0:9.425199804):0.07190576719,t3_0:8.826132669):0.2342818567,(t4_0:8.321528621,t5_0:8.0599082):0.2509419834):0.9408918394):0.7425197124,t6_0:9.694992029):2.36508096,t7_0:11.2758228):0.1994631268):8.443974525,((t8_0:10.76752205,((((t9_0:1.493044826,(t10_0:0.6698090384,t11_0:0.2989691445):0.7176777198):2.286111176,t12_0:2.654871592):1.588547853,t13_0:4.203655954):3.489759422,t14_0:7.542791391):1.88216266):8.014313382,((((t15_0:4.455846169,(t16_0:0.9348779818,t17_0:0.7092212787):2.927543424):0.8337954126,t18_0:4.371535283):2.561638646,(t19_0:2.317319668,(t20_0:0.2652308407,t21_0:0.2469742062):1.962177717):3.646397641):4.201926648,(((t22_0:3.626205298,(t23_0:1.814394049,t24_0:1.722932275):1.576199638):0.6832367053,(t26_0:0.143315467,t27_0:0.135478801):1.855008):4.430521602,(t29_0:0.277418938,t30_0:0.2751244534):2.656950561):1.277291788):4.44558088):0.4877611393):1.124425501,(((t31_0:2.199804416,t33_0:1.72439591):5.99779354,t34_0:7.697646612):0.2314130313,t35_0:7.7292073):1.578317139):0.6787721178):5.713754691):4.899357656):2.690189889,((((((t36_0:8.464440253,((t37_0:1.516370472,(t38_0:0.4518582713,t39_0:0.3776256558):1.039775741):5.008595559,(t40_0:1.662591706,t41_0:1.311689096):4.010173892):1.134735834):0.9467574058,t42_0:7.365820535):0.4308090259,((((t43_0:4.977793922,t44_0:4.1359021):0.04952307756,t45_0:4.176477429):0.004420431545,t46_0:3.828337992):0.1806606434,((t47_0:2.488665975,t48_0:2.460902709):0.2186504359,(t49_0:1.415777402,t50_0:1.358357241):0.6077191637):0.7478779126):1.81853207):7.625751786,(t51_0:1.460127624,t52_0:1.344261146):10.22672898):4.701163396,((t53_0:9.827071398,(t58_0:1.163158974,t59_0:0.8080003353):4.25790361):5.797987449,(t60_0:8.676431981,(t61_0:0.7238168631,t62_0:0.5772959095):6.677580493):1.790578221):0.5861914293):0.02660969378,t63_0:9.157389255):1.055890624):1.298920987,((t64_0:1.403696795,t66_0:0.17472493):4.761586473,(t67_0:0.8682056765,t68_0:0.7870286654):3.996084715):3.608662392):1.291247032,(t69_0:3.938693436,(t70_0:1.363501591,t71_0:1.047508982):1.675768049):5.725301901):1.748629464,(t73_0:0.4162471532,t74_0:0.3326790869):5.542586246):2.615577619):15.02704211):110.212517)");
    Tree tree = importer.importNextTree();
    Parameter N0 = new Parameter.Default(new double[] { 10831.41518, 18564.20864, 4012.90013, 4844.7051, 2191.07171, 864.58823, 1954.18284, 7233.75831, 1624.29542, 1204.22108, 2424.79383, 3236.60901, 741.81022, 309.39496, 739.2772, 436.22362, 793.08349, 708.42725, 470.52578, 731.14609, 609.88306, 380.00053, 333.14087, 445.31313, 385.08516, 310.62223, 117.55287, 15.35954, 5.30181, 9.55051, 31.10367, 59.87409, 53.83162, 28.2465, 57.93228, 26.31053, 61.78336, 98.70132, 104.77869, 255.49281, 715.66912, 324.43738, 163.67341, 89.23281, 91.41586, 133.36657, 71.08849, 93.51971, 329.73119, 595.42027, 274.05989, 192.55929, 200.60026, 180.83781, 225.98434, 96.75023, 108.98978, 169.2301, 174.38823, 206.05087, 24.43085, 32.28332, 29.62218, 22.61263, 67.1912, 12.66908, 14.31542, 17.22216, 40.34572, 29.89561, 269.60226, 792.19973, 1639.95258, 495.38584, 438.89219, 266.81732, 943.54934, 1430.35456, 454.51251, 310.67618, 500.64104, 308.28057, 289.18023, 1065.39065, 633.67468, 2127.13342, 4534.01476, 1561.61864, 1958.98386, 2209.80371, 655.44965, 352.61598, 107.18735, 53.62083, 124.80736, 189.3125, 67.15406, 7.91813, 15.98184, 26.89309 });
    double[] epochLengths = new double[] { 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024, 1.699024 };
    DemographicModel Ne = new PiecewisePopulationModel("Ne(t)", N0, epochLengths, false, Units.Type.DAYS);
    TreeIntervals intervalList = new TreeIntervals(tree, null, null);
    CoalescentLikelihood coalescent = new CoalescentLikelihood(intervalList, Ne);
    double logLik = coalescent.getLogLikelihood();
    System.out.printf("Loglik = %f\n", logLik);
    Parameter prec = new Parameter.Default(2.0);
    Parameter logPop = new TransformedParameter(N0, new Transform.LogTransform());
    RandomWalkGenerator rwg = new RandomWalkGenerator(logPop, new Parameter.Default(0.01), prec);
    double logFieldPri = rwg.getLogLikelihood();
    System.out.printf("LogFieldPri = %f\n", logFieldPri);
// ArrayList<Double> al = new ArrayList<Double>();
// List<Double> lst = new Collections.synchronizedList(al);
}
Also used : DemographicModel(dr.evomodel.coalescent.demographicmodel.DemographicModel) PiecewisePopulationModel(dr.evomodel.coalescent.demographicmodel.PiecewisePopulationModel) TreeIntervals(dr.evomodel.coalescent.TreeIntervals) CoalescentLikelihood(dr.evomodel.coalescent.CoalescentLikelihood) NewickImporter(dr.evolution.io.NewickImporter) Tree(dr.evolution.tree.Tree) Transform(dr.util.Transform)

Aggregations

DemographicModel (dr.evomodel.coalescent.demographicmodel.DemographicModel)7 Tree (dr.evolution.tree.Tree)4 TaxonList (dr.evolution.util.TaxonList)3 ArrayList (java.util.ArrayList)3 NewickImporter (dr.evolution.io.NewickImporter)2 Taxa (dr.evolution.util.Taxa)2 CoalescentSimulator (dr.evomodel.coalescent.CoalescentSimulator)2 PiecewisePopulationModel (dr.evomodel.coalescent.demographicmodel.PiecewisePopulationModel)2 TreeModel (dr.evomodel.tree.TreeModel)2 Parameter (dr.inference.model.Parameter)2 IntervalList (dr.evolution.coalescent.IntervalList)1 SimpleTree (dr.evolution.tree.SimpleTree)1 TreeUtils (dr.evolution.tree.TreeUtils)1 Taxon (dr.evolution.util.Taxon)1 Units (dr.evolution.util.Units)1 BNPRSamplingLikelihood (dr.evomodel.coalescent.BNPRSamplingLikelihood)1 CoalescentLikelihood (dr.evomodel.coalescent.CoalescentLikelihood)1 TreeIntervals (dr.evomodel.coalescent.TreeIntervals)1 TwoEpochDemographicModel (dr.evomodel.coalescent.demographicmodel.TwoEpochDemographicModel)1 XMLUnits (dr.evoxml.util.XMLUnits)1