Skip to content

Instantly share code, notes, and snippets.

@sirusb
Created February 18, 2015 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirusb/73dbacdb67b3b9e2e9f3 to your computer and use it in GitHub Desktop.
Save sirusb/73dbacdb67b3b9e2e9f3 to your computer and use it in GitHub Desktop.
range1 <- IRanges(start=c(10,50,300),end =c(60,90,456))
range1
#IRanges of length 3
# start end width
#[1] 10 60 51
#[2] 50 90 41
#[3] 300 456 157
reduce(range1)
#IRanges of length 2
# start end width
#[1] 10 90 81
#[2] 300 456 157
disjoin(range1)
#IRanges of length 4
# start end width
#[1] 10 49 40
#[2] 50 60 11
#[3] 61 90 30
#[4] 300 456 157
range2 <- IRanges(start=c(20,250),end =c(30,320))
findOverlaps(range2,range1)
#Hits of length 2
#queryLength: 2
#subjectLength: 3
# queryHits subjectHits
# <integer> <integer>
# 1 1 1
# 2 2 3
nearest(range2,range1)
#[1] 1 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment