likelihood.msa: MSA Likelihood

Description Usage Arguments Value Author(s) See Also Examples

View source: R/msa.R

Description

Likelihood of an alignment given a tree model

Usage

1
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).

Author(s)

Melissa J. Hubisz and Adam Siepel

See Also

phyloFit, tm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)

rphast documentation built on May 1, 2019, 9:26 p.m.