Metadata-Version: 2.4
Name: cresschrom1
Version: 0.1.3
Summary: Small dataset of Arabidopsis chromosome 1
Author-email: Anthony Aylward <anthony.aylward@protonmail.com>
Project-URL: Homepage, https://gitlab.com/aaylward/cresschrom1
Project-URL: Documentation, https://aaylward.gitlab.io/cresschrom1
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: biopython
Requires-Dist: pysradb
Requires-Dist: openpyxl
Dynamic: license-file

# CressChrom1

## Introduction

This package contains a set of minimal eukaryotic genome and transcriptome datasets from chromosme 1 of *Arabidopsis thaliana*. They may, for example, be useful for rapidly testing a RNA-seq bioinformatics pipeline.

## Installation

Ensure your computing environment includes Python 3.11 or later and the following bioinformatics tools:
- sra-tools
- pigz
- fastp
- kraken2
- openpyxl

Conda is useful for setting up this environment. Then, cresschrom1 can be installed with Pip:

```sh
conda create -c conda-forge -c bioconda -n cresschrom1 \
  biopython pysradb sra-tools pigz fastp kraken2 openpyxl
conda activate cresschrom1
pip install cresschrom1
```

## Usage

Run `cresschrom1` without arguments to list the help text of all subcommands

```sh
cresschrom1
```
```
usage: cresschrom1 [-h] [--version] {init,path,metadata,download,sheet,trim,classify} ...

Small dataset of Arabidopsis chromosome 1

positional arguments:
  {init,path,metadata,download,sheet,trim,classify}
    init                fully initialize the dataset by downloading, trimming, and classifying RNA-seq reads
    path                show paths to data directory and files
    metadata            fetch sra metadata
    download            download RNA-seq reads
    sheet               sample sheet for cresschrom1 rna-seq dataset
    trim                trim downloaded reads
    classify            classify downloaded reads

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
```

To download and downsample all RNA-seq data, run:

```sh
cresschrom1 init
```

Use `cresschrom1 path` to get the absolute path for a data file
```sh
cresschrom1 path data-dir
cresschrom1 path genome
cresschrom1 path cds
cresschrom1 path pep
cresschrom1 path gff
cresschrom1 path gtf
cresschrom1 path sheet
```

`cresschrom1 path` can also fetch paths to datasets for the two alternate species:

```sh
cresschrom1 path genome-atha
cresschrom1 path genome-aare
```

To see the sample sheet listing the locations of the RNA-seq reads:
```sh
cresschrom1 sheet
```

If you need the data at another location, you can symbolically link to the cresschrom1 dataset, or copy the contents to another directory
```sh
ln -s `cresschrom1 path data-dir` test_data/
cp -r `cresschrom1 path data-dir` test_data/
```

To see the SRA metadata of the RNA-seq reads:
```sh
cresschrom1 metadata
```

To execute the initialization steps individually:
```sh
cresschrom1 download
cresschrom1 trim
cresschrom1 classify
```

## Datasets
![cresschrom1-datasets.png](docs/source/_static/cresschrom1-datasets.png)

There are two groups of datasets: 
1. The directly included package data of **chromosome 1** sequence and annotation from [*A. thaliana* assembly TAIR10](https://www.ncbi.nlm.nih.gov/datasets/genome/GCF_000001735.4/) at NCBI, including:
    * Genome sequence (FASTA)
    * Coding sequences (FASTA)
    * mRNA transcripts (FASTA)
    * Peptide sequences (FASTA)
    * Gene annotation (GFF3, GTF)
    * Sequences and annotations are also included for another *Arabidopsis* species, [*A. arenosa*](https://www.ncbi.nlm.nih.gov/datasets/genome/GCA_905216605.1/). Two additional recent genome asseblies of [*A. arenosa*](https://www.ncbi.nlm.nih.gov/datasets/genome/GCA_026151155.1/) and [*A. lyrata*](https://www.ncbi.nlm.nih.gov/datasets/genome/GCA_026151145.1/), which were published in [Bramsiepe et al. (2023)](https://onlinelibrary.wiley.com/doi/10.1111/tpj.16401), are also included. The *A. arenosa* and *A. lyrata* assemblies are restricted to chromosomes 1 and 2, which are colinear with *A. thaliana*'s chromosome 1.
2. The RNA-seq reads are from a curated list published by from [Shintani et al. (2024)](https://www.frontiersin.org/journals/plant-science/articles/10.3389/fpls.2024.1343787/full). They are downloaded from SRA/NCBI and downsampled to include only chromosome 1 reads by running an included script.

## Downsampling RNA-seq
![cresschrom1-init.png](docs/source/_static/cresschrom1-init.png)

During the initialization process, after the RNA-seq reads are downloaded they are downsampled by:
1. Adapter and quality trimming with `fastp`
2. Classification with `kraken2` to filter out all reads that do not match chromosome I

## Configuration
You can configure some cresschrom1 settings using environment variables or a TOML file.

### Environment variables
```sh
export cresschrom1_DOWNLOAD_DIR = /absolute/path/to/directory/
export cresschrom1_TAXID = <integer>
export cresschrom1_SAMPLE_SHEET = /absolute/path/to/sample_sheet.csv
export cresschrom1_KRAKEN2_DB /absolute/path/to/kraken2_db/
```

### Config file
By default, cresschrom1 looks for configuration in TOML format at `$HOME/.cresschrom1.toml`

```toml
download_dir = /absolute/path/to/directory/
taxid = <integer>
sample_sheet = /absolute/path/to/sample_sheet.csv
kraken2_db = /absolute/path/to/kraken2_db/
```

The location of the config file can also be set using an environment variable:
```sh
export cresschrom1_CONFIG_FILE=/absolute/path/to/alternate/config.toml
```

## Python API

cresschrom1 resources can also be accessed from within python:

```python
import cresschrom1
cresschrom1.init()
cresschrom1.path('genome')
cresschrom1.path('genome-aare')
metadata = cresschrom1.metadata()
sample_sheet = cresschrom1.create_sample_sheet(metadata)
cresschrom1.write_sample_sheet(sample_sheet, 'sample_sheet.csv')
cresschrom1.download()
cresschrom1.trim('reads_1.fastq.gz', 'reads_2.fastq.gz')
cresschrom1.classify('reads_1.fastq.gz', 'reads_2.fastq.gz')
cresschrom1.taxid
cresschrom1.busco
```

## Example usage with nf-core pipelines

### Conda environment
```sh
conda create -c conda-forge -c bioconda -n cresschrom1-nf-core \
  biopython pysradb sra-tools pigz fastp kraken2 openpyxl \
  nextflow nf-core
conda activate cresschrom1-nf-core
pip install cresschrom1
```

### nf-core/genomeqc
```sh
echo '{"is_plant": true, "skip_busco": false, "skip_tidk": false}' > genomeqc-params.json
cresschrom1 sheet --pipeline nf-core-genomeqc > sample_sheet.csv
nextflow run nf-core/genomeqc -r 1.0.1 \
  -profile <docker/singularity/.../institute> \
  -params-file genomeqc-params.json \
  --input sample_sheet.csv \
  --outdir genomeqc_output_dir/ \
  --busco_lineage `cresschrom1 busco`
```

### nf-core/seqinspector
```sh
cresschrom1 sheet --pipeline nf-core-seqinspector > sample_sheet.csv
nextflow run nf-core/seqinspector \
  -profile <docker/singularity/.../institute> \
  --input sample_sheet.csv \
  --outdir seqinspector_output_dir/ \
  --fasta `cresschrom1 path genome`
```

### nf-core/rnaseq
```sh
cresschrom1 sheet > sample_sheet.csv
nextflow run nf-core/rnaseq \
  -profile <docker/singularity/.../institute> \
  --input sample_sheet.csv \
  --outdir rnaseq_output_dir/ \
  --fasta `cresschrom1 path genome` \
  --gtf `cresschrom1 path gtf`
```

### nf-core/denovotranscript
```sh
cresschrom1 sheet > sample_sheet.csv
nextflow run nf-core/denovotranscript -r 1.2.1 \
  -profile <docker/singularity/.../institute> \
  --input sample_sheet.csv \
  --outdir denovotranscript_output_dir/ \
  --assemblers rnaspades
```
