Question: After reading about discrepancies in RPKM method and solution as TPM. This question came to my mind would TPM be a good tag normalization method for ChIP-seq. During ChIP normalization I am always worried about the ChIP-enrichment strength when comparing ChIP-seq in two different condition after normalizing with tag per million. **Is TPM a good method for ChIP-seq normalization?** All suggestions are helpful.

----------
Thanks

Answer: Not sure it answers your question... One strategy I used to quantify "peak strength" is to count reads in the target region (e.g. from peak callers or some other regions of interest) and compare this count to the count in the flanking regions, left and right of the target.

By contrasting target vs flanking you don't have to worry about library size and you capture local biases that, supposedly, are conserved between libraries.

You can get the script from here:

wget 'https://github.com/dariober/bioinformatics-cafe/blob/master/localEnrichmentBed.py?raw=true' -O localEnrichmentBed.py

This is from the help:

localEnrichmentBed.py -h
usage: localEnrichmentBed.py [-h] --target TARGET --bam BAM --genome GENOME
[--slop SLOP] [--blacklist BLACKLIST]
[--tmpdir TMPDIR] [--keeptmp] [--verbose]
[--version]

DESCRIPTION
Compute the read enrichment in target intervals relative to local background.

Typical use case: A ChIP-Seq experiment on a sample returns a number of regions
of enrichment. We want to know how enriched these regions are in a *different*
sample. Note that enrichment is quantified relative to the local background
not relative to an input control.

See also localEnrichmentScore.R to combine replicates and compare
treatment vs control.

OUTPUT:
bed file with header and columns:
1. chrom
2. start
3. end
4. targetID
5. flank_cnt
6. target_cnt
7. flank_len
8. target_len
9. log10_pval
10. log2fc

EXAMPLE
localEnrichmentBed.py -b rhh047.bam -t rhh047.macs_peaks.bed -g genome.fa.fai -bl blacklist.bed > out.bed

Useful tip: Get genome file from bam file:

samtools view -H rhh047.bam \
| grep -P "@SQ\tSN:" \
| sed 's/@SQ\tSN://' \
| sed 's/\tLN:/\t/' > genome.txt

REQUIRES:
- bedtools 2.25+
- numpy, scipy

NOTES:
For PE reads, the second read in pair is excluded (by samtools view -F 128)
since coverageBed double counts pairs.

optional arguments:
-h, --help show this help message and exit
--target TARGET, -t TARGET
Target bed file where enrichment is to be computed.
Use - to read from stdin.

--bam BAM, -b BAM Bam file of the library for which enrichment is to be
computed.

--genome GENOME, -g GENOME
A genome file giving the length of the chromosomes.
A tab separated file with columns .
NB: It can be created from the header of the bam file (see tip above).

--slop SLOP, -S SLOP Option passed to slopBed to define the flanking region (aka background).
If `int` each target will be extended left and right this many bases.
If `float` each target is extended left and right this many times its size.
E.g. 5.0 (default) extends each target regions 5 times its length left and right.

--blacklist BLACKLIST, -bl BLACKLIST
An optional bed file of regions to ignore to compute
the local background. These might be unmappable regions with 0-counts which would
inflate the target enrichment.

--tmpdir TMPDIR Temp dir to use for intermediate files. If not set
python will get one. A subdir will be created here.

--keeptmp If set, the tmp dir is not deleted at the end of the
job (useful for debugging).

--verbose, -V Print to stderr the commands that are executed.

--version show program's version number and exit