Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. library("ape")
  2. library("Biostrings")
  3. library("ggplot2")
  4. library("ggtree")
  5.  
  6. setwd("")
  7.  
  8. nwk <- ("tree.newick")
  9. tree <- read.tree(nwk)
  10.  
  11. tipcategories = read.csv("tree.meta",
  12. sep = "\t",
  13. col.names = c("seq", "cat"),
  14. header = FALSE,
  15. stringsAsFactors = FALSE)
  16.  
  17. dd = as.data.frame(tipcategories)
  18.  
  19.  
  20. p <- ggtree(tree, layout = "rectangular", right = FALSE, ladderize = TRUE) +
  21. xlim(0, 0.025) + # to allow more space for labels
  22. geom_treescale() # adds the scale
  23.  
  24. p %<+% dd +
  25. geom_tiplab(aes(fill=factor(cat)),
  26. color = "black", # color for labels
  27. geom = "label", # labels not text
  28. label.padding = unit(0.15, "lines"),
  29. label.size = 0) +
  30. theme(legend.position=c(0.5,0.2),
  31. legend.title = element_blank(), # no title
  32. legend.key=element_blank()) # no keys
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement