Open Espinosa-Gongora opened 2 years ago
I think you can use ggtreeExtra
to plot it. The input is from the #367
tr <- "((((((Dasyurus_hallucatus:6.42500000,(Dasyurus_viverrinus:5.67801667,Dasyurus_maculatus:5.67801667)'14':0.74698333)'13':0.69500000,Sarcophilus_harrisii:7.12000000)'11':50.05805636,(Isoodon_macrourus:25.20000000,Macrotis_lagotis:25.20000000)'10':31.97805636)'19':4.45095364,((Phascolarctos_cinereus:35.00972500,Lasiorhinus_latifrons:35.00972500)'9':13.93526577,(((Potorous_tridactylus:23.93946385,(((Macropus_rufogriseus:7.72000000,(Macropus_rufus:7.31500000,Macropus_giganteus:7.31500000)'22':0.40500000)'8':0.00000000,Wallabia_bicolor:7.72000000)'6':1.35000000,Dendrolagus_lumholtzi:9.07000000)'30':14.86946385)'29':23.65610282,(Trichosurus_vulpecula:4.03000000,Trichosurus_caninus:4.03000000)'27':43.56556667)'35':0.66887333,(Petaurus_norfolcensis:32.91610000,Pseudocheirus_peregrinus:32.91610000)'43':15.34834000)'42':0.68055077)'40':12.68401923)'48':96.96857758,Canis_lupus:158.59758758)'51':18.32991064,(Ornithorhynchus_anatinus:45.62328444,Tachyglossus_aculeatus:45.62328444)'47':131.30421377);"
metadata.example <- structure(list(Genus_species.number1 = c("1", "0", "0", "1", "1", "0", "0", "0", "1", "0", "0", "1", "1", "1", "0", "1", "0", "0", "0", "1", "1"), Genus_species.number2 = c("0", "0", "0", "0", "1", "0", "0", "1", "1", "0", "0", "0", "0", "1", "1", "1", "0", "0", "0", "1", "0")), class = "data.frame", row.names = c("Canis_lupus", "Dasyurus_hallucatus", "Dasyurus_maculatus", "Dasyurus_viverrinus", "Dendrolagus_lumholtzi", "Macropus_giganteus", "Macropus_rufogriseus", "Macropus_rufus", "Macrotis_lagotis", "Ornithorhynchus_anatinus", "Petaurus_norfolcensis", "Phascolarctos_cinereus", "Potorous_tridactylus", "Pseudocheirus_peregrinus", "Sarcophilus_harrisii", "Tachyglossus_aculeatus", "Trichosurus_caninus", "Trichosurus_vulpecula", "Wallabia_bicolor", "Isoodon_macrourus", "Lasiorhinus_latifrons"))
library(ggtree)
library(ggtreeExtra)
library(ggplot2)
metadata.example %>% tibble::as_tibble(rownames='id') %>% tidyr::pivot_longer(cols=!id, names_to='type', values_to='number') -> dat
dat
tree <- read.tree(text=tr)
p <- ggtree(tree, right=T) +
geom_tiplab(size=2.8)+
geom_fruit(
data=dat,
geom=geom_tile,
mapping=aes(x=type,y=id,fill=number),
color='grey',
offset=.25,
axis.params=list(
axis='x',
text.angle=-45,
hjust=0,
text.size=2.8,
line.size=0,
fontface=3)
) +
ylim(-2, NA) +
scale_fill_manual(values= c("grey90", "grey20"))
p
Thank you Xiangpin, indeed finally the colnames are in italics, but I am afraid using this format I cannot figure out how to add the numeric labels to the heatmap (i.e., the values inside each tile). Do you have any suggestions? (Note: I am trying to avoid a colour legend, this is why I opt for the labels).
gheatmap supports family, and other edits of the colnames, but does not support fontface. Any chance fontface="italic" could be added?
Originally posted by @Espinosa-Gongora in https://github.com/YuLab-SMU/ggtree/issues/367#issuecomment-1085961370