# How to convert ChiP-seq track in .bam file format into an array at fixed bin resolution?

Is there a out of the box to convert a .bam file to a .wig file at specific resolution/bin size?

I was thinking to use igvtools, but I am not sure how it works:

igvtools count -z 5 -w 25 -e 250 alignments.bam alignments.cov.tdf hg19

What is the diffrence between -w,-z,-e?

-z num  Specifies the maximum zoom level to precompute. The default
value is 7 and is sufficient for most files. To reduce file
size at the expense of IGV performance this value can be
reduced.

-e, --extFactor num

The read or feature is extended by the specified distance in bp prior to counting. This option is useful for chip-seq and rna-seq applications. The value is generally set to the average fragment length of the library minus the average read length.

-w, --windowSize num

The window size over which coverage is averaged. Defaults to 25 bp.



bamCoverage -of bedgraph -bs 10 -b input.bam -p 20

Regarding the options to igvtools, -w is equivalent to -bs/--binSize in deepTools and denotes the resolution of the output data. -e (it's the same option in bamCoverage) denotes whether and how much to extend a read in its 3' direction. This done such that the output represents the sequences fragments. -z is specific to things like bigWig files (and apparently tdf files), where there are precomputed values that IGV will load as you zoom out (the various resolutions are "zoom levels", which is parlance taken from the bigWig format).