Bedtools map to generate a new bedgraph
1
0
Entering edit mode
6.5 years ago
Seigfried ▴ 80

Hello

I have a bed file with Start and End co-ordinates and I also have a bedgraph file with scores. I want to create a new bedgraph file using the co-ordinates in my bed file.

I know that bedtools map can do this. However, I cannot figure out which of the options to use

-o options

sum - numeric only
count - numeric or text
count_distinct - numeric or text
min - numeric only
max - numeric only
absmin - numeric only
absmax - numeric only
mean - numeric only
median - numeric only
antimode - numeric or text
collapse (i.e., print a comma separated list) - numeric or text
distinct (i.e., print a comma separated list) - numeric or text
concat (i.e., print a comma separated list) - numeric or text

If I have a bed file a.bed

Start End
4     9

And if I have a bdg file b.bdg

Start End Score
1     5   15
6     10  7

I want an output bdg file like this

Start End Score
4     5   15
6     9   7

So the number of entries in the new bdg files increase.

bedtools map • 2.3k views
ADD COMMENT
2
Entering edit mode
6.5 years ago
michael.ante ★ 3.8k

Hi Seigfried,

you can use intersectBed to generate the overlaps (I think you need to include a chromosome name - I used "1"):

intersectBed -a a.bed -b b.bed 
1   4   5
1   6   9

With -wb you can include the b.bed information:

intersectBed -a a.bed -b b.bed -wb
1   4   5   1   1   5   15
1   6   9   1   6   10  7

Afterwards you can use e.g. cut to get the columns of interest:

intersectBed -a a.bed -b b.bed -wb | cut -f 1-3,7
1   4   5   15
1   6   9   7

Cheers,

Michael

ADD COMMENT
0
Entering edit mode

I used intersectbed but forgot about -wb. Amazing. Thank you so much.

ADD REPLY

Login before adding your answer.

Traffic: 3277 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6