Metadata-Version: 2.4
Name: ATACofthesnake
Version: 0.4.0
Summary: ATACofthesnake
Author-email: WardDeb <w@rddeboutte.com>
License: MIT License
        
        Copyright (c) 2021 Max Planck Institute for Immunobiology and Epigenetics
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://www.github.com/maxplanck-ie/ATACofthesnake
Keywords: ATAC,differential accessibility,motifs,time-course analysis
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: seaborn>=0.12.0
Requires-Dist: pandas>=2
Requires-Dist: rich>=12.6.0
Requires-Dist: snakemake>=9.0.0
Requires-Dist: click>=8.0.0
Provides-Extra: dev
Requires-Dist: ruff; extra == "dev"
Requires-Dist: ty; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pip; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# ATACofthesnake

Downstream processing of ATAC data, including QC's and differential accessibility. Starting point are deduplicated bam or cram files.

## Important

All samples in a 'run' have to belong to the same group. That means that out of all peaks/sample, a union will be made. In case this is not relevant, you can run the workflow multiple times.
Fasta headers un field 0 (space delimited) are not allowed to contain a pipe character '|' (as peaks will be delimited as such).

## Installation

From pypi:
>  pip install ATACofthesnake
or with uv:
>  uv pip install ATACofthesnake

From github:
>  git clone git@github.com:maxplanck-ie/ATACofthesnake.git  
>  pixi run ATAC -h


## Quickstart

standard analysis:

 > ATAC --bamdir folder/with/bamfiles/ --outputdir outputfolder \
   --gtf genes.gtf --genomefasta genome.fa \
   --snakemakeprofile profile -b read_attracting_regions.bed

Note that this pipeline depends on snakemake. Additionally, the snakemake environments are managed using conda, which means you need to have conda installed and configured. Make sure this is set in your snakemake profile (if you use one), when not using a profile, snakemake will be ran with the --use-conda flag by default.

The default analysis will generate:

 - sieved bamfiles.
(cfr. --fragsize/-f & --read_attracting_regions/-b). Note that read attracting regions are obliged. At minimum this should contain the mitochondrial genome. Note that the mitochondrial contig is assumed to be named 'MT'. You can change this using --mitostring.
 - peaks called per bamfile (under peaks/) and a union of all peaks (peakset/).
 - bigwigs normalized using scalefactors and RPKM.
 - a number of QC plots (figures/) and metrics (qc/)

## Differential analysis

Differential analysis requires an additional yaml file specifying the comparison (comparison.yaml) and the samplesheet.

 > ATAC --bamdir folder/with/bamfiles/ --outputdir outputfolder \
   --gtf genes.gtf --genomefasta genome.fa --genomesize 1.87e9 \
   --snakemakeprofile profile -b read_attracting_regions.bed \
   --comparison comparison.yaml --samplesheet samplesheet.tsv

The samplesheet has to be a tab-separated file with the first column containing the sample names (as the bam files are named), and the other columns containing the factors that will make up the design. For example:

| sample | genotype | treatment |
| -- | -- | -- |
| sample1 | WT | DMSO |
| sample2 | WT | DMSO |
| sample3 | WT | drug |
| sample4 | WT | drug |
| sample5 | KO | DMSO |
| sample6 | KO | DMSO |
| sample7 | KO | drug |
| sample8 | KO | drug |

will result in the following design:

 > ~ genoype + treatment

or if --interaction is set:

 > ~ genotype * treatment  

Note the comparisons made need to be specified in the comparison.yaml file, a samplesheet alone is not enough. An example together with the above samplesheet would be:

```bash
comparison1:
  group1:
    genotype: 'WT'
  group2:
    genotype: 'KO'
wtdmso_vs_wtdrug:
  wtdmso:
    genotype: 'WT'
    treatment: 'DMSO'
  wtdrug:
    genotype: 'WT'
    treatment: 'drug'
```

In this case, 2 analyses would be performed (under folders 'comparison1' & 'wtdmso_vs_wtdrug'). In both cases all of the factor columns in the samplesheet will be used in the design.

A motif file in [meme](https://meme-suite.org/meme/doc/meme-format.html) format can be supplied as well. If this is the case, the motifs will first be clustered, and motif enrichments will be calculated for all differential regions (using [ame](https://meme-suite.org/meme/doc/ame.html)). Note that the 'reciprocal' differential peaks will be used as background. E.g. group2 differential peaks are background for group1 enrichments and vice versa. Note that this approach could be biased if there is a strong disbalance between those groups.
