separating legends of heatmaps in ggtree

I’ve been having great success with ggtree now and have recommended it to several colleages here in Oxford. Is there any way to seperate the legend in heatmaps? Eg I have plotted a tree in a circular style with outer rings given extra data - I would like a seperate key for each ring - is this possible? This is a user question. Plotting multiple heatmaps that align to the phylogenetic tree is easy with gheatmap function. Here is a simple example: library("ggplot2") library("ggtree") nwk <- system.file("extdata", "sample.nwk", package="treeio") tree <- read.tree(nwk) circ <- ggtree(tree, layout = "circular") df <- data.frame(first=c("a", "b", "a", "c", "d", "d", "a", "b", "e", "e", "f", "c", "f"), second= c("z", "z", "z", "z", "y", "y", "y", "y", "x", "x", "x", "a", "a")) rownames(df) <- tree$tip.label p1 <- gheatmap(circ, df[, "first", drop=F], offset=.8, width=.1, colnames_angle=90, colnames_offset_y = .25) p2 <- gheatmap(p1, df[, "second", drop=F], offset=5, width=.1, colnames_angle=90, colnames_offset_y = .25)

rename phylogeny tip labels in treeio

I don’t know whether ‘rename taxa’ is a common task or not. It seems not a good idea to rename taxa in Newick tree text, since it may introduce problems when mapping the original sequence alignment to the tree. If you just want to show different or additional information when plotting the tree, it is fine and easy to do it using ggtree:

setting ggplot2 background with ggbackground

ggimage 0.1.4 is available on CRAN. This release introduces a new function called ggbackground for setting image background as ggplot canvas. require(ggplot2) p <- ggplot(iris) + aes(x = Sepal.Length, y = Sepal.Width, color=Species) + geom_point(size=5) + theme_classic() Suppose we have the above ggplot object, p, the only thing we need to do is passing the p with an image file name (local or remote) to ggbackground, as demonstrated below:

Annotating phylogenetic tree with images using ggtree and ggimage

With ggimage, we are able to plot images using grammar of graphics. The layers defined in ggimage can be directly applied to ggtree to annotate phylogenetic tree using local/online image files. ggtree seamlessly work with ggimage. The geom_tiplab and geom_nodelab can accept parameter of geom="image" to parse taxa labels as image files and use them to “label” the taxa using images instead of text strings. Here are some examples for demonstration.

visualizing reassortment history using seqcombo

Reassortment is an important strategy for influenza A viruses to introduce a HA subtype that is new to human populations, which creates the possibilities of pandemic. A diagram showed above (Figure 2 of doi:10.1038/srep25549) is widely used to illustrate the reassortment events. While such diagrams are mostly manually draw and edit without software tool to automatically generate. Here, I implemented the hybrid_plot function for producing publication quality figure of reassortment events. library(tibble) library(ggplot2) n <- 8 virus_info <- tibble( id = 1:7, x = c(rep(1990, 4), rep(2000, 2), 2009), y = c(1,2,3,5, 1.5, 3, 4), segment_color = list( rep('purple', n), rep('red', n), rep('darkgreen', n), rep('lightgreen', n), c('darkgreen', 'darkgreen', 'red', 'darkgreen', 'red', 'purple', 'red', 'purple'), c('darkgreen', 'darkgreen', 'red', 'darkgreen', 'darkgreen', 'purple', 'red', 'purple'), c('darkgreen', 'lightgreen', 'lightgreen', 'darkgreen', 'darkgreen', 'purple', 'red', 'purple')) ) flow_info <- tibble(from = c(1,2,3,3,4,5,6), to = c(5,5,5,6,7,6,7)) hybrid_plot(virus_info, flow_info)

shadow text effect in grid and ggplot2 graphics

After the release of meme package, I received several feedbacks from users. The most usefule one is the comment on my blog post: Sercan Kahveci Greetings Mr. Yu, I am very happy that this package exists. Thank you for making it! I would like to request a feature, to ensure the package is able to compete with professional meme-creation tools like memegenerator and paint.net. Since memes often use the font Impact, in white and with black outline, I believe the package would be more powerful if it also did that automatically. Regards, Sercan Kahveci, MSc Content creator at Questionable Research Memes on Facebook https://www.facebook.com/QResearchMemes/ The words, ‘compete with professional meme-creation tools’, stimulated me to develop text plotting with background outline effect. Now this feature is available in meme v>=0.0.7, which can be downloaded from CRAN.

create meme in R

I developed a tiny toy package, meme, which is now on CRAN. As it’s name indicated, it was designed to create memes, which are captioned photos that are intended to be funny, riduculous. meme() The package is quite simple. You can use meme() function to add meme captions, and this is all the package supposed to do: library(meme) u <- "http://www.happyfamilyneeds.com/wp-content/uploads/2017/08/angry8.jpg" meme(u, "code", "all the things!")

joyplot for GSEA result

I am very glad to find that someone figure out how to use ggjoy with ggtree. I really love ggjoy and believe it can be a good tool to visualize gene set enrichment (GSEA) result. DOSE/clusterProfiler support several visualization methods.

pixel art of ggplot2 faceting using geofacet

I just discovered an interesting ggplot2 extension, geofacet, that supports arranging facet panels that mimics geographic topoloty. After playing with it, I realized that it is not only for visualizing geo-related data, but also can be fun for presenting data to mimics pixel art.

[Bioc 3.5] NEWS of my BioC packages

I have 8 packages published within the Bioconductor project. ChIPseeker clusterProfiler DOSE ggtree GOSemSim meshes ReactomePA treeio A new package treeio was included in BioC 3.5 release.