Skip to content

Commit bcc12a5

Browse files
authored
Merge pull request #238 from ClareRobin/clare_dev_pr
Add genome-alignment and RNA004 support (xPore v2.2)
2 parents 63fcaa6 + d2d2b41 commit bcc12a5

26 files changed

Lines changed: 2007 additions & 116 deletions

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
# ubuntu-22.04 (not ubuntu-latest) so that Python 3.8 is reliably available via setup-python.
10+
runs-on: ubuntu-22.04
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
python-version: ["3.8", "3.9", "3.10"]
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install package with test dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install .[test]
25+
- name: Run tests
26+
run: pytest -v

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
include xpore/diffmod/model_kmer.csv
1+
include xpore/diffmod/RNA002_5mer_model.csv
2+
include xpore/diffmod/RNA004_5mer_model.csv

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ xPore is described in details in [Pratanwanich et al. *Nat Biotechnol* (2021)](h
3333

3434
### Release History
3535

36-
The current release is xPore v2.1.
36+
The current release is xPore v2.2, which adds support for genome-aligned eventalign output (via the new `--kmer_source model_kmer` flag) and RNA004 data (now the default `xpore-diffmod` prior).
3737

3838
Please refer to the github release history for previous releases: https://github.com/GoekeLab/xpore/releases
3939

docs/source/cmd.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ Argument name Required Default value Descriptio
1717
================================= ========== =================== ============================================================================================================
1818
--eventalign=FILE Yes NA Eventalign filepath, the output from nanopolish.
1919
--out_dir=DIR Yes NA Output directory.
20-
--gtf_path_or_url No NA GTF file path or url used for mapping transcriptomic to genomic coordinates.
21-
--transcript_fasta_paths_or_urls No NA Transcript FASTA paths or urls used for mapping transcriptomic to genomic coordinates.
20+
--gtf_or_gff=FILE No NA GTF or GFF file path used for mapping transcriptomic to genomic coordinates.
21+
--transcript_fasta=FILE No NA Transcript FASTA path used for mapping transcriptomic to genomic coordinates.
2222
--skip_eventalign_indexing No False To skip indexing the eventalign nanopolish output.
2323
--genome No False To run on Genomic coordinates. Without this argument, the program will run on transcriptomic coordinates.
24+
--kmer_source=STR No reference_kmer Which kmer column to use from the eventalign file: ``reference_kmer`` (default, for transcriptome alignments) or ``model_kmer`` (for genome alignments, which contain reverse-strand reads).
2425
--n_processes=NUM No 1 Number of processes to run.
25-
--readcount_max=NUM No 1000 Maximum read counts per gene.
26+
--readcount_max=NUM No 1000 Maximum read counts per site. Use None for no limit.
2627
--readcount_min=NUM No 1 Minimum read counts per gene.
2728
--resume No False With this argument, the program will resume from the previous run.
2829
================================= ========== =================== ============================================================================================================

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
author = 'Ploy N. Pratanwanich'
2727

2828
# The short X.Y version
29-
version = '2.0'
29+
version = '2.2'
3030
# The full version, including alpha/beta/rc tags
31-
release = '2.0'
31+
release = '2.2'
3232

3333

3434
# -- General configuration ---------------------------------------------------

docs/source/configuration.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ Only the ``data`` and ``out`` sections are required, other sections are optional
2121
...
2222

2323
out: <DIR_PATH_FOR_OUTPUTS>
24-
24+
25+
# Optional: path to a CSV of unmodified-RNA kmer signal priors with columns
26+
# model_kmer,model_mean,model_stdv. If omitted, xpore-diffmod defaults to the
27+
# bundled RNA004 5mer model (xpore/diffmod/RNA004_5mer_model.csv).
28+
# For RNA002 data, set this to the bundled RNA002 model, e.g.:
29+
# prior: /path/to/xpore/diffmod/RNA002_5mer_model.csv
30+
prior: <PATH_TO_PRIOR_CSV>
31+
2532
criteria:
2633
readcount_min: <15>
2734
readcount_max: <1000>

docs/source/outputtable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ mu_mod inferred mean of the modified RNAs d
1818
sigma2_unmod inferred sigma^2 of the unmodified RNAs distribution
1919
sigma2_mod inferred sigma^2 of the modified RNAs distribution
2020
conf_mu_unmod confidence level of mu_unmod compared to the unmodified reference signal
21-
conf_mu_mod confidence level of mu_unmod compared to the unmodified reference signal
21+
conf_mu_mod confidence level of mu_mod compared to the unmodified reference signal
2222
mod_assignment lower if mu_mod < mu_unmod and higher if mu_mod > mu_unmod
2323
========================================== ========================================================================================================================================

docs/source/preparation.rst

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,38 @@
33
Data preparation from raw reads
44
===================================
55

6-
1. After obtaining fast5 files, the first step is to basecall them. Below is an example script to run Guppy basecaller. You can find more detail about basecalling at `Oxford nanopore Technologies <https://nanoporetech.com>`_::
7-
8-
guppy_basecaller -i </PATH/TO/FAST5> -s </PATH/TO/FASTQ> --flowcell <FLOWCELL_ID> --kit <KIT_ID> --device auto -q 0 -r
9-
10-
2. Align to transcriptome::
11-
12-
minimap2 -ax map-ont -uf -t 3 --secondary=no <MMI> <PATH/TO/FASTQ.GZ> > <PATH/TO/SAM> 2>> <PATH/TO/SAM_LOG>
13-
samtools view -Sb <PATH/TO/SAM> | samtools sort -o <PATH/TO/BAM> - &>> <PATH/TO/BAM_LOG>
14-
samtools index <PATH/TO/BAM> &>> <PATH/TO/BAM_INDEX_LOG>
15-
16-
3. Resquiggle using `nanopolish eventalign <https://nanopolish.readthedocs.io/en/latest/quickstart_eventalign.html>`_::
17-
18-
nanopolish index -d <PATH/TO/FAST5_DIR> <PATH/TO/FASTQ_FILE>
19-
nanopolish eventalign --reads <PATH/TO/FASTQ_FILE> \
20-
--bam <PATH/TO/BAM_FILE> \
21-
--genome <PATH/TO/FASTA_FILE \
22-
--signal-index \
23-
--scale-events \
24-
--summary <PATH/TO/summary.txt> \
25-
--threads 32 > <PATH/TO/eventalign.txt>
6+
1. After obtaining the raw signal files (POD5, or FAST5 for older runs), the first step is to basecall them. Below is an example using `Dorado <https://github.com/nanoporetech/dorado>`_, Oxford Nanopore's current basecaller (it replaces the older Guppy/Albacore basecallers and supports both RNA002 and RNA004 chemistries — select the model that matches your chemistry). You can find more detail about basecalling at `Oxford Nanopore Technologies <https://nanoporetech.com>`_::
267

8+
dorado basecaller <MODEL> </PATH/TO/POD5_DIR> --emit-fastq > <PATH/TO/FASTQ>
9+
10+
For RNA004 data use an ``rna004`` model (e.g. ``rna004_130bps_sup@v5.1.0``); for RNA002 data use an ``rna002`` model. See the `Dorado documentation <https://github.com/nanoporetech/dorado>`_ for the available models and options.
11+
12+
2. Align the basecalled reads with `minimap2 <https://github.com/lh3/minimap2>`_. xPore supports both **transcriptome** and **genome** alignments — choose one depending on which coordinate system you want in the output.
13+
14+
**Transcriptome alignment** (align to a transcriptome reference). xPore reports transcriptomic coordinates, or genomic coordinates if you also pass ``--genome`` together with ``--gtf_or_gff`` and ``--transcript_fasta`` to ``xpore dataprep``::
15+
16+
minimap2 -ax map-ont -uf -t 3 --secondary=no <TRANSCRIPTOME.MMI> <PATH/TO/FASTQ.GZ> > <PATH/TO/SAM> 2>> <PATH/TO/SAM_LOG>
17+
samtools view -Sb <PATH/TO/SAM> | samtools sort -o <PATH/TO/BAM> - &>> <PATH/TO/BAM_LOG>
18+
samtools index <PATH/TO/BAM> &>> <PATH/TO/BAM_INDEX_LOG>
19+
20+
**Genome alignment** (align directly to a genome reference; use spliced alignment so that reads spanning introns map correctly). Genome alignments contain reverse-strand reads, so run ``xpore dataprep`` with ``--kmer_source model_kmer`` for these (see :ref:`Command line arguments <cmd>`)::
21+
22+
minimap2 -ax splice -uf -k14 -t 3 --secondary=no <GENOME.MMI> <PATH/TO/FASTQ.GZ> > <PATH/TO/SAM> 2>> <PATH/TO/SAM_LOG>
23+
samtools view -Sb <PATH/TO/SAM> | samtools sort -o <PATH/TO/BAM> - &>> <PATH/TO/BAM_LOG>
24+
samtools index <PATH/TO/BAM> &>> <PATH/TO/BAM_INDEX_LOG>
25+
26+
3. Resquiggle (align the raw signal to the reference) to produce the eventalign file. We recommend `f5c <https://github.com/hasindu2008/f5c>`_, an optimised, CPU/GPU-accelerated re-implementation of ``nanopolish eventalign`` that produces equivalent output much faster on large datasets::
27+
28+
# index the raw signal: use -d <FAST5_DIR> for FAST5, or --slow5 <FILE.blow5> for SLOW5/BLOW5
29+
f5c index -d <PATH/TO/FAST5_DIR> <PATH/TO/FASTQ_FILE>
30+
f5c eventalign --reads <PATH/TO/FASTQ_FILE> \
31+
--bam <PATH/TO/BAM_FILE> \
32+
--genome <PATH/TO/REFERENCE_FASTA> \
33+
--rna \
34+
--signal-index \
35+
--scale-events \
36+
--threads 32 > <PATH/TO/eventalign.txt>
37+
38+
For **RNA004** data, add ``--kmer-model <PATH/TO/5-mer-model>``: recent versions of f5c auto-select the 9-mer model for RNA004, which xPore cannot use — xPore requires the 5-mer model (see `xPore issue #215 <https://github.com/GoekeLab/xpore/issues/215>`_).
39+
40+
``nanopolish eventalign`` can be used instead with the same arguments. Note that the ``--genome`` argument here refers to the **alignment reference** (the transcriptome or genome FASTA used in step 2), not xPore's ``--genome`` flag.

docs/source/quickstart.rst

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,44 @@
33
Quickstart - Detection of differential RNA modifications
44
=========================================================
55

6+
.. note::
7+
**Updates in xPore v2.2:** xPore is now compatible with genome alignments and RNA004 data — see the table below and the :ref:`Data preparation from raw reads <preparation>` section for more information.
8+
9+
xPore is now compatible with genome alignment. See below for the minimal commands to run xPore on transcriptome- or genome-aligned data:
10+
11+
.. list-table::
12+
:header-rows: 1
13+
:widths: 22 48 30
14+
15+
* -
16+
- **Dataprep**
17+
- **Diffmod**
18+
* - Transcriptome alignment (output transcriptome coordinates)
19+
- | ``xpore dataprep``
20+
| ``--eventalign <eventalign.txt>``
21+
| ``--out_dir <out_dir>``
22+
- | ``xpore diffmod``
23+
| ``--config <config.yml>``
24+
* - Transcriptome alignment (output genome coordinates)
25+
- | ``xpore dataprep``
26+
| ``--eventalign <eventalign.txt>``
27+
| ``--out_dir <out_dir>``
28+
| ``--genome``
29+
| ``--transcript_fasta <transcript.fa>``
30+
| ``--gtf_or_gff <annotation.gtf>``
31+
- | ``xpore diffmod``
32+
| ``--config <config.yml>``
33+
* - Genome alignment
34+
- | ``xpore dataprep``
35+
| ``--eventalign <eventalign.txt>``
36+
| ``--out_dir <out_dir>``
37+
| ``--kmer_source model_kmer``
38+
- | ``xpore diffmod``
39+
| ``--config <config.yml>``
40+
41+
Running Example Demo Data
42+
-------------------------
43+
644
Download and extract the demo dataset from our `zenodo <https://zenodo.org/record/5162402/files/demo.tar.gz>`_::
745

846
wget https://zenodo.org/record/5162402/files/demo.tar.gz
@@ -61,8 +99,12 @@ Below is how it looks like::
6199

62100
out: ./out # output dir
63101

102+
# The demo data is RNA002. Since v2.2 the default prior is the RNA004 model,
103+
# so point xpore-diffmod at the bundled RNA002 model to reproduce the demo:
104+
prior: /path/to/xpore/diffmod/RNA002_5mer_model.csv
105+
64106

65-
See the :ref:`Configuration file page <configuration>` for more details.
107+
See the :ref:`Configuration file page <configuration>` for more details. Note that since xPore v2.2 the default unmodified-signal prior is the RNA004 model; for RNA002 data (like this demo) set ``prior:`` to the bundled ``RNA002_5mer_model.csv`` as shown above.
66108

67109
3. Now that we have the data and the configuration file ready for modelling differential modifications using ``xpore-diffmod``.
68110

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
name=__pkg_name__,
1515
license="MIT",
1616
description='xpore is a python package for Nanopore data analysis of differential RNA modifications.',
17-
version='v2.1',
17+
version='v2.2',
1818
long_description=README,
1919
long_description_content_type='text/markdown',
2020
url='https://github.com/GoekeLab/xpore',
@@ -30,6 +30,7 @@
3030
'ujson>=4.0.1'
3131
],
3232
python_requires=">=3.8",
33+
extras_require={'test': ['pytest']},
3334
entry_points={'console_scripts': ["xpore={}.scripts.xpore:main".format(__pkg_name__)]},
3435
classifiers=[
3536
# Trove classifiers

0 commit comments

Comments
 (0)