This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Retrieve coordinate for maximum value in a region using a bigwig file

Hello,

I have a bed file with a series of regions and a signal bigwig file. I want to look for each region in the bed file what is the maximum value in the bigwig file, and then obtain the genomic coordinated for the maxima. I have seen ways to get the maximum, but not how to get a coordinate position. Any leads?

Thanks!

bigwig peak summit

1 answer

A one-liner (not tested)

 echo -e "chr1\t1014511\t1023256\nchr1\t1014570\t1014600" | while read CHROM START END ; do echo -en "${CHROM}\t${START}\t${END}\t" &&  bigWigToBedGraph -chrom=${CHROM} -start=${START} -end=${END}path/to/file.bigWig stdout  | sort -t $'\t' -k4,4gr | head -n 1 |tr -d "\n" && echo ; done

Log in to answer this question.