Skip to content

Instantly share code, notes, and snippets.

@chrissyhroberts
Created December 15, 2017 10:34
Show Gist options
  • Save chrissyhroberts/7384ea611ea2ba0713f27a18247771b9 to your computer and use it in GitHub Desktop.
Save chrissyhroberts/7384ea611ea2ba0713f27a18247771b9 to your computer and use it in GitHub Desktop.
find overlap between some SNP locations and a list of gene locations
#find overlap between some SNP locations and a list of gene locations
#test SNPs
#df = snps
#chr start stop
#1 1232 1232
#2 12444 12444
#gene positions
#df =genes
#chr start stop
#1 100 2000
#2 14000 130000
#define fuzzy flank size
flank.region <- 20000
inner_join(genes, snps, by="chr") %>% filter(start.y >= start.x-flank.region & stop.y <= stop.x+flank.region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment