Created
June 1, 2012 03:37
-
-
Save darmitage/2848513 to your computer and use it in GitHub Desktop.
Cleaning up OTU tables and Phylogenies
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
phy = read.tree("mytree.tre") | |
samp = read.table("OTUtable.txt", head = T, sep = "") | |
#lists taxa in OTU table that are not in the phylogeny, and removes them | |
samp = (samp[rowSums(samp) != 0, , drop=FALSE]) | |
samp = t(samp) | |
phy = prune.sample(samp, phy) | |
labs <- phy$tip.label | |
length(labs) | |
ncol(samp) | |
sampnames <- colnames(samp) | |
sampnames[!(sampnames %in% labs)] | |
samp <- samp[,labs] | |
#code for removing OTUs who don't belong in the diversity profile (i.e., zero for all communities) | |
samp = samp[,colSums(samp) != 0] | |
phy = prune.sample(comm, phy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment