library(ggtext)
library(tidyverse)
library(ggpubr)
library(rstatix)
df <- read_tsv("data.xls")
df %>% select(Cell_type) %>% group_by(Cell_type) %>%
mutate(count = n()) %>% distinct()
dff <- df %>%
mutate(Cell_type=case_match(Cell_type,"PC3" ~ "PC3<br><br>(n=27)",
"HeLa" ~"HeLa<br><br>(n=24)",
"K562" ~ "K562<br><br>(n=29)"))
dff$Cell_type <- factor(dff$Cell_type,levels = dff$Cell_type %>% unique())
df_p_val1 <- dff %>%
wilcox_test(True_coverage ~ Cell_type) %>%
adjust_pvalue(p.col = "p", method = "bonferroni") %>%
add_significance(p.col = "p.adj") %>%
add_xy_position(x = "Cell_type",dodge=0.8)
dff %>% ggplot(aes(Cell_type,True_coverage))+
geom_violin(aes(fill=Cell_type),show.legend = F,alpha=0.5,trim = F)+
geom_jitter(aes(fill=Cell_type),width = 0.1,alpha=0.1,show.legend = F)+
geom_boxplot(aes(fill=Cell_type),width=0.2,staplewidth = 0.2,outliers = F,show.legend = F,alpha=1)+
stat_summary(geom = "point", fun = "mean",color="#CB2314",size=3,show.legend = F)+
geom_text(stat = 'summary', fun = mean,
aes(label = round(after_stat(y),digits = 2)),
size = 3.5,nudge_y = 0.4,color="black")+
stat_pvalue_manual(df_p_val1,label = "p.adj.signif",tip.length = 0.01,
label.size=5,hide.ns = T,color="black")+
scale_fill_manual(values =c("#A195CE","#5171A4","#85D4E3"))+
labs(x=NULL,y=NULL)+
theme_classic()+
theme(axis.text.x=element_markdown(color="black",face="bold"),
axis.text.y=element_text(color="black",face="bold"))