This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BamTobw bedGraphToBigWig: command not found

Hi, I was trying to use bamTobw to convert bam to bigwig file. The bash file had an issue when trying to convert bedgraph into bigwig (first, bash file converts bam into bedGraph, then converted bedGraph into bw files.

...
Convert DP_Jun_trimmed.sorted.bedgraph to DP_Jun_trimmed.sorted.bw
bedGraphToBigWig DP_Jun_trimmed.sorted.bedgraph chrom_sizes.tmp DP_Jun_trimmed.sorted.bw
~/Tool/bamTobw.sh: line 61: bedGraphToBigWig: command not found
...

it seemed that the command bedGraphToBigWig was missing. and I found this command belongs to "UCSC utilities" mentioned in the requirement of bamTobw. so I downloaded from the web, put it in the same directory with bamtobw.sh file make it executable:

chmod +x bedGraphToBigWig

set the PATH of bedGraphToBigWig

PATH=$PATH:$HOME/Tool/bedGraphToBigWig:$PATH

source the .bash_profile still I had the same issue.

Does anyone has any idea what went wrong? Thanks!

software error alignment

You could just use bamCoverage from deepTools, it's rather more heavily used and therefore a bit more likely to work.

@Devon Ryan, Thanks! I tried to tweak the code clumsily, but it seems that it did not work out.

function bedgraph_to_bw {
    local bedgraph_file=$1.bedgraph
    local name=$1.bw
    local chrom_sizes=$2
    echo "Convert $bedgraph_file to $name" | tee -a bamTobw.log
    echo "bedGraphToBigWig $bedgraph_file $chrom_sizes $name" | tee -a bamTobw.log
    bedGraphToBigWig $bedgraph_file $chrom_sizes $name
}


function bedgraph_to_bw {
    local bedgraph_file=$1.bedgraph
    local name=$1.bw
    local chrom_sizes=$2
    echo "Convert $bedgraph_file to $name" | tee -a bamTobw.log
    echo "bamCoverage $bedgraph_file $name" | tee -a bamTobw.log
    bamCoverage $bedgraph_file $name
}

I guess I could just use bamCoverage as command to convert the file one by one. but if could you please kindly let me know if minor tweaks could be made in order for the bamTobw.sh to work?

I'd never even heard of bamTobw before you posted it, so I can't comment on what might need to be tweaked.

@Devon Ryan. Thanks for you editing and patient reply! I think I am fine with using bamCoverage as command line at this moment.

@Devon Ryan. I just realized that bamCoverage could DIRECTLLY convert bam into bw. Thanks!

I too never head of it. the pipeline I heard about bigwig generation from bam files involving bedGraphToBigWig involves bedgraph generation with bedtools:

bedtools genomecov -bga -ibam file.bam > file.bedgraph
bedGraphToBigWig file.bedgraph file.bigwig

0 answers

No answers yet.

Log in to answer this question.