Member-only story

Follow the Journal of Advanced Research to learn drawing | Use R language visualization to draw multiple violin charts using ggplot2 and ggh4x

Beck Moulton
4 min readOct 5, 2024

--

Follow the Journal of Advanced Research to learn drawing | Use R language visualization to draw multiple violin charts using ggplot2 and ggh4x

We usually use violin charts in combination with box plots, scatter plots, etc., but in this issue we are studying grouped violin charts. Gene expression relationship diagrams commonly used in single-cell and other techniques.

As shown in the figure below, published in 2024_Journal of Advanced Research_Title:“Single-nucleus transcriptional and chromatin accessible profiles reveal critical cell types and molecular architecture underlying chicken sex determination”。

Load dataset and R package

library(openxlsx)
library(ggplot2)
library(RColorBrewer)
library(ggh4x)
brewer.pal(9, "Set2")
df<-read.xlsx("df.xlsx")

Draw basic graphics

ggplot(df, aes(factor(Cluster), value, fill = Gene)) +
geom_violin(scale = "width", width =0.8, trim = F) +
facet_grid(rows = vars(Gene), scales

--

--

Beck Moulton
Beck Moulton

Written by Beck Moulton

Focus on the back-end field, do actual combat technology sharing Buy me a Coffee if You Appreciate My Hard Work https://www.buymeacoffee.com/BeckMoulton

No responses yet