Hi John,

John Denton wrote on 31/01/2011 01:30:
Hi folks,

I'm starting to use APE, and am trying to write a script to iteratively
prune taxa from an alignment / tree combination and print the reduced
datasets to separate files.

I was thinking of using some combination of drop.tip + DNAbin, but I am
unsure of how to link removing the tip labels in the tree and the
corresponding taxon labels in the alignment in such a way that the
iteration completes without redundancy.

Assuming that the set of labels are the same between the tree and the alignment, which can be checked with:

all(tr$tip.label %in% rownames(x)) && all(rownames(x) %in% tr$tip.label)

(tr is the tree, x is the alignment), you may do:

for (a in tr$tip.label) {
     write.tree(drop.tip(tr, a), file = ....
     write.dna(x[rownames(x) != a, ], file = ....
}

You have to find a way to create your file names, these could be:

paste("tree_whithout_", a, ".tre", sep = "")
paste("alignment_whithout_", a, ".phy", sep = "")

These are all standard R manipulations.

Best,

Emmanuel

Is there a function or loop you could recommend?

~John

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


--
Emmanuel Paradis
IRD, Jakarta, Indonesia
http://ape.mpl.ird.fr/

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to