Genealogy part 7 - veeninglab/BactMAP GitHub Wiki
There are many more possibilities for tree & network manipulation within the ggplot realm you can discover. Here are two cool options:
The reason I added the igraph network in the output of SuperSegger and
Oufti is that it makes it easier to use other network plotting options
than ggtree
.
Technically, the types of trees we are plotting are no phylogenetic
trees, they are networks with a time element. Therefore, you might
prefer other network plotting options. Here I’ll give a very brief
introduction to ggraph
.
If you want to install ggraph
,
run the following lines:
install.packages("ggraph")
Then, load the package. Check the vignette’s on the ggraph
github
page for more information.
Essentially, this package is a set of additions to the
ggplot2
functions specified for networks,
with functions as geom_edge()
and geom_node_point()
.
Here I just make a simple network plot without x/y-labels and a minimal theme:
library(ggraph)
ggraph(myTreeNetwork, 'dendrogram') +
geom_edge_diagonal() +
geom_node_point() +
xlab("") +
ylab("") +
theme_minimal() +
theme(axis.text = element_blank())
As you see, this plot doesn’t show the edgelength
(or division time),
in contrary to the plots we made above. In general I find the ggraph
networks a bit more difficult to manipulate when it comes to x/y-scales,
which is one of the reasons why I chose to base the tree plots in
bactMAP
on ggtree
.
To follow up on the previous chapter, it is quite hard to see the generation change in fluorescence, but what if we can follow the mother-daughter cells over time in the graph? Let’s do a quick animation.
First I make the clade plot again, then I group my cells in groups when
they split. After that, I add a variable frame
into my geom_point()
to indicate what I want to change in my animation: these are the groups
in which I want my cells to appear. Finally, I use the package
plotly
to animate the plot.
yplot_clade <- plotTreeBasic(myTreePhylo, myTreeDF,
yscalechange=TRUE, ydata="fluormean_D",
showClade=TRUE, cellNumber=6, lines=TRUE, colors=TRUE,
layout="slanted")
yplot_clade$data$birthgroup <- as.character(cut(yplot_clade$data$death, 8, labels=1:8))
yplot_clade$data$birthgroup[yplot_clade$data$group==0] <- "0"
yplot_clade_animate <- yplot_clade +
scale_linetype_manual(values=c("dotted", "solid")) +
scale_color_manual(values=c("grey", "black")) +
geom_point(data=yplot_clade$data[yplot_clade$data$group!=0,],aes(fill=fluormean_D, frame=birthgroup),shape=21,
linetype="solid", size=3) +
scale_fill_viridis_c() +
theme(legend.position="none")
Then run the following to turn it into an animation:
install.packages("plotly")
library(plotly)
ggplotly(yplot_clade_animate)
What you probably are still waiting for (at least I would!) is plots where the intermediate states of the cell cycle are also put inside the phylogenetic tree. This is still in the making. Another thing which I would really like to add is single cell images. Open an issue on our GitHub page if you have specific requests or suggestions.
⬅️ Genealogy Part 6: More Tree Manipulation | Genealogy Part 8: Resources ➡️ |
---|