Created
June 4, 2019 13:25
-
-
Save joelnitta/6f30a7c0f1c83d78c76a5469e935d56f to your computer and use it in GitHub Desktop.
convert DNAbin to DNAstring set
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
# Convert ape::DNAbin format to Biostrings::DNAStringSet format, | |
# optionally removing gaps | |
DNAbin_to_DNAstringset <- function (seqs, remove_gaps = TRUE) { | |
if(isTRUE(remove_gaps)) { | |
seqs %>% as.list() %>% as.character %>% | |
lapply(.,paste0,collapse="") %>% | |
lapply( function (x) gsub("-", "", x)) %>% | |
unlist %>% Biostrings::DNAStringSet() | |
} else { | |
seqs %>% as.list() %>% as.character %>% | |
lapply(.,paste0,collapse="") %>% | |
unlist %>% Biostrings::DNAStringSet() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment