I am trying to create a line plot connecting the top points of a Manhattan plot (showing only the 'skyline' of the manhattan plot). I think I can manually select the points to connect and specify them with the 'line' command, but I was wondering if there is an easier way to do this in R?
This is an example dataset and plot:
affy <-c(40220, 41400, 33801, 32334, 32056, 31470, 25835, 27457, 22864, 28501, 26273, 24954, 19188, 15721, 14356, 15309, 11281, 14881, 6399, 12400, 7125, 6207)
CM <- cumsum(affy)
n.markers <- sum(affy)
n.chr <- length(affy)
test <- data.frame(chr=rep(1:n.chr,affy),pos=1:n.markers,p=runif(n.markers))
plot(test$pos, -log10(test$p))
Thank you in advance for the help!