コード例 #1
0
 def _add_prior(self, prior, name):
     alpha_prior = xml.prior(prior,
                             id="covarion_alpha_prior.s:%s" % name,
                             name="distribution",
                             x="@covarion_alpha.s:%s" % name)
     xml.Uniform(alpha_prior,
                 id="CovAlphaUniform:%s" % name,
                 name="distr",
                 upper="Infinity")
     switch_prior = xml.prior(prior,
                              id="covarion_s_prior.s:%s" % name,
                              name="distribution",
                              x="@covarion_s.s:%s" % name)
     gamma = xml.Gamma(switch_prior, id="Gamma.0:%s" % name, name="distr")
     xml.parameter(gamma,
                   text="0.05",
                   id="covarion_switch_gamma_param1:%s" % name,
                   name="alpha",
                   lower="0.0",
                   upper="0.0")
     xml.parameter(gamma,
                   text="10.0",
                   id="covarion_switch_gamma_param2:%s" % name,
                   name="beta",
                   lower="0.0",
                   upper="0.0")
コード例 #2
0
 def add_prior(self, prior):
     # Uniform prior on mean clock rate
     sub_prior = xml.prior(prior,
                           id="clockPrior:%s" % self.name,
                           name="distribution",
                           x="@clockRate.c:%s" % self.name)
     xml.Uniform(sub_prior,
                 id="UniformClockPrior:%s" % self.name,
                 name="distr",
                 upper="Infinity")
コード例 #3
0
ファイル: base.py プロジェクト: lmaurits/BEASTling
    def add_prior(self, beastxml):
        """Add a (calibrated) birth-death tree prior."""
        # Tree prior

        attribs = {}
        attribs["id"] = "BirthDeathModel.t:beastlingTree"
        attribs["tree"] = "@Tree.t:beastlingTree"
        attribs[
            "spec"] = "beast.evolution.speciation.BirthDeathGernhard08Model"
        attribs["birthDiffRate"] = "@birthRate.t:beastlingTree"
        attribs["relativeDeathRate"] = "@deathRate.t:beastlingTree"
        attribs["sampleProbability"] = "@sampling.t:beastlingTree"
        attribs[
            "type"] = "unscaled"  #TODO: Someone dropped the "restricted" type here, which does not exist.
        xml.distribution(beastxml.prior, attrib=attribs)

        # Birth rate prior
        attribs = {}
        attribs["id"] = "BirthRatePrior.t:beastlingTree"
        attribs["name"] = "distribution"
        attribs["x"] = "@birthRate.t:beastlingTree"
        sub_prior = xml.prior(beastxml.prior, attrib=attribs)
        xml.Uniform(sub_prior, id="Uniform.0", name="distr", upper="Infinity")

        # Relative death rate prior
        attribs = {}
        attribs["id"] = "relativeDeathRatePrior.t:beastlingTree"
        attribs["name"] = "distribution"
        attribs["x"] = "@deathRate.t:beastlingTree"
        sub_prior = xml.prior(beastxml.prior, attrib=attribs)
        xml.Uniform(sub_prior, id="Uniform.1", name="distr", upper="Infinity")

        # Sample probability prior
        attribs = {}
        attribs["id"] = "samplingPrior.t:beastlingTree"
        attribs["name"] = "distribution"
        attribs["x"] = "@sampling.t:beastlingTree"
        sub_prior = xml.prior(beastxml.prior, attrib=attribs)
        xml.Uniform(sub_prior,
                    id="Uniform.3",
                    name="distr",
                    lower="0",
                    upper="1")
コード例 #4
0
 def add_prior(self, prior):
     """
     Add prior distributions for Gamma-distributed rate heterogenetiy, if
     configured.
     """
     if self.scale_precision:
         precision_prior = xml.prior(prior,
                                     id="sphericalPrecisionPrior",
                                     x="@sphericalPrecision",
                                     name="distribution")
         xml.Uniform(precision_prior,
                     id="sphericalPrecisionPriorUniform",
                     name="distr",
                     lower="0",
                     upper="1e10")
コード例 #5
0
 def _add_prior(self, prior, name):
     switch_prior = xml.prior(
         prior,
         id="%s:pdcovarion_s_prior.s" % name,
         name="distribution",
         x="@%s:pdcovarion_s.s" % name)
     gamma = xml.Gamma(switch_prior, id="%s: Gamma.0" % name, name="distr")
     xml.parameter(
         gamma,
         text="0.05",
         id="%s:pdcovarion_switch_gamma_param1" % name,
         name="alpha",
         lower="0.0",
         upper="0.0")
     xml.parameter(
         gamma,
         text="10.0",
         id="%s:pdcovarion_switch_gamma_param2" % name,
         name="beta",
         lower="0.0",
         upper="0.0")
     origin_prior = xml.prior(
         prior,
         id="%s:pdcovarion_origin_prior.s" % name,
         name="distribution",
         x="@%s:pdcovarion_origin.s" % name)
     xml.Uniform(
         origin_prior,
         id="%s:PDCovOriginUniform" % name,
         name="distr",
         upper="Infinity")
     death_prior = xml.prior(
         prior,
         id="%s:pdcovarion_death_prior.s" % name,
         name="distribution",
         x="@{:}:pdcovarion_death.s".format(name))
     xml.Exponential(
         death_prior,
         id="%s:PDCovDeathExp" % name,
         name="distr",
         mean="1.0")
コード例 #6
0
    def add_prior(self, beastxml):
        """
        Add Yule birth-process tree prior.
        """
        # Tree prior
        ## Decide whether to use the standard Yule or the fancy calibrated one
        if len(beastxml.config.calibrations) == 1:
            yule = "calibrated"
        elif len(beastxml.config.calibrations) == 2:
            # Two calibrations can be handled by the calibrated Yule if they
            # are nested
            langs1, langs2 = [
                c.langs for c in beastxml.config.calibrations.values()
            ]
            if len(set(langs1) & set(langs2)) in (len(langs1), len(langs2)):
                yule = "calibrated"
            else:
                yule = "standard"
        else:
            yule = "standard"

        attribs = {}
        attribs["id"] = "YuleModel.t:beastlingTree"
        attribs["tree"] = "@Tree.t:beastlingTree"
        if yule == "standard":
            attribs["spec"] = "beast.evolution.speciation.YuleModel"
            attribs["birthDiffRate"] = "@birthRate.t:beastlingTree"
            if "root" in beastxml.config.calibrations:
                attribs["conditionalOnRoot"] = "true"
        elif yule == "calibrated":
            attribs["spec"] = "beast.evolution.speciation.CalibratedYuleModel"
            attribs["birthRate"] = "@birthRate.t:beastlingTree"
        xml.distribution(beastxml.prior, attrib=attribs)

        # Birth rate prior
        sub_prior = xml.prior(beastxml.prior,
                              id="YuleBirthRatePrior.t:beastlingTree",
                              name="distribution",
                              x="@birthRate.t:beastlingTree")
        xml.Uniform(sub_prior, id="Uniform.0", name="distr", upper="Infinity")