我有这个rdata:https://dl.dropboxusercontent.com/u/43417085/cpp.rdata.RData 我在下面的代码中想要的是为" IBS"添加值的方法。每个截止值(颜色)的列,并且还使每个截止值的线条更加明显(因为线条混合在一起并且对于每个截止值没有很好地分开)。 以下是我绘制图形的代码:
color <- c("0.25_ok"= "navy", "0.5_confounding_high" = "blanchedalmond", "0.5_ok" = "cyan3", "1.0_confounding" = "brown2", "cancer" = "darkgray", "confounding_unrelated" = "khaki2",
"contaminated_dil" = "black", "identical_ok" = "cornsilk3", "mislabelled" = "dodgerblue2", "sample_contam" = "red1", "unrelated" = "yellow1" )
p<- ggplot(cpp, aes(x = Num_Good, y = IBS, group = key.related.sheet, color = cutoff)) +
geom_line() + geom_point() #to show the dots
p1 <- p+labs(title="SNPs threshold for coherent IBD", x="Number of good SNPs", y="IBD") +
theme_bw() +
theme(axis.text.x=element_text(size=14), axis.title.x=element_text(size=16),
axis.text.y=element_text(size=14), axis.title.x=element_text(size=16),
plot.title=element_text(size=20, face="bold", color="darkgreen"))
p2 <-p1+ scale_x_continuous(expand = c(0, 0), breaks = c(0, 1500, seq(5000, max(as.data.frame(cpp)[,"Num_Good"]), 10000)),
labels = c(0, 1500, seq(5000, max(as.data.frame(cpp)[,"Num_Good"]),10000))) #expand forces the origin to start at zero
p3 <- p2 + scale_color_manual(values = color)
#rescaling the Y-axis breaks
p4 <- p3+scale_y_continuous(breaks = seq(-1,2,0.25),
labels = seq(-1,2,0.25))
p5 <- p4 + geom_hline(yintercept = 0, colour="black", linetype = "longdash")+
geom_hline(yintercept = 0.5, colour="black", linetype = "longdash")+
geom_hline(yintercept = 1.0, colour="black", linetype = "longdash")
p6 <- p5 + coord_cartesian (xlim = c(0, 30000), ylim = c())