I'm using R to plot a matrix of gene counts being up/down regulated, where the y-axis would be the categories and the x-axis would be the counts in each treatment. Here's an example of the matrix structure I plotted with corrplot:
Matrix plot by corrplot
Instead of plotting the full circle in each cell, like in the image above, I would like each cell to have a split circle plot. One half containing the type "up" values, and the other containing "down" values.
Using this post as example for the circle plot, I have been able to plot the circles but I'm struggling to turn this into a matrix-like figure. Here's some sample data:
df <- data.frame(category = rep(c("A", "B"), each = 2),
type = rep(c("up", "down"), 4),
treatment = rep(c("treat1", "treat2", "treat3", "treat4"), each = 4),
count = c(19419, 1132, 8138, 947, 8349, 436, 789, 1580))
df$treatment <- as.factor(df$treatment)
library(ggplot2)
ggplot(df, aes(x=category, y=sqrt(count), fill=type)) + geom_col(width =1) +
coord_polar(theta = "x", direction = -1) +
facet_wrap(category~treatment) +
theme_void()
How do I arrange these circles in a matrix-like figure? How do I plot split circles within each cell of a matrix?
Any suggestions will be greatly appreciated. Many thanks!!
ggplot(df, aes(x=category, y=sqrt(count), fill=type)) + geom_col(width =999, position="dodge") +
coord_polar(theta = "x", direction = -1, start=pi/2) +
facet_grid(category~treatment) +
theme_void()
Rotates the plots and has the up and down parts plotting in different directions