-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added in function to return the mll of the root node of a hierarchy
- Loading branch information
1 parent
cfe08b3
commit b5d3b63
Showing
8 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: fastbaps | ||
Title: A fast genetic clustering algorithm that approximates a Dirichlet Process Mixture model | ||
Version: 1.0.0 | ||
Authors@R: person("Gerry", "Tonkin-Hill", email = "[email protected]", role = c("aut", "cre")) | ||
Authors@R: person("Gerry", "Tonkin-Hill", email = "[email protected]", role = c("aut", "cre")) | ||
Description: Takes a multiple sequence alignment as input and clusters according to the 'no-admixture' model. | ||
It combines ideas from the Bayesian Hierarchical Clustering algorithm of Heller et al. <doi:10.1145/1102351.1102389> | ||
and hierBAPS <doi:10.1093/molbev/mst028> to produce a rapid and accurate clustering algorithm. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#' root_mll | ||
#' | ||
#' Function to calculate the marginal log likelihood of the root of a hierarchy for use in model comparison. | ||
#' | ||
#' @import Matrix | ||
#' | ||
#' | ||
#' @param sparse.data a sparse SNP data object returned from import_fasta_sparse_nt | ||
#' @param h a hclust object representing the hierarchical clustering | ||
#' @param quiet suppress the printing of extra information (default=FALSE) | ||
#' | ||
#' @return the marginal log likelihood of the root node | ||
#' | ||
#' @examples | ||
#' fasta.file.name <- system.file("extdata", "seqs.fa", package = "fastbaps") | ||
#' fasta.file.name <- system.file("extdata", "seqs.fa", package = "fastbaps") | ||
#' sparse.data <- import_fasta_sparse_nt(fasta.file.name) | ||
#' baps.hc <- fast_baps(sparse.data) | ||
#' root_mll(sparse.data, baps.hc) | ||
#' | ||
#' @export | ||
root_mll <- function(sparse.data, h, quiet=FALSE){ | ||
|
||
# Check inputs | ||
if(!is.list(sparse.data)) stop("Invalid value for sparse.data! Did you use the import_fasta_sparse_nt function?") | ||
if(!(class(sparse.data$snp.matrix)=="dgCMatrix")) stop("Invalid value for sparse.data! Did you use the import_fasta_sparse_nt function?") | ||
if(!is.numeric(sparse.data$consensus)) stop("Invalid value for sparse.data! Did you use the import_fasta_sparse_nt function?") | ||
if(!is.matrix(sparse.data$prior)) stop("Invalid value for sparse.data! Did you use the import_fasta_sparse_nt function?") | ||
if(!(class(h) %in% c("hclust", "phylo"))) stop("Invalid value for h! Should be a hclust or phylo object!") | ||
|
||
llks <- tree_llk(sparse.data, h$merge) | ||
root.mll <- llks$ptree[length(llks$ptree)] | ||
|
||
return(root.mll) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.