This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Combine BedTools Closest and Window Command

Hi,

I am new to using Bedtools so please excuse my possible naive question. Let's say my file A is Snps and file B is genes.

The Closest command with -k flat let one set how many genes that are closest to the SNPs of interest. The Window command allows one to set a window and get all genes within that window. What should I do if I want to combine the 2 commands and find, for example, the 10 genes within 5kb up and downstream of the SNP?

What I have now is: bedtools window -a A.sorted.bed -b B.sorted.bed -w 5000 | bedtools closest -k 10 -D b -a A.sorted.bed -b B.sorted.bed > closest.genes.k5.bed

But this isn't correct because it's only outputting the result of the latter (closest) command.

Any help is appreciated! Thanks in advance.

snp genome sequencing bedtools gwas

I would simply use slop to extend the SNP coordinate by 5kb in each direction and then intersect to get the overlaps with the gene start coordinate.

0 answers

No answers yet.

Log in to answer this question.