Skip to content

Instantly share code, notes, and snippets.

@darmitage
Created June 1, 2012 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darmitage/2848513 to your computer and use it in GitHub Desktop.
Save darmitage/2848513 to your computer and use it in GitHub Desktop.
Cleaning up OTU tables and Phylogenies
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