This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.5
setwd("D:/RData/violin")
dataFile = "rvis.txt"
data = read.table(dataFile, head=T, sep = "\t")
data <- transform(data, class = factor(class, levels = unique(class)))
You can also embed plots, for example:
ggplot(data, aes(class, score, fill = class))+
geom_violin()+
geom_boxplot(width=.05, fill="black", outlier.colour=NA) +
stat_summary(fun.y=median, geom="point", fill="white", shape=21, size=2.5)+
scale_y_continuous(limits=c(-2.5,2.5))+
theme(axis.title = element_blank(),
axis.text = element_text(size = 14,color = "black"),
axis.ticks = element_line(colour = "black"),
legend.position = "none",
panel.grid = element_blank(),
panel.background = element_rect(fill = "white",colour = "black"))
## Warning: Removed 422 rows containing non-finite values (stat_ydensity).
## Warning: Removed 422 rows containing non-finite values (stat_boxplot).
## Warning: Removed 422 rows containing non-finite values (stat_summary).
#wilcox.test
getP = function(df,level){
x = df[df$class==level[1],1]
for(i in 2:length(level)){
data = df[df$class==level[i],1]
print(paste(level[i], wilcox.test(x, data)$p.value, sep = " : "))
}
}
levels = sort(unique(data$class))
getP(data, levels)
## [1] "case-denovo : 5.65151252429542e-06"
## [1] "case-recurent : 0.000872568062451305"
## [1] "control-denovo : 0.0175143197228321"
## [1] "VDRG : 6.44184876520878e-07"
for(i in levels){
print(paste(i, nrow(data[data$class==i, ]), sep = " : "))
}
## [1] "background : 16956"
## [1] "case-denovo : 116"
## [1] "case-recurent : 19"
## [1] "control-denovo : 45"
## [1] "VDRG : 718"