Animating the Cell Cycle
Dec 28, 2020
Introduction
There are many ways to visualize the same data. In Xia*, Fan*,Emanuel* et al (2019), we used transcriptome-scale MERFISH along with RNA velocity in situ analysis to identify genes associated with the cell cycle. For more details on the analysis, please refer to the original manuscript or check out RNA Velocity Analysis (In Situ) - Tutorials and Tips.
Static visualizations
To visualize these identified cell cycle genes, we used a variety of different static visualizations, including those similar to the ones below. These tSNE plots visualize cells as points and are colored by scaled gene expression magnitude of select identified cell cycle genes.
m <- mat[genes.final,]
m <- t(scale(t(m)))
m[m > 2] <- 2
m[m < -2] <- -2
library(ggplot2)
ps <- lapply(seq_along(genes.final), function(i) {
gexp <- m[genes.final[i], rownames(emb.test)]
df <- data.frame(emb.test, gexp)
p <- ggplot(df, aes(x = X1, y = X2, col=gexp)) + geom_point()
p <- p + theme_void() +
theme(legend.position = "none") +
scale_color_distiller(palette = 'RdBu',
limits = c(-2,2)) +
labs(title = genes.final[i])
p
})
library(gridExtra)
grid.arrange(
grobs = ps,
nrow=4, ncol=4
)
In the original manuscript, we also used heatmaps to visualize the pseudotemporal ordering of cells versus the peak expression of identified cell cycle genes and scatterplots of the pseudotemporal ordering of cells versus gene expression magnitude to visualize the shifting peak expression of cell cycle genes along pseudotime. Each visualization seeks to communicate and highlight a different aspect of the results.
Animating with gganimate
Still, when we are able to operature outside of traditional printed media and static visualizations, we can now take advantage of the additional time dimension for visualization offered by animations! We can use the gganimate
package to visualize the same cell cycle genes as above.
library(gganimate)
df.all <- do.call(rbind, lapply(1:length(genes.final), function(i) {
gexp <- m[genes.final[i], rownames(emb.test)]
df <- data.frame(emb.test, gexp, gene=genes.final[i], order=i)
}))
p <- ggplot(df.all, aes(x = X1, y = X2, col=gexp)) + geom_point()
p <- p + theme_void() +
theme(legend.position = "none") +
scale_color_distiller(palette = 'RdBu',
limits = c(-2,2))
anim <- p +
transition_states(order,
transition_length = 5,
state_length = 1) +
labs(title = '{genes.final[as.integer(closest_state)]}') +
theme(plot.title = element_text(size = 28)) +
geom_point(size = 5) +
enter_fade()
anim
For more information about gganimate
, check out:
- Older
- Newer
RECENT POSTS
- 3D animation of the brain in R on 08 November 2022
- Ethical Challenges in Biomedical Engineering - Data Collection, Analysis, and Interpretation on 15 October 2022
- I use R to (try to) figure out the cost of medical procedures by analyzing insurance data from the Transparency in Coverage Final Rule on 12 September 2022
- Annotating STdeconvolve Cell-Types with ASCT+B Tables on 30 August 2022
- Deconvolution vs Clustering Analysis: An exploration via simulation on 11 July 2022
- Coloring SVGs in R on 17 June 2022
- Deconvolution vs Clustering Analysis for Multi-cellular Pixel-Resolution Spatially Resolved Transcriptomics Data on 03 May 2022
- Exploring UMAP parameters in visualizing single-cell spatially resolved transcriptomics data on 19 January 2022
- Animating RNA velocity with moving arrows on 15 October 2021
- A tale of two cell populations: integrating RNA velocity information in single cell transcriptomic data visualization with VeloViz on 06 October 2021