Skip to content

Genealogy Part 6

Renske van Raaphorst edited this page Oct 18, 2019 · 2 revisions

More tree manipulation

You might decide that another layout makes more sense for you. You can flip the plot or reverse the scales (check out the ggplot2 vignette for options), or pick one of the ggtree layouts. I go for a circular layout this time. In this way the time scale is still intuitive, and there is more space between the cells so I can label them without making the plot too big:

#make the tree but now with other layout. angle=0 means that the whole circle will be filled with our plot.
angletree <- plotTreeBasic(myTreePhylo, myTreeDF, layout="fan", open.angle=0)

#basic tree, I change the theme so gridlines appear.
angletree1 <- angletree +
  theme_bw() +
  theme(axis.text.x=element_blank()) +
  xlab("Time (frames)")

#now I add both the colored points & the cell labels again.
angletree2 <- angletree1 +
  geom_point(aes(x=x-branch.length, color=fluormean), size=8) +
  geom_tippoint(aes(color=fluormean_D), size=5) +
  geom_label(aes(x=x-branch.length, label=label), color=NA, fill="white", alpha=0.5, size=1) +
  #I also make a seethrough background label so you can see the text over the colored dots
  geom_text(aes(x=x-branch.length, label=label), size=3) +
  scale_color_viridis_c(option="inferno")

Call for the plots if you want to see them in your console.

4.4 Change the y-axis of the plot

In tree and network plots, the y axis of the plot is normally just arbitrary to generate enough space between the nodes and tips of the tree. However, you can change the y-axis to something with more meaning, like the fluorescence of the cells in our case.

It is possible but quite tricky to play with the y-axis data in ggtree objects, therefore I added the feature into the plotTreeBasic() function. To use it, set yscalechange to TRUE. Here’s two examples of plots, one with the regular “rectangular” layout, and one where the layout is set to “slanted”.

#add the basic plot again:

yplot_rectangular <- plotTreeBasic(myTreePhylo, myTreeDF, yscalechange=TRUE, ydata="fluormean_D")

yplot_slanted <- plotTreeBasic(myTreePhylo, myTreeDF, yscalechange=TRUE, ydata="fluormean_D", layout="slanted")

You can see that in our case, it becomes quite messy. Partly because we have no information on fluorescence between birth & death, partly because all lines are just walking through each other so it’s impossible to follow any cell, and partly because the change in fluorescence is pretty sudden. We can make it a bit easier on our eyes by picking a group of cells to focus on. From the “angletree2” figure above, it seems that cell 28 seems quite an interesting parent cell: one of it’s children becomes very, very fluorescent, the other not. It’s a bit hard to see who is the parent of cell 28 in the plot though. Let’s find out by looking in myTreeDF. I want to see the column of cell 28 to find out which cell is the parent. This I can do by subsetting:

myTreeDF[myTreeDF$cell==28,]
##    node cell birth death edgelength fluorsum fluormean fluorsum_D
## 28  131   28     9    16          7    75096  466.4348     133917
##    fluormean_D parent child1 child2 root nodelabel
## 28    469.8842    110     52     53    0         6

Here you can see that the node=131, cell=28, parent=110 and nodelabel=6. node and parent are the numbers which indicate their location on the tree, while cell and nodelabel are the original numbers the segmentation program gave the cells. Here, nodelabel is the number of the cell's parent, so the cell number we are looking for is 6.

Let’s highlight this “clade” by putting showClade=TRUE and cellNumber=6 into plotTreeBasic():

yplot_clade <- plotTreeBasic(myTreePhylo, myTreeDF,
                              yscalechange=TRUE, ydata="fluormean_D",
                              showClade=TRUE, cellNumber=6, lines=TRUE, colors=TRUE,
                              layout="slanted")


yplot_clade +
  scale_linetype_manual(values=c("dotted", "solid")) +
  scale_color_manual(values=c("grey", "black")) +
  geom_point(aes(fill=fluormean_D, color=group),shape=21,
             linetype="solid", size=3) +
  scale_fill_viridis_c()


⬅️ Genealogy Part 5: Fluorescence Data Genealogy Part 7: Using other packages ➡️
Clone this wiki locally