Created
August 7, 2017 22:51
-
-
Save lwaldron/75e8226c319965189c4d084c41a932c1 to your computer and use it in GitHub Desktop.
Write a one-column table of all metaphlan2 taxa at all levels of taxonomy
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
library(curatedMetagenomicData) | |
newicklabs <- getMetaphlanTree(simplify=FALSE)$tip.label | |
delims <- paste0("\\|", c("p", "c", "o", "f", "g", "s"), "__.+") | |
res <- lapply(delims, function(x) sub(x, "", newicklabs)) | |
res <- unique(unlist(res)) | |
res <- c(res, grep("s__", newicklabs, val=TRUE)) | |
res <- sort(res) | |
res <- grep("GCF", res, invert=TRUE, val=TRUE) | |
res <- grep("noname$", res, invert = TRUE, value = TRUE) | |
write.table(res, file="~/Downloads/metaphlantaxa.tsv", row.names=FALSE, col.names = FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment