Skip to main content

qt.tppl

function coalesceQTTree​

Processes a QTTree and conditions on its likelihood It traverses the nodes of tree and calls coalesceQTTwig on subtrees that have just two children who are leafs. @param tree @param m @param doresample - Whether to resample after processing the tree the idea is that the first invocation of this function should be with False, as it corresponds to outermost recursion; after that the subsequent recursive calls will have True @return QTTree that matches the QTWeightedLeaf constructor

function coalesceQTTree(tree: QTTree, m: ModelDynamics, doresample: Bool) => QTTree

function coalesceQTTwig​

coalesceQTTwig deals with a subtree that has two leafs as children (they can be weighted or unweighted)

function coalesceQTTwig(tree: QTTree, m: ModelDynamics, doresample: Bool) => QTTree

function computeMessageLogLikelihood​

NOTE(vsenderov, 2023-11-08) This function proved very easy to introduce bugs into. Makes the necesseity for writing tests even more apparent.

function computeMessageLogLikelihood(mes: Matrix[Real]) => Real

function evolveCharacter​

function evolveCharacter(mes: Matrix[Real], m: ModelDynamics, t: Real, sJumps: Int) => Matrix[Real]

function evolveMessageClosure​

Using the Q-T-BIRDS model, evolve a single message along a branch of length t @param dyn: ModelDynamics @param t: Real Time of evolution @param mes: Matrix[Real] The initial likelihood as a row vector If the mes has negative values, it is considered missing data

function evolveMessageClosure( dyn: ModelDynamics
, t: Real
, u: Real
, mes: Matrix[Real]
) => MessageEvolution

function evolveMessageSequence​

Using the Q-T-BIRDS model, evolve the messages along a branch of length t

function evolveMessageSequence( messages: Matrix[Real][]
, m: ModelDynamics
, t: Real
) => MessageSequenceEvolution

function gammaZeroMix​

function gammaZeroMix(rho: Bool, a: Real, b: Real) => Real

function getAgeDiff​

function getAgeDiff(parent: QTTree, child: QTTree) => Real

function getCharacterMessage​

function getCharacterMessage(tree: QTTree, messages: Real[][]) => Matrix[Real]

function getIndex​

function getIndex(tree: QTTree) => Int

function getMessage​

TODO/ WIP: What if the state is missing??

function getMessage(state: Int) => Matrix[Real]

function getMessageSequence​

function getMessageSequence(tree: QTTree) => Matrix[Real][]

function idInt​

function idInt(i: Int) => Int

function idSeq​

function idSeq(s: Real[]) => Real[]

function idSTensorReal​

function idSTensorReal(t: Matrix[Real][]) => Matrix[Real][]

function idTensorReal​

function idTensorReal(t: Matrix[Real]) => Matrix[Real]

function isMissing​

function isMissing(x: Matrix[Real]) => Bool

function meGetJumps​

workaround not elegant

function meGetJumps(mes: MessageEvolution) => Int

function meGetMessage​

workaround not elegant, otherwise name clash

function meGetMessage(mes: MessageEvolution) => Matrix[Real]

type MessageEvolution​

type MessageEvolution = MessageEvolution { message: Matrix[Real]
, sJumps: Int
}

type MessageSequenceEvolution​

type MessageSequenceEvolution = MessageSequenceEvolution {
messageSequence: Matrix[Real][],
characterJumps: Int
}

type ModelDynamics​

type ModelDynamics = ModelDynamics { qChar: Matrix[Real]
, jChar: Matrix[Real]
, qMol: Matrix[Real]
, jMol: Matrix[Real]
, nu: Real
, charMessages: Real[][]
// , molMessages: Real[][]
}

function mtxElemMulMissing​

Multiplies two tensors, ignores if missing data is encoded as -1. Hack!

function mtxElemMulMissing(a: Matrix[Real], b: Matrix[Real]) => Matrix[Real]

function qtbirds​

Q-T-BIRDS model @param tree: QTTree - Phylogenetic tree, the tips of which have sequence and phenotype information @param normQChar: Matrix[Real] - Normalized Q matrix for the phenotype @param JChar: Matrix[Real] - Jump matrix for the phenotype @param normQMol: Matrix[Real] - Normalized Q matrix for the gene @param JMol: Matrix[Real] - Jump matrix for the gene @param lamShape: Real - Hyperparameter of the Gamma distribution for the phenotype transition rate @param lamScale: Real - Hyperparameter of the Gamma distribution for the phenotype transition rate @param muShape: Real - Hyperparameter of the Gamma distribution for the gene transition rate @param muScale: Real - Hyperparameter of the Gamma distribution for the gene transition rate @param nuShape: Real - Hyperparameter of the Gamma distribution for the joint transition rate @param nuScale: Real - Hyperparameter of the Gamma distribution for the joint transition rate @param pa: Real - Prob of correlation rho ~ Beta(pa, pb) @param pb: Real - Prob of correlation rho ~ Beta(pa, pb) @return [lam, mu, nu, p]

model function qtbirds( tree: QTTree
, normQChar: Matrix[Real]
, jChar: Matrix[Real]
, charMessages: Real[][]
, normQMol: Matrix[Real]
, jMol: Matrix[Real]
, lamShape: Real
, lamScale: Real
, muShape: Real
, muScale: Real
, nuShape: Real
, nuScale: Real
, pa: Real
, pb: Real
) => Real[]

type QTParm​

type QTParm = QTParm { lambda: Real // Rate of phenotypic evolution
, mu: Real // Rate of molecular evolution
, nu: Real // Rate of joint evolution
}

type QTTree​

type QTTree =
| QTLeaf { age: Real

function tree2string​

function tree2string(tree: QTTree) => String