This is a test version of Biostars. For the public version, visit https://www.biostars.org.
plotting phylogenetic trees using R

I wanted to remove one of the taxa from the tree. so i downloaded ape package and using drop.tip i could remove the taxa. but I am unable to print/plot the modified tree. i tried using plot() for plotting the tree but it seems to be specified with ylim values. how do i get ylim values for the tree? or is there a different way of plotting the tree?

thank you

r phylogenetic tree

Please add the code you used, ideally with a minimum reproducible example (i.e. a small dataset that we can use to reproduce your problem). Also, for plotting trees take a look at the ggtree package and its documentation, for example the introduction.

I used the following:

library (ape)
phylo <-read.tree ("mytree.nwk")
drop.tip (phylo, "taxa_name")

With this the taxa I wanted to remove was removed and the tree now had a taxa less than what it had. I do not know how to display/ rite/plot the modified tree

Take a look at ?drop.tip documentation. There it says the returned value from drop.tip is a phylo object. Therefore, you need to assign the returned value to a variable and plot that.

how do I do that? I am using R for the first time. can you please help me with the code?

OK, something like this:

library(ape)
tree <- read.tree("mytree.nwk") # read tree, assign to variable tree.
plot(tree) # you can plot this.
tree2 <- drop.tip (tree, "taxa_name") # drop taxa, returns a modified tree. we assign it to variable tree2.
plot(tree2) # you can also plot this.

I would highly recommend you to read some introduction to R. There are many in the documentation section at http://www.r-project.org

it worked. thank you so much! Can I export this tree in newick format?

Try reading ?write.tree.

0 answers

No answers yet.

Log in to answer this question.