library(sjstats)
library(ggplot2)
Import protein and RNA data
tmt <- readRDS("tmt.SL")
cpm <- readRDS("cpm.SL")
Calculate CV for the three B73 biological replicates across each protein/RNA
tmt$CV <- NA
for(i in 1:nrow(tmt)){
tmt[i,"CV"] <- cv(as.numeric(tmt[i,14:16]))
}
cpm$CV <- NA
for(i in 1:nrow(cpm)){
cpm[i,"CV"] <- cv(as.numeric(cpm[i,2:4]))
}
Plot!
#combine protein and RNA data
tmt$measure <- "Protein"
cpm$measure <- "mRNA"
cv <- rbind(tmt[,c("Gene","CV","measure")], cpm[,c("Gene","CV","measure")])
ggplot(cv, mapping = aes(x=measure, y=CV, fill=stat(y)))+
geom_violin(draw_quantiles = 0.5, fill="#77769d")+
theme_minimal()+
xlab("")+
ylab("Coefficient of variation (CV)")+
ylim(0,1)+
theme(legend.position = c(0.09,0.88), legend.text = element_text(size=10), axis.text.x = element_text(size=10), axis.text.y = element_text(size=10), axis.title.x = element_text(size=12), axis.title.y = element_text(size=12))+
theme(panel.grid.minor = element_blank())
ggsave("CoefficientVariation.png",width = 4, height = 3)