Beispiel #1
0
double Tree::lnPriorRatio(double nh, double oh) {

	nh = nh * treeScale;
	oh = oh * treeScale;

	if (treeTimePrior == 1) {
	}
	else if (treeTimePrior == 2) {
		double diff = modelPtr->getActiveSpeciation()->getNetDiversification();
		double nator = (-(diff) * nh);
		double dator = (-(diff) * oh);
		return nator - dator;
	} else {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		double rel = s->getRelativeDeath(); // dr / br

		double zn = log(1 - (rel) * exp(-(diff) * nh));
		double nator = -2 * zn + (-(diff) * nh);

		double zd = log(1 - (rel) * exp(-(diff) * oh));
		double dator = -2 * zd + (-(diff) * oh);

		return nator - dator;
	}
	return 0.0;
}
Beispiel #2
0
double Tree::getTreeSpeciationProbability() {
	if (treeTimePrior == 1)
		return 0.0;
	else if (treeTimePrior == 2) {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification();
		double c1 = (numTaxa - 1) * log(diff);
		double nps = getTreeCBDNodePriorProb(diff, 0.0);
		return c1 + nps;
	} else {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		double rel = s->getRelativeDeath();
		double lnC = 0.0;
		double c1 = ((numTaxa - 1) * log(diff)) + (numTaxa * log(1 - rel));
		double nps = getTreeCBDNodePriorProb(diff, rel);
		return lnC + c1 + nps;
	}
	return 0.0;
}
Beispiel #3
0
double Tree::getTreeCBDNodePriorProb() {

	double nprb = 0.0;
	if (treeTimePrior == 1)
		return 0.0;
	else if (treeTimePrior == 2) {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		for (int i = 0; i < numNodes; i++) {
			Node *p = &nodes[i];
			if (p->getIsLeaf() == false) {
				double nh = p->getNodeDepth() * treeScale;
				double l = (-(diff) * nh);
				if (p == root) {
					l += (-(diff) * nh);
				}
				nprb += l;
			}
		}
		return nprb;
	} else {
		Speciation *s = modelPtr->getActiveSpeciation();
		double diff = s->getNetDiversification(); // br-dr
		double rel = s->getRelativeDeath(); // dr / br
		for (int i = 0; i < numNodes; i++) {
			Node *p = &nodes[i];
			if (p->getIsLeaf() == false) {
				double nh = p->getNodeDepth() * treeScale;
				double zn = log(1 - (rel) * exp(-(diff) * nh));
				double l = -2 * zn + (-(diff) * nh);
				if (p == root) {
					l += (-(diff) * nh) - zn;
				}
				nprb += l;
			}
		}
		return nprb;
	}
	return 0.0;
}
Beispiel #4
0
Parameter& Parameter::operator=(Parameter &p) {

	if (this != &p){
		ranPtr = p.ranPtr;
		name   = p.name;
		
		{
			Basefreq *thatDerivedPtr = dynamic_cast<Basefreq *>(&p);
			Basefreq *thisDerivedPtr = dynamic_cast<Basefreq *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}

		{
			Exchangeability *thatDerivedPtr = dynamic_cast<Exchangeability *>(&p);
			Exchangeability *thisDerivedPtr = dynamic_cast<Exchangeability *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}

		{
			Shape *thatDerivedPtr = dynamic_cast<Shape *>(&p);
			Shape *thisDerivedPtr = dynamic_cast<Shape *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}
		
		{
			Tree *thatDerivedPtr = dynamic_cast<Tree *>(&p);
			Tree *thisDerivedPtr = dynamic_cast<Tree *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}

		{
			NodeRate *thatDerivedPtr = dynamic_cast<NodeRate *>(&p);
			NodeRate *thisDerivedPtr = dynamic_cast<NodeRate *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}
			
		{
			Cphyperp *thatDerivedPtr = dynamic_cast<Cphyperp *>(&p);
			Cphyperp *thisDerivedPtr = dynamic_cast<Cphyperp *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}
		
		{
			Treescale *thatDerivedPtr = dynamic_cast<Treescale *>(&p);
			Treescale *thisDerivedPtr = dynamic_cast<Treescale *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}
		
		{
			Speciation *thatDerivedPtr = dynamic_cast<Speciation *>(&p);
			Speciation *thisDerivedPtr = dynamic_cast<Speciation *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}
		
		{
			ExpCalib *thatDerivedPtr = dynamic_cast<ExpCalib *>(&p);
			ExpCalib *thisDerivedPtr = dynamic_cast<ExpCalib *>(this);
			if ( thatDerivedPtr != 0 && thisDerivedPtr != 0 ){
				thisDerivedPtr->clone( *thatDerivedPtr );
				goto exitOperator;
			}
		}
		exitOperator:
			;
	}
		
	return *this;
}
Beispiel #5
0
double Treescale::getLnTreeProb(Tree *t) {
	
	if(treeTimePrior == 1)
		return 0.0;
	else if(treeTimePrior == 2 || treeTimePrior == 3){
		
		return t->getTreeCBDNodePriorProb();
	}
	else if(treeTimePrior == 4 || treeTimePrior == 5){
		Speciation *s = modelPtr->getActiveSpeciation();
		double nps = t->getTreeBDSSTreeNodePriorProb(s->getNetDiversification(), 
													 s->getRelativeDeath(), s->getBDSSFossilSampRatePsi(), 
													 s->getBDSSSppSampRateRho(), treeOriginTime);
		return nps;
	}
	else if(treeTimePrior == 6){
		Speciation *s = modelPtr->getActiveSpeciation();
		s->setAllBDFossParams();
		double nps = t->getTreeCalBDSSTreeNodePriorProb(s->getBDSSSpeciationRateLambda(), 
														s->getBDSSExtinctionRateMu(), 
														s->getBDSSFossilSampRatePsi(), 
														s->getBDSSSppSampRateRho());
		return nps;
	}
	else if(treeTimePrior == 7){
		Speciation *s = modelPtr->getActiveSpeciation();
		s->setAllBDFossParams();
		double nps = t->getTreeAncCalBDSSTreeNodePriorProb(s->getBDSSSpeciationRateLambda(), 
														s->getBDSSExtinctionRateMu(), 
														s->getBDSSFossilSampRatePsi(), 
														s->getBDSSSppSampRateRho());
		return nps;
	}
	return 0.0;
}