Metadata-Version: 2.5
Name: pileup_reads
Version: 0.0.2
Summary: Pileup reads from ChIP/ATAC/RNA-seq to make bedgraph/wig/bigwig
Project-URL: Homepage, https://github.com/ajgouhier/pileup_reads
Author-email: Arthur Gouhier <ajgouhier@gmail.com>
License: BSD-3-Clause
License-File: LICENSE
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# pileup_reads

Pileup reads from ChIP/ATAC/RNA-seq to make bedgraph/wig/bigwig.

## Requirements

- Python >= 3.8, no third-party packages
- [samtools](https://www.htslib.org/) on `PATH` (`module load samtools`)
- for bigwig, UCSC `wigToBigWig` / `bedGraphToBigWig` on `PATH`; otherwise they
  are fetched over https and md5-checked into the run's temporary directory.
  Put them on `PATH` if compute nodes have no outbound network.

## Usage

```sh
pileup-reads $INPUT $OUTPUT $OPTIONS...              # installed
python -m pileup_reads $INPUT $OUTPUT $OPTIONS...    # from a checkout

# ChIP
pileup-reads in.bam out.cpm.bigwig -n cpm -p 20
# ATAC
pileup-reads in.bam out.cpm.bigwig -s m36 -t force-extend -e 80 -n cpm -p 20
# RNA-seq
pileup-reads in.bam out.cpm.bigwig -b 1 -t splice -n cpm -p 20
# split a paired-end bam by fragment size
pileup-reads split-by-size in.bam -s 150 -i --plot
```

`pileup-reads --help` lists every option. A minus sign may be written `m`
(`-s m36` is -36), and counts take a metric prefix (`10M`).

## Notes

- Output does not depend on `--chunk-size`; `tests/` asserts it.
- Unmapped, secondary and supplementary reads are always skipped. Duplicates
  (0x400) and low MAPQ are only filtered with `-f`: `-f 0` drops duplicates,
  `-f 30` also drops reads below MAPQ 30.
- `-t extend` builds the interval from the mate, so it also skips reads whose
  pairing failed (mate unmapped, not properly paired). That is a quality
  filter: reads the aligner reports as single-end are extended normally.
- `.bai` and `.csi` are both found, as `file.bam.bai` or `file.bai`.
- Intermediate files go to `$SLURM_TMPDIR` when set, otherwise `$OUTPUT.tmp`
  beside the output, so they land on a filesystem with room. `--tmp-dir`
  overrides both.

## Tests

```sh
module load samtools
python -m unittest discover -s tests -t .   # synthetic fixtures, no data/ needed
tests/smoke.sh --check                      # rebuild data/ tracks and diff
tests/smoke.sh                              # regenerate them in place
```

`data/` holds a real mouse bam and reference bigwigs, kept out of version
control for size; `tests/` is what guards behaviour. `tests/smoke.sh` records
the settings each reference track was built with.
