This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error when uploading Wig file to UCSC

I used this script (found in the forum) to convert a sorted BAM with uniquely mapped reads to wig format:

samtools mpileup -BQ0 run.sorted.bam | perl -pe '($c, $start, undef, $depth) = split;if ($c ne $lastC || $start != $lastStart+1) {print "fixedStep chrom=$c start=$start step=1 span=1\n";}$_ = $depth."\n";($lastC, $lastStart) = ($c, $start);' | gzip -c > run.wig.gz

However, when trying to upload to USCS I get an error saying:

Unrecognized format line 1 "fixedStep chrom=chr1 start=9957 step=1 span=1" (note: chrom names are case sensitive, e.g.: correct: 'chr1', incorrect: 'Chr1', incorrect: '1')

What is causing the error? Format seems to be Ok...

Thanks

EDIT: Trying to convert to bigWig with wigtoBigwig yields:

invalid unsigned integer: "chrom=chr1"

uscs upload wig

1 answer

According to this post samtools depth works better. Latest edit suggest bedtools coverage followed by bedGraphToBigWig.

Log in to answer this question.