-
-
Save taoliu/2469050 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# check commands: slopBed, bedGraphToBigWig and bedClip | |
which bedtools &>/dev/null || { echo "bedtools not found! Download bedTools: <http://code.google.com/p/bedtools/>"; exit 1; } | |
which bedGraphToBigWig &>/dev/null || { echo "bedGraphToBigWig not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; } | |
which bedClip &>/dev/null || { echo "bedClip not found! Download: <http://hgdownload.cse.ucsc.edu/admin/exe/>"; exit 1; } | |
# end of checking | |
if [ $# -lt 2 ];then | |
echo "Need 2 parameters! <bedgraph> <chrom info>" | |
exit | |
fi | |
F=$1 | |
G=$2 | |
bedtools slop -i ${F} -g ${G} -b 0 | bedClip stdin ${G} ${F}.clip | |
LC_COLLATE=C sort -k1,1 -k2,2n ${F}.clip > ${F}.sort.clip | |
bedGraphToBigWig ${F}.sort.clip ${G} ${F/bdg/bw} | |
rm -f ${F}.clip ${F}.sort.clip |
Thank you, the bedClip binary fixed my errors while converting bedGraph to bigWig.
Great stuff!
HOwever I have a small correction: sometimes (always in general case) you need to sort the bdg file or bedGraphToBigWig crashes with:
".bdg.clip is not case-sensitive sorted at line 31766. Please use "sort -k1,1 -k2,2n" with LC_COLLATE=C, or bedSort and try again."
So here is my fix:
F=$1
G=$2
bedtools slop -i ${F} -g ${G} -b 0 | bedClip stdin ${G} ${F}.clip
LC_COLLATE=C sort -k1,1 -k2,2n ${F}.clip > ${F}.sort.clip
bedGraphToBigWig ${F}.sort.clip ${G} ${F/bdg/bw}
Same here, thank @elgartmi for the fix.
Thank @elgartmi ! I incorporated your fix
Hi, is there a command line option similar to bedClip in bedGraphToBigWig to avoid the error - End coordinate bigger than chr? Thanks!
how can i use this code??? use as ./..sh file
help me plz
bedGraphToBigWig: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
bedGraphToBigWig: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
Can someone please help with this? I am losing my mind...
@ultrav71 check this macs3-project/MACS#505
@hyjforesight thank you!
hey there taoliu. would you mind to help me sloving quisiton when i run script and errors came out like bedgraph file contain Homo sapiens unplaced genomic contig ?
Hi I have some questions about this script, first, I ran the original script and ran into the error about "Overlapping regions in a BedGraph file", then I made some modifications according to the last post in here and was able to make the bw file. I don't really understand what the codes do....but I was able to make it work.. Do you have further suggestions regarding "Overlapping regions in a BedGraph file"?
In the bw file, I noticed that the "binning" is larger than the original bedgraph, is it possible to keep the original "binning"? It is changed because there's a "bedtool merge" step in the modification (which is to solve the overlapping region error?)?
Thank you!
thanks! great. that will save me from doing