How do I annotate a ggtree object with bootstrap values?
1
0
Entering edit mode
6 weeks ago
Yarabi • 0

Hello everyone,

I have made a phylogenetic tree using IQTREE and visualized it with R package "ggtree" and I want to add bootstrap value, does anyone know how can I do it?

Here's the code I used.

library(ggtree)
library(viridis)
library(gdata)
library(dplyr)
library(readxl)
library(ggplot2)
library(ggnewscale)
library(gplots)
library(paletteer)


#Cargar el archivo newick que se genero en IQTree
secuencia_aa_NSs_tree <- read.tree("Secuencia_aa_NSs_Alineadas.txt.treefile")
#Cargar el archivo excel con los ID y las clasificaciones
datos <- read_excel("Secuencias_aa_NSs_R.xlsx")
#Crear Dataframe para el estado y tejido
Estado <- data.frame("Estado" = datos$Estado)
Tejido <- data.frame("Tejido" = datos$Tejido)
rownames(Estado) <- datos$ID_nuevo
rownames(Tejido) <- datos$ID_nuevo
#Cambiar nombres de los ID
secuencia_aa_NSs_tree$tip.label <- datos$ID_nuevo
#Crear grafico ggtree
p1 <- ggtree(secuencia_aa_NSs_tree, branch.length = 'none', layout = 'circular') +
    geom_tiplab(size = 3) +
    theme(
        legend.position = "none",
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        plot.title = element_text(
            size = 20,
            face = "bold",
            hjust = 0.5,
            vjust = -15
        )
    )
p1 <- p1 + theme(plot.margin = margin(0, 0, 0, 0, "cm")) #Ajustar segun necesidades

p2 <- gheatmap(p1, Estado,
               offset = 1.0,
               width = 0.23,
               color = NULL,
               colnames = FALSE) +
    scale_fill_manual(name = "Estado",
                      values = c("Severo" = alpha("#C03211", 0.5),
                                 "Leve"= alpha ("#1E8449", 0.5)),  
                      breaks = c("Severo", "Leve"),
                      labels = c("Severo", "Leve")) +
    theme(legend.position = "right",
          legend.title = element_text(size = 12),
          legend.text = element_text(size = 12),
          legend.box = "vertical", legend.margin = margin()) +
    guides(fill = guide_legend(keywidth = 0.7, keyheight = 0.7))   # Ajusta keywidth segĂșn tus necesidades
p3 <- p2 + new_scale_fill()

#show tree
print(p3)
ggtree phylogenetic-tree R bootstrap • 244 views
ADD COMMENT
0
Entering edit mode
6 weeks ago
inedraylig ▴ 60

It is quite difficult to know how to answer this without seeing your data. Also, the ggtree documentation is very good and comprehensive, with very good examples for this. If the bootstrap values are stored in the newick format under label, you'll want something like

+ geom_label2(aes(label=label)

ADD COMMENT

Login before adding your answer.

Traffic: 1605 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6