Created
June 4, 2019 13:54
-
-
Save joelnitta/53786e4647ce05643df7291f2953310c to your computer and use it in GitHub Desktop.
Concatenate a list of aligned genes
This file contains hidden or 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
#' Concatenate a list of aligned genes | |
#' | |
#' @param dna_list List of matrices of class DNAbin | |
#' | |
#' @return Matrix of class DNAbin | |
#' | |
#' @examples | |
#' data(woodmouse) | |
#' gene_1 <- woodmouse[,1:100] | |
#' gene_2 <- woodmouse[,101:200] | |
#' woodmouse_genes <- list(gene_1, gene_2) | |
#' concatenate_genes(woodmouse_genes) | |
concatenate_genes <- function (dna_list) { | |
require(apex) | |
assertthat::assert_that(is.list(dna_list)) | |
assertthat::assert_that(all(lapply(dna_list, class) == "DNAbin"), | |
msg = "All elements of dna_list must be of class DNAbin") | |
assertthat::assert_that(all(sapply(dna_list, is.matrix)), | |
msg = "All elements of dna_list must be matrices") | |
dna_multi <- new("multidna", dna_list) | |
apex::concatenate(dna_multi) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment