This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Some lines are not well organized in BED file, how to correct them ? Thanks a lot !

A BED file was downloaded online.

When I checked it, a few lines were not well organized.

How can I correct them?

Thanks a lot!

enter image description here

bed
Which BED file is this? How do you define 'organized'?

I want to convert this BED file to BigWig file using bedGraphToBigWig. But it failed owing to the labbled line with the incorrect format.

Whatever may be wrong with your BED file, it is not in the area you highlighted. BED files are tab-separated. Because the string in column 4 is shorter in your highlighted row, everything gets shifted to the left. However, that part would look normal if you imported the file.

it doesnt look like anything is wrong, necessarily.

can you try the following command:

awk -F'\t' '{print NF}' myfile.bed | sort | uniq -c

and then tell us the output

I learm something new from you . Thanks for you reply.

Your bed file looks fine. I guess you mean the line is not aligned with others, but this is how it is displayed. All columns are separated by tabular ("\t"), but sometimes some display looks like space.

(+1) and a couple of tips: use column -t my.bed | less -S for nicer display of tabular file. Even better use tableview, one of the most useful and little-known programs I've come across!

i think the original comment is predicated on an unproven assumption.

the awk one liner i provided is meant to prove this, only then would i make the comment matthewp made...

this shouldnt be assumed but rather proven.

Your are correct ! I figure out. Thanks for your reply.

1 answer

I want to convert this BED file to BigWig file using bedGraphToBigWig

Your input file could also be called BED4+4.

The first four columns follow UCSC BED specification. The remaining four columns are just a grabbag of whatever.

In any case, you don't have a bedGraph file. A bedGraph file can also be called BED3+1. In a bedGraph file, the fourth column is the score column, instead of an identifier as is normally found in a BED4+n file.

If you try to feed a non-bedGraph file into bedGraphToBigWig then that won't work. You need an extra step to make the bedGraph file.

To potentially turn your BED4+4 into a BED3+1/bedGraph file:

sort-bed in.bed | cut -f1-3,6 > out.bedGraph

This uses BEDOPS sort-bed to sort the file in.bed, passes the sorted result to cut to cleave off the first three columns and the sixth column, and then writes a sorted bedGraph file to out.bedGraph.

I am presuming that your score data are in the sixth column. I could be wrong. Adjust this number in the cut statement depending on which field the score data of interest is coming from, if it is not the sixth column.

You should then be able to feed out.bedGraph into bedGraphToBigWig to make a bigWig file (assuming you have a chromSizes file via fetchChromSizes or other for your assembly).

Thank you very much for your detailed reply ! Very helpful.

Now I would like to visualize the bedgrpah file to check the peaks.

But I find the range of scores is really big like the attached picture (1st chrom, 2nd start, 3rd end, 4th score).

How can I normalize it or modify it ?

Thank you again

What do you know about the score data? You could log-transform it, perhaps, or load it into a UCSC genome browser track, which provides different ways to render the track peaks, such as normalization or cutoffs.

Log in to answer this question.