I'm looking at heterozygosity in windows across the genome. I have a value for each window and I want to plot these, alternating the colors of each chromosome (black and gray) to make it clearer. Additionally I would like to color significant values in red.
On the x axis I have chromosome, and on the y axis I have heterozygosity. I can color the significant values but I'm completely stuck on how to alternate between two colors. There are many values for each chromosome.
This is what I have so far:
plot(mydata$heterozygosity~mydata$chromosome, xlab = "chromosome", ylab = "het", ylim = c(0, 0.35), pch=ifelse(mydata$het > 0, 21, 26), bg=ifelse(mydata$het >0.1374, 'red', 'white'))
Please can anybody help?
Edit: Sorry! My plot so far is here:
and my example data is:
chromosome start end heterozygosity window 1 5920001 5960000 0.0569 219990 1 5930001 5970000 0.1009 219991 2 5940001 5980000 0.1099 219992 2 5950001 5990000 0.0768 219993 3 5960001 6000000 0.0392 219994 4 5970001 6010000 0.0354 219995
This is just a very short example because my real file is huge, but I basically have many entries for each chromosome and so I want to color those entries by their chromosome number. I hope this is clearer, please let me know if I'm still not making sense!