-
Notifications
You must be signed in to change notification settings - Fork 0
/
violin.R.txt
30 lines (26 loc) · 1.08 KB
/
violin.R.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#install.packages("ggpubr")
#if(!require(devtools)) install.packages("devtools")
#devtools::install_github("kassambara/ggpubr")
library("ggpubr") # Type 1
data("ToothGrowth")
head(ToothGrowth)
df = read.delim("clipboard",header=TRUE)
# Violin plots with box plots inside
# :::::::::::::::::::::::::::::::::::::::::::::::::::
# Change fill color by groups: dose
# add boxplot with white fill color
ggviolin(df, x = "dose", y = "len", fill = "dose",
palette = c("#00AFBB", "#E7B800", "#FC4E07"),
add = "boxplot", add.params = list(fill = "white"))+
stat_compare_means(comparisons = my_comparisons, label = "p.signif")+ # Add significance levels
stat_compare_means(label.y = 50)
library("ggpubr") # Type 2
df = read.delim("clipboard",header=TRUE)
my_comparisons <- list( c("C", "T"))
ggplot(df, aes(x = Allele, y = Capacity, color = Allele))+
geom_violin(trim=FALSE)+
geom_boxplot(width=0.3)+
geom_jitter(width = 0.03)+
stat_compare_means(comparisons = my_comparisons, label = "p.format",label.y = 17)+ # Add significance levels
theme_bw()+
theme(legend.position="none")