3
$\begingroup$

I was wondering how can I convert bed file to wig file.

I have several bed files which look like

head EE88324.shortlong.frag.bed
chr1    10003   10117   1
chr1    10003   10138   1
chr1    10003   10146   1
chr1    10008   10152   1
chr1    10009   10129   1
chr1    10009   10130   1
chr1    10025   10169   1
chr1    10026   10145   1
chr1    10030   10172   1
chr1    10052   10245   1

Now I want convert this bed file to wig file, which should look like this, (this toy bed and wig samples are different)

head -n 50 S9U_ZKDN240002406-1A_H5VMFDSXC_L1_bwaM_readCounts.w1000k.wig
fixedStep chrom=chr1 start=1 step=1000000 span=1000000
2682
8134
7087
6923
5585
5579
7056
5953
6174
7058
6606
6682
5630
4705
5432
6755
9442
6563
5891
6427
6033
6871
6360
6574

What I tried so far,

#bed to wig conversion
chromsizes="~/mapF/GRCh38_chr.txt"
bedGraphToBigWig="~/KentUtils/exe/linux.x86_64/bedGraphToBigWig"
bigWigToWig="~/KentUtils/exe/linux.x86_64/bigWigToWig"


conda activate bedops_env
    bedops --partition EE88324.shortlong.frag.bed |
    bedmap --echo --mean --delim '\t' --window 1000000 --fixed 1000000 - EE88324.shortlong.frag.bed |
    $bedGraphToBigWig - $chromsizes |
    $bigWigToWig - EE88324.shortlong.diff.partition.map.1MB.wig
$\endgroup$

1 Answer 1

0
$\begingroup$

I do not know bedops, so I assume that this two-step pipe at the end of bedmap produces a regular bedGraph.

The problem is that both bedGraphToBigWig and bigWigToWig like any of the kentUtils tools does not read or write from/to stdin/stdout. Hence, write the bedGraph to disk, then convert to BigWig, then convert to Wig. Tedious, but that's what kentUtils support -- they do not allow piping.

$\endgroup$
1
  • $\begingroup$ Could you add the relevant command please? As it stands, this is pointing the OP in the right direction, but it isn't actually giving the answer. $\endgroup$
    – terdon
    Commented Jun 1 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.