# script to import CC phylo nexus, alter focal Order tree, re-export CC phylo nexus with new tree # remove objects from workspace rm(list=ls()) install.packages(c('ouch','ape')) library(ouch) library(ape) ## run script 'tc2ape' to create function is(tc2ape,'function') # should be true ## read in csv of example 'Hemiptera-taxon-container.csv' hemip <- read.csv('hemiptera-taxon-container.csv',colClasses='character') ## examine structure, 2 columns str(hemip) # check: how many clades have blank ancestors hemip$Container[!as.character(hemip$Container) %in% as.character(hemip$Taxon)] # should be 1 empty # check: how many taxa? length(hemip$Taxon[!as.character(hemip$Taxon) %in% as.character(hemip$Container)]) # should == number of tips/taxa ## use custom function to make tree object hemip.tr <- tc2ape(hemip) summary(hemip.tr) write.tree(hemip.tr) plot(hemip.tr,cex=0.5,type='p') ## now this tree can be grafted onto other trees, analyzed using picante etc.