Hi, all. I'm working on a script that iteratively removes taxa from an initial total tree and re-searches for optimal (pruned) topologies after outputting a pruned alignment.
I'm trying to get a few things to happen: First, the script iteratively checks to make sure that the taxon names match in the alignments and trees, and terminates if they do not. I can get it to print that the matches are okay as it checks each taxon: for (i in totaltr$tip.label) { if (all(totaltr$tip.label %in% rownames(alig)) && all(rownames(alig) %in% totaltr$tip.label)) cat("OK: Taxon labels match in tree and alignment") else stop("Taxon labels do not match. Script terminates.") } But I want each line of "OK: Taxon labels match...." and "Taxon labels do not match" to print the name of the taxon being checked, or the taxon for which a match does not occur, something like "Taxon labels match in tree and alignment FOR TAXON i." and "Taxon labels do not match FOR TAXON i. Script terminates." Suggestions? Second, I want the script to store a list of the tree lengths it calculates as it goes. I can calculate tree lengths via sum(tree.name$edge.length), but I am having trouble, it seems, initializing and storing the list. The code I have is ts.values <- list() length(ts.values) <- length(row.names(alig)) for (i in totaltr$tip.label) { if (all(totaltr$tip.label %in% rownames(alig)) && all(rownames(alig) %in% totaltr$tip.label)) cat("OK: Taxon labels match in tree and alignment") else stop("Taxon labels do not match. Script terminates.") } Sys.sleep(3) for (i in totaltr$tip.label) { write.tree(drop.tip(totaltr, i), file = paste("minus_", i, ".tre", sep = "") ) ts.values[[i]] <- {sum(drop.tip(totaltr, i)$edge.length)} } So ts.values is the list I am trying to store the tree lengths in. After the script finishes, though, I try to call ts.values via print(ts.values), but it says the object does not exist. I am tinkering with these two problems using a modified version of the phymltest routine in the ape package, so the tree/alignment filenames written are for phyml output. Suggestions? Thanks a lot. ~John -- "ORGANIC LIFE beneath the shoreless waves Was born and nurs'd in ocean's pearly caves; First forms minute, unseen by spheric glass, Move on the mud, or pierce the watery mass; These, as successive generations bloom, New powers acquire and larger limbs assume; Whence countless groups of vegetation spring, And breathing realms of fin and feet and wing." ~Erasmus Darwin, The Temple of Nature Canto I.V _______________________________________________ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo