1

I have this rdata: https://dl.dropboxusercontent.com/u/43417085/cpp.rdata.RData What I want in the codes below is the way to add range of values for "IBS" column for each cutoff (colours), and also make the lines more distinct for each cutoff enter image description here(because the lines are mixed together and are not well separated for each cutoff) . Here are my codes to plot the figure:

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())
MAPK
  • 5,635
  • 4
  • 37
  • 88
  • I got warnings related to `namespace` when I loaded `cpp.rdata.RData`. – cuttlefish44 Sep 12 '16 at 06:53
  • 1
    Faceting on "color" might make the plot more readable. – zx8754 Sep 12 '16 at 07:07
  • @zx8754 That is right. Then how do you add the range bar for each facet? – MAPK Sep 12 '16 at 07:15
  • 2
    Range bar, as in hand drawn bits, exactly as it is shown in your image? This might need manual line drawing. Or we could [add shades](http://stackoverflow.com/questions/10542326) behind the plot? – zx8754 Sep 12 '16 at 07:18

0 Answers0