This is a bioinformatic question.
For those of you familiar with ggtree, how do I go about annotating numerical information per node and tip in ggtree?
Say for example I have a phylogenetic tree, and for each node and tip I have a gene-count. How can I annotate this relevant information next to the node and tip? I have csv file (dataframe) where the rows have the following information:
Node Name | Count |
---|---|
A | 12 |
B | 14 |
For my tree I want the number 12 to show attached to node A and 14 next to node B.
This gives me a tree no issue:
library(tidyverse)
library(ggtree)
# the path to the tree files is
tree <- read.tree("tree.txt")
ggtree(tree,branch.length = 'none') + theme_tree2()+geom_tiplab(align=TRUE, linesize=.5)+ xlim(0,25)
ggsave("test_2.pdf", width = 60, height = 80, units = "cm", limitsize = FALSE)
But my gene tree could use some annotations with numbers, speciifically I want to be able to add number relevant to each node and tip.
I have looked around and this tutorial is about as close as I can come to describing what I want to do but I am not being able to set the code just right.
This is the closest I came but keep getting the error Error in UseMethod("left_join") : no applicable method for 'left_join' applied to an object of class "NULL"
.
library(tidyverse)
library(ggtree)
dd <- read.table(file = 'raw_data/counts.csv',sep='\t',header=TRUE) # this is the data frame where one column is the name of tips and rows and the second column named 'Increase' is the count per tip and node
# row.names(dd) <- NULL
tree <- read.tree("raw_data/tree.txt") # this is the tree
tree <- tree %<+% dd + geom_tiplab() + geom_tippoint(aes(size=Increase), alpha=0.25) # this is what I was hoping would add the data frame data to the tree