NextPyper 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. nextpyper-0.1.0/MANIFEST.in +5 -0
  2. nextpyper-0.1.0/NextPyper.egg-info/PKG-INFO +231 -0
  3. nextpyper-0.1.0/NextPyper.egg-info/SOURCES.txt +72 -0
  4. nextpyper-0.1.0/NextPyper.egg-info/dependency_links.txt +1 -0
  5. nextpyper-0.1.0/NextPyper.egg-info/entry_points.txt +3 -0
  6. nextpyper-0.1.0/NextPyper.egg-info/requires.txt +14 -0
  7. nextpyper-0.1.0/NextPyper.egg-info/top_level.txt +1 -0
  8. nextpyper-0.1.0/PKG-INFO +231 -0
  9. nextpyper-0.1.0/README.md +196 -0
  10. nextpyper-0.1.0/nextpyper/__init__.py +0 -0
  11. nextpyper-0.1.0/nextpyper/__main__.py +429 -0
  12. nextpyper-0.1.0/nextpyper/config/config.yaml +80 -0
  13. nextpyper-0.1.0/nextpyper/config/rich_config.yaml +54 -0
  14. nextpyper-0.1.0/nextpyper/config/system_config.yaml +10 -0
  15. nextpyper-0.1.0/nextpyper/data/blosum62.csv +32 -0
  16. nextpyper-0.1.0/nextpyper/data/cps_seqids.csv +674 -0
  17. nextpyper-0.1.0/nextpyper/data/mock/mock_args.yaml +17 -0
  18. nextpyper-0.1.0/nextpyper/data/mock/probes.fasta +56 -0
  19. nextpyper-0.1.0/nextpyper/data/mock/reads/sample1_R1.fastq +20 -0
  20. nextpyper-0.1.0/nextpyper/data/mock/reads/sample1_R2.fastq +20 -0
  21. nextpyper-0.1.0/nextpyper/data/mock/reads/sample2_R1.fastq +20 -0
  22. nextpyper-0.1.0/nextpyper/data/mock/reads/sample2_R2.fastq +20 -0
  23. nextpyper-0.1.0/nextpyper/data/mock/reads/sample3_R1.fastq +20 -0
  24. nextpyper-0.1.0/nextpyper/data/mock/reads/sample3_R2.fastq +20 -0
  25. nextpyper-0.1.0/nextpyper/data/mock/sample.tsv +4 -0
  26. nextpyper-0.1.0/nextpyper/nextpyper.CITATION +9 -0
  27. nextpyper-0.1.0/nextpyper/nextpyper.LICENSE +19 -0
  28. nextpyper-0.1.0/nextpyper/nextpyper.VERSION +1 -0
  29. nextpyper-0.1.0/nextpyper/src/divergence_estimation.py +131 -0
  30. nextpyper-0.1.0/nextpyper/src/diversity.py +93 -0
  31. nextpyper-0.1.0/nextpyper/src/exon_discovery.py +294 -0
  32. nextpyper-0.1.0/nextpyper/src/exon_intron.py +197 -0
  33. nextpyper-0.1.0/nextpyper/src/fix_headers.py +107 -0
  34. nextpyper-0.1.0/nextpyper/src/gfa2fasta.py +71 -0
  35. nextpyper-0.1.0/nextpyper/src/gfa_graph.py +1245 -0
  36. nextpyper-0.1.0/nextpyper/src/gff_parser.py +344 -0
  37. nextpyper-0.1.0/nextpyper/src/graph_utils.py +201 -0
  38. nextpyper-0.1.0/nextpyper/src/homolog_filtering.py +411 -0
  39. nextpyper-0.1.0/nextpyper/src/miniprot.py +1008 -0
  40. nextpyper-0.1.0/nextpyper/src/multi_seq_probes.py +292 -0
  41. nextpyper-0.1.0/nextpyper/src/run_orfipy.py +493 -0
  42. nextpyper-0.1.0/nextpyper/src/sample_table.py +63 -0
  43. nextpyper-0.1.0/nextpyper/src/seeds_collection.py +387 -0
  44. nextpyper-0.1.0/nextpyper/src/summarize_results.py +507 -0
  45. nextpyper-0.1.0/nextpyper/src/union_find.py +65 -0
  46. nextpyper-0.1.0/nextpyper/src/var_asm_parser.py +229 -0
  47. nextpyper-0.1.0/nextpyper/test/.gitkeep +0 -0
  48. nextpyper-0.1.0/nextpyper/workflow/Snakefile +62 -0
  49. nextpyper-0.1.0/nextpyper/workflow/envs/alignment.yaml +7 -0
  50. nextpyper-0.1.0/nextpyper/workflow/envs/assembly.yaml +8 -0
  51. nextpyper-0.1.0/nextpyper/workflow/envs/clustering.yaml +9 -0
  52. nextpyper-0.1.0/nextpyper/workflow/envs/matching.yaml +8 -0
  53. nextpyper-0.1.0/nextpyper/workflow/envs/preprocessing.yaml +11 -0
  54. nextpyper-0.1.0/nextpyper/workflow/envs/saute.yaml +7 -0
  55. nextpyper-0.1.0/nextpyper/workflow/envs/translating.yaml +8 -0
  56. nextpyper-0.1.0/nextpyper/workflow/rules/0_preprocessing/0.1_reads.smk +90 -0
  57. nextpyper-0.1.0/nextpyper/workflow/rules/0_preprocessing/0.2_probes.smk +16 -0
  58. nextpyper-0.1.0/nextpyper/workflow/rules/1_seeds_assembly/1.1_assembly_spades.smk +48 -0
  59. nextpyper-0.1.0/nextpyper/workflow/rules/1_seeds_assembly/1.2_seeds_extension.smk +90 -0
  60. nextpyper-0.1.0/nextpyper/workflow/rules/1_seeds_assembly/1.3_seeds_filtering.smk +64 -0
  61. nextpyper-0.1.0/nextpyper/workflow/rules/1_seeds_assembly/1.4_seeds_clustering.smk +73 -0
  62. nextpyper-0.1.0/nextpyper/workflow/rules/2_homologs_assembly/2.1_saute_assembly.smk +228 -0
  63. nextpyper-0.1.0/nextpyper/workflow/rules/3_homolog_prospection/3.1_allele_collapsing.smk +23 -0
  64. nextpyper-0.1.0/nextpyper/workflow/rules/3_homolog_prospection/3.2_homologs_filtering.smk +76 -0
  65. nextpyper-0.1.0/nextpyper/workflow/rules/3_homolog_prospection/3.3_region_separation.smk +189 -0
  66. nextpyper-0.1.0/nextpyper/workflow/rules/common.smk +160 -0
  67. nextpyper-0.1.0/nextpyper/workflow/schemas/probes.yaml +12 -0
  68. nextpyper-0.1.0/nextpyper/workflow/schemas/sample_table.yaml +29 -0
  69. nextpyper-0.1.0/nextpyper/workflow/scripts/bench_busco.py +572 -0
  70. nextpyper-0.1.0/nextpyper/workflow/scripts/categories_bench.sh +92 -0
  71. nextpyper-0.1.0/nextpyper/workflow/scripts/end_recs_parser.py +146 -0
  72. nextpyper-0.1.0/nextpyper/workflow/scripts/tribble_stats.py +131 -0
  73. nextpyper-0.1.0/pyproject.toml +57 -0
  74. nextpyper-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,5 @@
1
+ include nextpyper/nextpyper.LICENSE
2
+ include nextpyper/nextpyper.CITATION
3
+ include nextpyper/nextpyper.VERSION
4
+ recursive-include nextpyper *
5
+ prune nextpyper/workflow/conda
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: NextPyper
3
+ Version: 0.1.0
4
+ Summary: Recovery of homoeologous loci from target capture data in higher ploidy samples
5
+ Author-email: Simón Villanueva Corrales <simon.corrales@ibot.cas.cz>, "Yann J.K. Bertrand" <Yann.Bertrand@ibot.cas.cz>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/M2BL/NextPyper
8
+ Project-URL: Documentation, https://m2bl.github.io/NextPyper
9
+ Classifier: Environment :: Console
10
+ Classifier: Environment :: MacOS X
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Requires-Python: >=3.12
18
+ Description-Content-Type: text/markdown
19
+ License-File: nextpyper/nextpyper.LICENSE
20
+ Requires-Dist: snaketool-utils>=0.0.4
21
+ Requires-Dist: snakemake>=9.21
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: Click>=8.1.3
24
+ Requires-Dist: rich-click>=1.9.7
25
+ Requires-Dist: pandas>=2.2
26
+ Requires-Dist: biopython>=1.83
27
+ Requires-Dist: numpy>=1.26
28
+ Requires-Dist: scikit-learn>=1.5
29
+ Requires-Dist: scipy>=1.14
30
+ Requires-Dist: polars>=1.32.3
31
+ Requires-Dist: intervaltree>=3.1
32
+ Requires-Dist: kmedoids>=0.5.3.1
33
+ Requires-Dist: more-itertools>=10.7
34
+ Dynamic: license-file
35
+
36
+ # NextPyper
37
+ Recovery of homoeologous loci from target capture data in higher ploidy samples.
38
+
39
+ ## Documentation
40
+
41
+ Please refer to the [official documentation](https://m2bl.github.io/NextPyper/), which is more complete.
42
+
43
+ ## Table of contents
44
+
45
+ - [Installation](#installation)
46
+ - [Conda/Mamba](#condamamba)
47
+ - [Pip](#pip)
48
+ - [Manual](#manual)
49
+ - [Environments setup (recommended)](#environments-setup-recommended)
50
+ - [Usage](#usage)
51
+ - [1. Preparing your probes](#1-preparing-your-probes)
52
+ - [Single-probe sets](#single-probe-sets)
53
+ - [Multi-probe sets](#multi-probe-sets)
54
+ - [2. Preparing your samples](#2-preparing-your-samples)
55
+ - [3. Running NextPyper](#3-running-nextpyper)
56
+ - [Output](#output)
57
+ - [Sequence versions](#sequence-versions)
58
+ - [Output structure](#output-structure)
59
+
60
+
61
+ ## Installation
62
+
63
+ Regardless of the installation method, `NextPyper` requires `conda` in your PATH, to manage and deploy workflow environments.
64
+
65
+ ### Conda/Mamba
66
+
67
+ If you already have [bioconda](https://bioconda.github.io/) set up, you can create a new environment and simply run:
68
+
69
+ ```bash
70
+ conda install nextpyper # or mamba
71
+ ```
72
+
73
+ ### Pip
74
+
75
+ Alternatively you can use pip:
76
+
77
+ ```
78
+ pip install nextpyper
79
+ ```
80
+
81
+ ### Manual
82
+
83
+ You can also install NextPyper manually with pip. We recommend to create a new environment.
84
+
85
+ ```bash
86
+ # from your new environment with pip
87
+ git clone git@github.com:M2BL/NextPyper.git
88
+ cd NextPyper
89
+ pip install .
90
+ ```
91
+
92
+ ## Environments setup (recommended)
93
+
94
+ NextPyper uses [snakemake](https://snakemake.github.io/) to orchestrate and execute the different steps of the workflow, which uses conda to set up the packages and environments required at each stage.
95
+
96
+ The first time you run NextPyper, this setup will be done automatically at the start of the workflow.
97
+
98
+ Alternatively, you can set up these environments beforehand by running:
99
+
100
+ ```bash
101
+ nextpyper prepare
102
+ ```
103
+
104
+ This command creates the required environments within NextPyper's installation path. You can use the option `--conda-prefix` to specify a different path where to store these environments.
105
+
106
+ ## Usage
107
+
108
+ NextPyper requires two inputs, a probes file with the targets of your experiment, and a sample table describing where to find the data of your samples.
109
+
110
+ ### 1. Preparing your probes
111
+
112
+ NextPyper expects a nucleotide fasta file with the sequences of the targeted loci, what we call the probe set. Probe sets can be divided into two categories:
113
+
114
+ - **Multi probe sets**: Contains multiple sequences per locus/gene (*e.g.* Angiosperms353).
115
+ - **Single probe sets**: Contains a single sequence per locus. Usually, custom probe sets designed from a single reference genome fall in this category.
116
+
117
+ Sequence names in the probe set are required to be simple (letters, numbers and underscore, characters only). Additionally no duplicated names are allowed.
118
+
119
+ Currently, only coding regions that can be translated are supported.
120
+
121
+ #### Single-probe sets
122
+
123
+ If you are using a single-probe set, you only need to worry about sticking to the naming conventions described above. To check your probes, you can use `nextpyper validate`:
124
+
125
+ ```bash
126
+ $ nextpyper validate --probes probes.fasta
127
+
128
+ # Probe sequence names comply with naming convention.
129
+ # Pattern (.*) yielded no grouping of the sequences.
130
+ # Either this is a single-probe set or the pattern is not appropriate for multi-probe mode
131
+ ```
132
+
133
+ If you get the message above, your probe set is well formatted to run in single-probes mode.
134
+
135
+ #### Multi-probe sets
136
+
137
+ If using a multi-probe set, NextPyper needs to know which sequences target the same locus. The option `--pattern` expects a RegEx (with one capture group) that will inform about that hierarchy based on the name of the probes.
138
+
139
+ For instance, for the Angiosperms353 probe set with sequence names:
140
+
141
+ ```
142
+ AJFN_probe4471
143
+ Ambtr_probe4471
144
+ BERS_probe4527
145
+ ZENX_probe4527
146
+ Arath_probe4691
147
+ QUTB_probe4691
148
+ ```
149
+
150
+ We can use `--pattern "(\d+)$"`, which will group the sequences by the number at the end of the sequence name (which is the LocusID).
151
+
152
+ You can use the `validate` subcommand to check if your pattern groups your probes:
153
+
154
+ ```bash
155
+ $ nextpyper validate --probes kew_probes.fasta --pattern "(\d+)$"
156
+
157
+ # Probe sequence names comply with naming convention.
158
+ # The pattern yields 353 groups from 4781 probe sequences
159
+ ```
160
+
161
+ Use the options `--out_summary` and `--out_hierarchy` to get more details about the grouping.
162
+
163
+ ### 2. Preparing your samples
164
+
165
+ NextPyper expects a 4-column table that defines the identity and ploidy of your samples, and where to find their associated data.
166
+
167
+ Knowledge about your samples' ploidy is not required to run NextPyper. Simply set it to 0, if you do not know it, or do not want to take it into account.
168
+
169
+ The table requires a header with 4 columns (see an example here):
170
+
171
+ - sample: the name of the sample.
172
+ - path_forward: absolute path to the forward reads. It can be .gz compressed.
173
+ - path_reverse: absolute path to the reverse reads. It can be .gz compressed.
174
+ - ploidy: the ploidy of the sample. If 0, ploidy won't be taken into account to process the sample.
175
+
176
+ You can use the `gather` subcommand to help you create the sample table. From a data directory ([like this one](https://github.com/M2BL/NextPyper/tree/main/nextpyper/data/mock/reads)) with only the paired-end data (forward and reverse files) you can run:
177
+
178
+ ```bash
179
+ nextpyper gather --input data_folder --output sample.tsv
180
+ ```
181
+
182
+ To get the input the sample table for your samples. See an example of the result [here](https://github.com/M2BL/NextPyper/blob/main/nextpyper/data/mock/sample.tsv).
183
+
184
+ The sample names are inferred based on the common prefix between the forward and reverse files.
185
+
186
+ ### 3. Running NextPyper
187
+
188
+ Finally, use the `run` subcommand to start the workflow. For single-probes you do not need to specify a pattern, so simply provide the inputs we prepared:
189
+
190
+ ```bash
191
+ nextpyper run --threads 16 --single-probes --input input_samples.tsv --probes custom_probes.fasta --output out_single
192
+ ```
193
+
194
+ For multi-probes, specify the appropriate pattern as well:
195
+
196
+ ```bash
197
+ nextpyper run --threads 16 --input new_hier_samples.tsv --probes kew_probes.fasta --pattern "(\d+)$" --output out_multi
198
+ ```
199
+
200
+
201
+ ## Output
202
+
203
+ ### Sequence versions
204
+
205
+ The main output of NextPyper are the samples' homologous sequences for each targeted locus. We generate 3 versions of these sequences, depending on the final postprocessing:
206
+
207
+ - **Exons**: includes only the exonic part of the sequence.
208
+ - **Genetigs**: includes exons and introns.
209
+ - **Supercontigs**: The full sequence, including exons, introns and flanking regions.
210
+
211
+ The exons are the shorter and more conserved version of the output sequences, while the supercontigs are longer and include all discovered variation (which can be a bit noisy). Genetigs usually provide a good balance, containing more signal than the exons without it being overwhelming. You may want to explore which type of sequence suits better your purposes.
212
+
213
+ ### Output structure
214
+
215
+ NextPyper organizes its main outputs in the following fashion:
216
+
217
+ - Homologous sequences per sample: `<outdir>/outputs/seqs_per_sample`
218
+ - Homologous sequences per locus: `<outdir>/outputs/seqs_per_locus`
219
+ - Loci Multiple Sequence Alignments (MSAs): `<outdir>/outputs/alignments`
220
+
221
+ NextPyper output directory follows the following structure:
222
+
223
+ ```
224
+ outdir
225
+ ├── config.yaml # Final config with parameters used to run the workflow.
226
+ ├── execution.log # Snakemake execution log of all workflow jobs.
227
+ ├── logs/ # Logs generated by the workflow jobs.
228
+ ├── nextpyper.log # Summary of params and snakemake invocation.
229
+ ├── outputs/ # Final outputs of the workflow.
230
+ └── workflow/ # Working folder for all the jobs and stages of the pipeline. It contains intermediate and final files.
231
+ ```
@@ -0,0 +1,72 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ NextPyper.egg-info/PKG-INFO
5
+ NextPyper.egg-info/SOURCES.txt
6
+ NextPyper.egg-info/dependency_links.txt
7
+ NextPyper.egg-info/entry_points.txt
8
+ NextPyper.egg-info/requires.txt
9
+ NextPyper.egg-info/top_level.txt
10
+ nextpyper/__init__.py
11
+ nextpyper/__main__.py
12
+ nextpyper/nextpyper.CITATION
13
+ nextpyper/nextpyper.LICENSE
14
+ nextpyper/nextpyper.VERSION
15
+ nextpyper/config/config.yaml
16
+ nextpyper/config/rich_config.yaml
17
+ nextpyper/config/system_config.yaml
18
+ nextpyper/data/blosum62.csv
19
+ nextpyper/data/cps_seqids.csv
20
+ nextpyper/data/mock/mock_args.yaml
21
+ nextpyper/data/mock/probes.fasta
22
+ nextpyper/data/mock/sample.tsv
23
+ nextpyper/data/mock/reads/sample1_R1.fastq
24
+ nextpyper/data/mock/reads/sample1_R2.fastq
25
+ nextpyper/data/mock/reads/sample2_R1.fastq
26
+ nextpyper/data/mock/reads/sample2_R2.fastq
27
+ nextpyper/data/mock/reads/sample3_R1.fastq
28
+ nextpyper/data/mock/reads/sample3_R2.fastq
29
+ nextpyper/src/divergence_estimation.py
30
+ nextpyper/src/diversity.py
31
+ nextpyper/src/exon_discovery.py
32
+ nextpyper/src/exon_intron.py
33
+ nextpyper/src/fix_headers.py
34
+ nextpyper/src/gfa2fasta.py
35
+ nextpyper/src/gfa_graph.py
36
+ nextpyper/src/gff_parser.py
37
+ nextpyper/src/graph_utils.py
38
+ nextpyper/src/homolog_filtering.py
39
+ nextpyper/src/miniprot.py
40
+ nextpyper/src/multi_seq_probes.py
41
+ nextpyper/src/run_orfipy.py
42
+ nextpyper/src/sample_table.py
43
+ nextpyper/src/seeds_collection.py
44
+ nextpyper/src/summarize_results.py
45
+ nextpyper/src/union_find.py
46
+ nextpyper/src/var_asm_parser.py
47
+ nextpyper/test/.gitkeep
48
+ nextpyper/workflow/Snakefile
49
+ nextpyper/workflow/envs/alignment.yaml
50
+ nextpyper/workflow/envs/assembly.yaml
51
+ nextpyper/workflow/envs/clustering.yaml
52
+ nextpyper/workflow/envs/matching.yaml
53
+ nextpyper/workflow/envs/preprocessing.yaml
54
+ nextpyper/workflow/envs/saute.yaml
55
+ nextpyper/workflow/envs/translating.yaml
56
+ nextpyper/workflow/rules/common.smk
57
+ nextpyper/workflow/rules/0_preprocessing/0.1_reads.smk
58
+ nextpyper/workflow/rules/0_preprocessing/0.2_probes.smk
59
+ nextpyper/workflow/rules/1_seeds_assembly/1.1_assembly_spades.smk
60
+ nextpyper/workflow/rules/1_seeds_assembly/1.2_seeds_extension.smk
61
+ nextpyper/workflow/rules/1_seeds_assembly/1.3_seeds_filtering.smk
62
+ nextpyper/workflow/rules/1_seeds_assembly/1.4_seeds_clustering.smk
63
+ nextpyper/workflow/rules/2_homologs_assembly/2.1_saute_assembly.smk
64
+ nextpyper/workflow/rules/3_homolog_prospection/3.1_allele_collapsing.smk
65
+ nextpyper/workflow/rules/3_homolog_prospection/3.2_homologs_filtering.smk
66
+ nextpyper/workflow/rules/3_homolog_prospection/3.3_region_separation.smk
67
+ nextpyper/workflow/schemas/probes.yaml
68
+ nextpyper/workflow/schemas/sample_table.yaml
69
+ nextpyper/workflow/scripts/bench_busco.py
70
+ nextpyper/workflow/scripts/categories_bench.sh
71
+ nextpyper/workflow/scripts/end_recs_parser.py
72
+ nextpyper/workflow/scripts/tribble_stats.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ my-cli = nextpyper.src:cli
3
+ nextpyper = nextpyper.__main__:main
@@ -0,0 +1,14 @@
1
+ snaketool-utils>=0.0.4
2
+ snakemake>=9.21
3
+ pyyaml>=6.0
4
+ Click>=8.1.3
5
+ rich-click>=1.9.7
6
+ pandas>=2.2
7
+ biopython>=1.83
8
+ numpy>=1.26
9
+ scikit-learn>=1.5
10
+ scipy>=1.14
11
+ polars>=1.32.3
12
+ intervaltree>=3.1
13
+ kmedoids>=0.5.3.1
14
+ more-itertools>=10.7
@@ -0,0 +1 @@
1
+ nextpyper
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: NextPyper
3
+ Version: 0.1.0
4
+ Summary: Recovery of homoeologous loci from target capture data in higher ploidy samples
5
+ Author-email: Simón Villanueva Corrales <simon.corrales@ibot.cas.cz>, "Yann J.K. Bertrand" <Yann.Bertrand@ibot.cas.cz>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/M2BL/NextPyper
8
+ Project-URL: Documentation, https://m2bl.github.io/NextPyper
9
+ Classifier: Environment :: Console
10
+ Classifier: Environment :: MacOS X
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Requires-Python: >=3.12
18
+ Description-Content-Type: text/markdown
19
+ License-File: nextpyper/nextpyper.LICENSE
20
+ Requires-Dist: snaketool-utils>=0.0.4
21
+ Requires-Dist: snakemake>=9.21
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: Click>=8.1.3
24
+ Requires-Dist: rich-click>=1.9.7
25
+ Requires-Dist: pandas>=2.2
26
+ Requires-Dist: biopython>=1.83
27
+ Requires-Dist: numpy>=1.26
28
+ Requires-Dist: scikit-learn>=1.5
29
+ Requires-Dist: scipy>=1.14
30
+ Requires-Dist: polars>=1.32.3
31
+ Requires-Dist: intervaltree>=3.1
32
+ Requires-Dist: kmedoids>=0.5.3.1
33
+ Requires-Dist: more-itertools>=10.7
34
+ Dynamic: license-file
35
+
36
+ # NextPyper
37
+ Recovery of homoeologous loci from target capture data in higher ploidy samples.
38
+
39
+ ## Documentation
40
+
41
+ Please refer to the [official documentation](https://m2bl.github.io/NextPyper/), which is more complete.
42
+
43
+ ## Table of contents
44
+
45
+ - [Installation](#installation)
46
+ - [Conda/Mamba](#condamamba)
47
+ - [Pip](#pip)
48
+ - [Manual](#manual)
49
+ - [Environments setup (recommended)](#environments-setup-recommended)
50
+ - [Usage](#usage)
51
+ - [1. Preparing your probes](#1-preparing-your-probes)
52
+ - [Single-probe sets](#single-probe-sets)
53
+ - [Multi-probe sets](#multi-probe-sets)
54
+ - [2. Preparing your samples](#2-preparing-your-samples)
55
+ - [3. Running NextPyper](#3-running-nextpyper)
56
+ - [Output](#output)
57
+ - [Sequence versions](#sequence-versions)
58
+ - [Output structure](#output-structure)
59
+
60
+
61
+ ## Installation
62
+
63
+ Regardless of the installation method, `NextPyper` requires `conda` in your PATH, to manage and deploy workflow environments.
64
+
65
+ ### Conda/Mamba
66
+
67
+ If you already have [bioconda](https://bioconda.github.io/) set up, you can create a new environment and simply run:
68
+
69
+ ```bash
70
+ conda install nextpyper # or mamba
71
+ ```
72
+
73
+ ### Pip
74
+
75
+ Alternatively you can use pip:
76
+
77
+ ```
78
+ pip install nextpyper
79
+ ```
80
+
81
+ ### Manual
82
+
83
+ You can also install NextPyper manually with pip. We recommend to create a new environment.
84
+
85
+ ```bash
86
+ # from your new environment with pip
87
+ git clone git@github.com:M2BL/NextPyper.git
88
+ cd NextPyper
89
+ pip install .
90
+ ```
91
+
92
+ ## Environments setup (recommended)
93
+
94
+ NextPyper uses [snakemake](https://snakemake.github.io/) to orchestrate and execute the different steps of the workflow, which uses conda to set up the packages and environments required at each stage.
95
+
96
+ The first time you run NextPyper, this setup will be done automatically at the start of the workflow.
97
+
98
+ Alternatively, you can set up these environments beforehand by running:
99
+
100
+ ```bash
101
+ nextpyper prepare
102
+ ```
103
+
104
+ This command creates the required environments within NextPyper's installation path. You can use the option `--conda-prefix` to specify a different path where to store these environments.
105
+
106
+ ## Usage
107
+
108
+ NextPyper requires two inputs, a probes file with the targets of your experiment, and a sample table describing where to find the data of your samples.
109
+
110
+ ### 1. Preparing your probes
111
+
112
+ NextPyper expects a nucleotide fasta file with the sequences of the targeted loci, what we call the probe set. Probe sets can be divided into two categories:
113
+
114
+ - **Multi probe sets**: Contains multiple sequences per locus/gene (*e.g.* Angiosperms353).
115
+ - **Single probe sets**: Contains a single sequence per locus. Usually, custom probe sets designed from a single reference genome fall in this category.
116
+
117
+ Sequence names in the probe set are required to be simple (letters, numbers and underscore, characters only). Additionally no duplicated names are allowed.
118
+
119
+ Currently, only coding regions that can be translated are supported.
120
+
121
+ #### Single-probe sets
122
+
123
+ If you are using a single-probe set, you only need to worry about sticking to the naming conventions described above. To check your probes, you can use `nextpyper validate`:
124
+
125
+ ```bash
126
+ $ nextpyper validate --probes probes.fasta
127
+
128
+ # Probe sequence names comply with naming convention.
129
+ # Pattern (.*) yielded no grouping of the sequences.
130
+ # Either this is a single-probe set or the pattern is not appropriate for multi-probe mode
131
+ ```
132
+
133
+ If you get the message above, your probe set is well formatted to run in single-probes mode.
134
+
135
+ #### Multi-probe sets
136
+
137
+ If using a multi-probe set, NextPyper needs to know which sequences target the same locus. The option `--pattern` expects a RegEx (with one capture group) that will inform about that hierarchy based on the name of the probes.
138
+
139
+ For instance, for the Angiosperms353 probe set with sequence names:
140
+
141
+ ```
142
+ AJFN_probe4471
143
+ Ambtr_probe4471
144
+ BERS_probe4527
145
+ ZENX_probe4527
146
+ Arath_probe4691
147
+ QUTB_probe4691
148
+ ```
149
+
150
+ We can use `--pattern "(\d+)$"`, which will group the sequences by the number at the end of the sequence name (which is the LocusID).
151
+
152
+ You can use the `validate` subcommand to check if your pattern groups your probes:
153
+
154
+ ```bash
155
+ $ nextpyper validate --probes kew_probes.fasta --pattern "(\d+)$"
156
+
157
+ # Probe sequence names comply with naming convention.
158
+ # The pattern yields 353 groups from 4781 probe sequences
159
+ ```
160
+
161
+ Use the options `--out_summary` and `--out_hierarchy` to get more details about the grouping.
162
+
163
+ ### 2. Preparing your samples
164
+
165
+ NextPyper expects a 4-column table that defines the identity and ploidy of your samples, and where to find their associated data.
166
+
167
+ Knowledge about your samples' ploidy is not required to run NextPyper. Simply set it to 0, if you do not know it, or do not want to take it into account.
168
+
169
+ The table requires a header with 4 columns (see an example here):
170
+
171
+ - sample: the name of the sample.
172
+ - path_forward: absolute path to the forward reads. It can be .gz compressed.
173
+ - path_reverse: absolute path to the reverse reads. It can be .gz compressed.
174
+ - ploidy: the ploidy of the sample. If 0, ploidy won't be taken into account to process the sample.
175
+
176
+ You can use the `gather` subcommand to help you create the sample table. From a data directory ([like this one](https://github.com/M2BL/NextPyper/tree/main/nextpyper/data/mock/reads)) with only the paired-end data (forward and reverse files) you can run:
177
+
178
+ ```bash
179
+ nextpyper gather --input data_folder --output sample.tsv
180
+ ```
181
+
182
+ To get the input the sample table for your samples. See an example of the result [here](https://github.com/M2BL/NextPyper/blob/main/nextpyper/data/mock/sample.tsv).
183
+
184
+ The sample names are inferred based on the common prefix between the forward and reverse files.
185
+
186
+ ### 3. Running NextPyper
187
+
188
+ Finally, use the `run` subcommand to start the workflow. For single-probes you do not need to specify a pattern, so simply provide the inputs we prepared:
189
+
190
+ ```bash
191
+ nextpyper run --threads 16 --single-probes --input input_samples.tsv --probes custom_probes.fasta --output out_single
192
+ ```
193
+
194
+ For multi-probes, specify the appropriate pattern as well:
195
+
196
+ ```bash
197
+ nextpyper run --threads 16 --input new_hier_samples.tsv --probes kew_probes.fasta --pattern "(\d+)$" --output out_multi
198
+ ```
199
+
200
+
201
+ ## Output
202
+
203
+ ### Sequence versions
204
+
205
+ The main output of NextPyper are the samples' homologous sequences for each targeted locus. We generate 3 versions of these sequences, depending on the final postprocessing:
206
+
207
+ - **Exons**: includes only the exonic part of the sequence.
208
+ - **Genetigs**: includes exons and introns.
209
+ - **Supercontigs**: The full sequence, including exons, introns and flanking regions.
210
+
211
+ The exons are the shorter and more conserved version of the output sequences, while the supercontigs are longer and include all discovered variation (which can be a bit noisy). Genetigs usually provide a good balance, containing more signal than the exons without it being overwhelming. You may want to explore which type of sequence suits better your purposes.
212
+
213
+ ### Output structure
214
+
215
+ NextPyper organizes its main outputs in the following fashion:
216
+
217
+ - Homologous sequences per sample: `<outdir>/outputs/seqs_per_sample`
218
+ - Homologous sequences per locus: `<outdir>/outputs/seqs_per_locus`
219
+ - Loci Multiple Sequence Alignments (MSAs): `<outdir>/outputs/alignments`
220
+
221
+ NextPyper output directory follows the following structure:
222
+
223
+ ```
224
+ outdir
225
+ ├── config.yaml # Final config with parameters used to run the workflow.
226
+ ├── execution.log # Snakemake execution log of all workflow jobs.
227
+ ├── logs/ # Logs generated by the workflow jobs.
228
+ ├── nextpyper.log # Summary of params and snakemake invocation.
229
+ ├── outputs/ # Final outputs of the workflow.
230
+ └── workflow/ # Working folder for all the jobs and stages of the pipeline. It contains intermediate and final files.
231
+ ```