Skip to content

Instantly share code, notes, and snippets.

@katwre
Last active August 29, 2015 14:20
Show Gist options
  • Save katwre/4d1966bc62e80e323d22 to your computer and use it in GitHub Desktop.
Save katwre/4d1966bc62e80e323d22 to your computer and use it in GitHub Desktop.
a way to show two granges objects on a plot. from http://www.sthda.com/english/wiki/iranges
target.paired.end = GRanges(rep(c(1),each=7),
IRanges(c(7,7,8,9,9,24,25), width=39),
strand=rep(c("-"), times=7))
windows.paired.end = GRanges(rep(c(1),each=3), IRanges(c(7,8,24), width=10),
strand=rep("-", times=3))
plotir <- function(ir,i, col) { arrows(start(ir)-.5,i,end(ir)+.5,i,code=3,angle=90,lwd=3, col=col) }
plot(0,0,xlim=c(0,65),ylim=c(0,11),type="n",xlab="",ylab="",xaxt="n")
axis(1,0:65)
abline(v=0:65 + .5,col=rgb(0,0,0,.5))
for(i in 1:length(target.paired.end))
plotir(target.paired.end[i],i, "black")
for(i in 1:length(windows.paired.end))
plotir(windows.paired.end[i],i, "red")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment