boxplot绘制箱形图
部分数据:
Value Group
2 a
4 a
3 a
2 a
4 a
7 a
7 a
2 a
5 a
4 a
5 b
6 b
8 b
5 b
代码语言:javascript复制dat <- read.table("boxplot.txt",header=T)
boxplot(Value~Group,data = dat)
代码语言:javascript复制#调整
boxplot(Value~Group,data = dat,
varwidth=TRUE,
col="#6DC9F2",
outline=FALSE,
names=c("Control","Drug1","Drug2","Drug3","Drug4","Drug5"),
horizontal=FALSE )
代码语言:javascript复制#高级调整
points(jitter(as.numeric(dat$Group)),dat$Value, pch = 16, col = "red")
ggplot绘制箱形图
绘图格式:
代码语言:javascript复制ggplot(dat, aes(Group,Value)) geom_boxplot()
这里就不展示了,试试自己绘制一下。
韦恩图
数据
代码语言:javascript复制####first generate the test data
#a function to generate gene names
generateGeneName <- function()
{
paste(sample(LETTERS,5,replace=T), collapse='')
}
#generate 100 gene names
geneNames <- replicate(1000, generateGeneName())
####method 1
####
library(gplots)
#venn plot of two groups
GroupA <- sample(geneNames,400, replace=F)
GroupB <- sample(geneNames,400, replace=F)
input <- list(GroupA,GroupB)
venn(input)
代码语言:javascript复制#venn plot of three groups
GroupA <- sample(geneNames,400, replace=F)
GroupB <- sample(geneNames,400, replace=F)
GroupC <- sample(geneNames,500, replace=F)
input <- list(GroupA,GroupB,GroupC)
venn(input)
代码语言:javascript复制#venn plot of four groups
GroupA <- sample(geneNames,400, replace=F)
GroupB <- sample(geneNames,300, replace=F)
GroupC <- sample(geneNames,500, replace=F)
GroupD <- sample(geneNames,700, replace=F)
input <- list(GroupA,GroupB,GroupC,GroupD)
venn(input)
代码语言:javascript复制#venn plot of five groups
GroupA <- sample(geneNames,400, replace=F)
GroupB <- sample(geneNames,300, replace=F)
GroupC <- sample(geneNames,500, replace=F)
GroupD <- sample(geneNames,700, replace=F)
GroupE <- sample(geneNames,600, replace=F)
input <- list(GroupA,GroupB,GroupC,GroupD,GroupE)
venn(input)
代码语言:javascript复制####method2
####using package "venneuler", with weights. using the size of the area to indicate different sets and the intersection
library(venneuler)
m <- data.frame(c(GroupA, GroupB, GroupC),
c(rep("GroupA", length(GroupA)),
rep("GroupB", length(GroupB)),
rep("GroupC", length(GroupC))
)
)
v <- venneuler(m)
plot(v)
代码语言:javascript复制####method3
####
library(VennDiagram)
#three groups
venn.diagram(list(GroupA=sample(geneNames,400, replace=F),
GroupB=sample(geneNames,300, replace=F),
GroupC=sample(geneNames,500, replace=F) ),
height=3000,
width=3000,
resolution=500,
imagetype="tiff",
filename="venn.diagram.3groups.tiff",
fill = c("cornflowerblue", "green", "yellow"),
label.col="black",
cat.col = c("darkblue", "darkgreen", "orange")
)
#four groups
venn.diagram(list(GroupA=sample(geneNames,400, replace=F),
GroupB=sample(geneNames,300, replace=F),
GroupC=sample(geneNames,500, replace=F),
GroupD=sample(geneNames,700, replace=F) ),
height=3000,
width=3000,
resolution=500,
imagetype="tiff",
filename="venn.diagram.4groups.tiff",
col="transparent",
fill = c("cornflowerblue", "green", "yellow", "darkorchid1"),alpha = 0.50,
label.col = c("orange", "white", "darkorchid4", "white", "white", "white", "white", "white", "darkblue", "white", "white", "white", "white", "darkgreen", "white"),
cat.col = c("darkblue", "darkgreen", "orange", "darkorchid4")
)
#five groups
venn.diagram(list(GroupA=sample(geneNames,400, replace=F),
GroupB=sample(geneNames,300, replace=F),
GroupC=sample(geneNames,500, replace=F),
GroupD=sample(geneNames,700, replace=F),
GroupE=sample(geneNames,800, replace=F)),
height=3000,
width=3000,
resolution=500,
imagetype="tiff",
filename="venn.diagram.5groups.tiff",
col = "black",
fill = c("dodgerblue", "goldenrod1", "darkorange1", "seagreen3", "orchid3"),
alpha = 0.50,
cex = c(1.5, 1.5, 1.5, 1.5, 1.5, 1, 0.8, 1, 0.8, 1, 0.8, 1, 0.8,
1, 0.8, 1, 0.55, 1, 0.55, 1, 0.55, 1, 0.55, 1, 0.55, 1, 1, 1, 1, 1, 1.5),
cat.col = c("dodgerblue", "goldenrod1", "darkorange1", "seagreen3", "orchid3"),
cat.cex = 1.5,
cat.fontface = "bold",
margin = 0.1
)