Learn R Programming

rphast (version 1.6.9)

likelihood.msa: MSA Likelihood

Description

Likelihood of an alignment given a tree model

Usage

likelihood.msa(x, tm, features = NULL, by.column = FALSE)

Arguments

x

An object of class msa representing the multiple alignment

tm

An object of class tm representing the tree and model of substitution

features

A features object. If non-null, compute likelihoods for each feature rather than the whole alignment.

by.column

Logical value. If TRUE, return the log likelihood for each alignment column rather than total log likelihood. Ignored if features is not NULL.

Value

Either the log likelihood of the entire alignment (if by.column==FALSE && is.null(features), or a numeric vector giving the log likelihood of each feature (if !is.null(features)), or a numeric vector giving the log likelihood of each column (if by.column==TRUE).

See Also

phyloFit, tm

Examples

Run this code
# NOT RUN {
files <- c("rev.mod", "ENr334-100k.maf", "ENr334-100k.fa", "small.gff")
exampleArchive <- system.file("extdata", "examples.zip", package="rphast")
unzip(exampleArchive, files)
msa <- read.msa("ENr334-100k.fa")
mod <- read.tm("rev.mod")
likelihood.msa(msa, mod)
like1 <- likelihood.msa(msa, mod, by.column=TRUE)
length(like1)==ncol.msa(msa)
sum(like1)
msa <- read.msa("ENr334-100k.maf")
likelihood.msa(msa, mod)
like2 <- likelihood.msa(msa, mod, by.column=TRUE)
sum(like2)
mod$subst.mod <- "JC69"
likelihood.msa(msa, mod)
#'
# can also get likelihood by feature
features <- read.feat("small.gff")
features$seqname <- names(msa)[1]
likelihood.msa(msa, mod, features=features)
unlink(files)
# }

Run the code above in your browser using DataLab