Question: Bedtools map to generate a new bedgraph
0
gravatar for Seigfried
17 months ago by
Seigfried70
Seigfried70 wrote:

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.

map bedtools • 677 views
ADD COMMENTlink modified 17 months ago by michael.ante3.2k • written 17 months ago by Seigfried70
2
gravatar for michael.ante
17 months ago by
michael.ante3.2k
Austria/Vienna
michael.ante3.2k wrote:

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 COMMENTlink written 17 months ago by michael.ante3.2k

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

ADD REPLYlink written 17 months ago by Seigfried70
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2566 users visited in the last hour