This is a test version of Biostars. For the public version, visit https://www.biostars.org.
convert bedgraph to bed

I am looking for program to convert bedgraph file to bed file. Thanks a lot for you any help or suggestion in advance.

Bedgraph example input :

track type=bedGraph name="peaks_id76673" description="peaks in group_4271" db=mm9 color="120,101,172" priority="20" maxHeightPixels="100:50:0" altColor="200,120,59" visibility="full"

    chr1    3016963    3016964    1
    chr1    3016964    3016965    3
    chr1    3204552    3204553    -2
    chr1    3204659    3204660    -1

Output example: bed file with strand and score separated:

    chr1    3016963    3016964  .  +    1
    chr1    3016964    3016965  .  +    3
    chr1    3204552    3204553  .  -    2
    chr1    3204659    3204660  .  -    1
rna-seq chip-seq r

Something like this should work (not tested)

cat bedgraph.bg | grep -v 'track' | bedtools merge -i - -d 1 > bedgraph.bed

Thank you, It is just giving first 3 column. I want to information from 4th column as well. It contains score and strand. I want to them to be separate.

Your output example was different in the original thread, I though you wanted to merge side-by-side regions. Also, what's the point of making score signs (+/-) as a new column? You are converting a quantitative information into strand information.

cat bedgraph.bg | grep -v 'track' | awk '{print $0 ".\t" $4}'

I thought it was confusing, So I changed it. The input file consists of both strand information (+/-) and score (coverage value). I want to put strand (+/-) into a separate column and score into a separate column.

0 answers

No answers yet.

Log in to answer this question.