利用ggplot2绘制点图
2022-12-23 本文已影响0人
pumpkinC
目的:使用ggplot2绘制二维点图。
输入文件格式:
Type a b c
botrytis 1.061400134 1.864434621 1.756580352
capitata 1.071468013 2.105041727 1.964633289
botrytis 1.098937678 2.757260101 2.509023173
botrytis 1.142003064 2.28265522 1.99881707
italica 1.155204592 4.618688189 3.998156014
capitata 1.249593966 2.43867596 1.951574692
脚本如下:
library(ggplot2)
mytheme2 <- theme_bw() + theme(legend.title=element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
axis.title.x = element_text(size=8),
axis.title.y = element_text(size=8,angle=90),
#axis.title.y = element_text(size=8,angle=90),
axis.text.x=element_text(size=9,angle=0),
axis.text.y = element_text(size=7), ##- biao qian
#axis.ticks.y = element_blank(), ##- ke du xian
legend.position="top",
legend.key.size = unit(0.4,'cm'),
legend.text = element_text(size=6,angle=0),
strip.text = element_text(size=8)
)
argv<-commandArgs(TRUE)
data1 <- read.table(argv[1], header = T, sep="\t")
#data1$Chr <- factor(data1$Chr, levels=c("A01", "A02", "A03", "A04", "A05", "A06", "A07", "A08", "A09", "A10"))
#chrColor <- c("#FFFFFF", "#9933FF", "#FF33FF", "#FF3399", "#FF3333", "#FF9933", "#99FF33", "#33FF99", "#3399FF", "#B8B800")
p2 <- ggplot(data1, aes(x=a, y=b, colour=Type, fill=Type, group=Type)) +
geom_point(size=3, shape=16, alpha=0.8) +
#facet_grid(Sam1vsSam2 ~ Chr,as.table=TRUE, scales="free_x", space="free_x") +
#geom_vline(data=subset(data1, Chr=="A02"), aes(xintercept=18122666/1000000), colour="#990000", linetype="dashed") +
#geom_vline(data=subset(data1, Chr=="A10"), aes(xintercept=1616321/1000000), colour="#990000", linetype="dashed") +
ylab("D4/D1") + xlab("D3/D1") + mytheme2
ggsave(filename=argv[2],plot=p2,height=4,width=4)
结果图:
image.png