hogprof 0.3.0__py3-none-any.whl

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.
@@ -0,0 +1,231 @@
1
+ Metadata-Version: 2.4
2
+ Name: hogprof
3
+ Version: 0.3.0
4
+ Summary: Phylogenetic Profiling with OMA and minhashing
5
+ Author-email: Dave Moi <dmoi@unil.ch>, Athina Gavriilidou <athina.gavriilidou@unil.ch>, Nikolai Romashchenko <nikolai.romashchenko@unil.ch>
6
+ Maintainer-email: Nikolai Romashchenko <nikolai.romashchenko@unil.ch>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/DessimozLab/HogProf
9
+ Project-URL: Bug Tracker, https://github.com/DessimozLab/HogProf/issues
10
+ Project-URL: Docs, https://dessimozlab.github.io/HogProf/
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: <3.13,>=3.11
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: biopython
19
+ Requires-Dist: datasketch
20
+ Requires-Dist: ete3
21
+ Requires-Dist: goatools
22
+ Requires-Dist: h5py
23
+ Requires-Dist: legacy-cgi; python_version >= "3.13"
24
+ Requires-Dist: lxml
25
+ Requires-Dist: numpy
26
+ Requires-Dist: pandas
27
+ Requires-Dist: polars
28
+ Requires-Dist: pyham>=1.1.10
29
+ Requires-Dist: pyoma>=0.14.2
30
+ Requires-Dist: rich
31
+ Requires-Dist: tables
32
+ Provides-Extra: ml
33
+ Requires-Dist: keras; extra == "ml"
34
+ Dynamic: license-file
35
+
36
+ # HogProf
37
+
38
+ [![tests](https://github.com/DessimozLab/HogProf/actions/workflows/ci.yml/badge.svg)](https://github.com/DessimozLab/HogProf/actions/workflows/ci.yml)
39
+ [![release](https://img.shields.io/pypi/v/HogProf.svg)](https://pypi.org/project/HogProf/)
40
+ [![cite](https://img.shields.io/badge/DOI-10.1371%2Fjournal.pcbi.1007553-blue)](https://doi.org/10.1371/journal.pcbi.1007553)
41
+
42
+ HogProf is an extensible and tunable approach to phylogenetic profiling using orthology data. It is powered by minhash-based data structures and computationally efficient.
43
+
44
+ # Features
45
+ - Using orthoxoml files and a taxonomy calculated enhanced phylogenies of each family
46
+ - These are transformed into minhash signatures and a locally sensitive hashing forest object for search and comparison of profiles
47
+ - Taxonomic levels and evolutionary event types (presence, loss, duplication) can have custom weight in profile construction
48
+ - Optimization of weights using machine learning
49
+
50
+ If you run into any problems, feel free to contact me at [dmoi@unil.ch](dmoi@unil.ch)
51
+
52
+ # Quickstart
53
+ ## Install from PyPI (recommended)
54
+
55
+ ```bash
56
+ pip install hogprof
57
+ ```
58
+
59
+ ## Install from sources
60
+ ```bash
61
+ git clone https://github.com/DessimozLab/HogProf.git
62
+ cd HogProf
63
+ pip install .
64
+ ```
65
+
66
+
67
+ # Usage: main mode
68
+
69
+ ## Example: using the OMA database
70
+ Let's get a current version of the OMA hdf5 file and GAF. This will aloww us to use the HOGs and study the functional enrichment of our search results. **Careful, this download is heavy (hundreds of GB)**:
71
+
72
+ ```bash
73
+ mkdir YourOmaDirectory
74
+ cd YourOmaDirectory
75
+ wget https://omabrowser.org/All/OmaServer.h5
76
+ wget https://omabrowser.org/All/oma-go.txt.gz
77
+ ```
78
+
79
+ The latest release (May.2026) is more than 300GB in size. Alternatively, you can use earlier releases, for example:
80
+ ```bash
81
+ wget https://omabrowser.org/All.Jul2024/OmaServer.h5
82
+ ```
83
+ which is 180GB in size. For other releases, check `https://omabrowser.org/oma/archives/`, select release and search for "OMA Browser database (as hdf5)".
84
+
85
+
86
+ We also need to make a location to store our pyprofiler databases
87
+
88
+ ```bash
89
+ cd ..
90
+ mkdir YourHogProfDirectory
91
+ ```
92
+
93
+ Let's now compile a database containing all HOGs and our desired taxonomic levels using default settings. Launch the lshbuilder as shown below.
94
+ `dbtypes` available on the command line are: `all`, `plants`, `archaea`, `bacteria`, `eukarya`, `protists`, `fungi`, `metazoa`, and `vertebrates`. These will use the NCBI taxonomy as a tree to annotate events in different gene family's histories.
95
+
96
+ If you are using an OMA release before 2022 you will need to use the NCBI tree. This is the default tree used by HogProf.
97
+
98
+ ```
99
+ lshbuilder --outpath YourHogProfDirectory --dbtype all --OMA YourOmaDirectory/OmaServer.h5 --nthreads numberOfCPUcores
100
+
101
+ ```
102
+
103
+ If you are using OMA releases after 2022 we will also be downloading the OMA taxonomic tree since it is more accurate than the NCBI tree. This will be used to annotate the events in the gene family histories.
104
+
105
+ ```bash
106
+ wget https://omabrowser.org/All/speciestree.nwk
107
+ ```
108
+
109
+ We are ready to use the OMA tree to build our database.
110
+
111
+ ```bash
112
+ lshbuilder --outpath YourHogProfDirectory --dbtype all --OMA YourOmaDirectory/OmaServer.h5 --nthreads numberOfCPUcores --mastertree YourOmaDirectory/speciestree.nwk --reformat_names True
113
+
114
+ ```
115
+
116
+ This should build a taxonomic tree for the genomes contained in the release and then calculate enhanced phylogenies for all HOGs in OMA.
117
+
118
+ Once the database is completed it can be interogated using a profiler object. Construction and usage of this object should be done using a python script or notebook. This shown in the example notebook searchenrich.ipynb found in the examples. Please feel free to modify it to suit the needs of your own research.
119
+
120
+
121
+ # Usage: levels mode
122
+
123
+ The installation process is the same (github only for now).
124
+
125
+ A fastOMA result folder is expected as input.
126
+
127
+ **Step 1**: split the orthoxml into HOG-specific orthoxmls, using this script (requires a fastOMA installation):
128
+ ```
129
+ python path/to/HogProf/src/HogProf/splitter.py \
130
+ /path/to/output_directory \
131
+ --fastoma-path /path/to/FastOMA
132
+ ```
133
+
134
+ **Step 2**: build the HogProf database in **levels mode** by running `lshbuilder.py` with the `--slicesubhogs` option enabled. Point `--OrthoGlob` to the HOG-specific OrthoXML files generated in Step 1 and provide the species tree used by FastOMA.
135
+
136
+ ```bash
137
+ python path/to/HogProf/src/HogProf/lshbuilder.py \
138
+ --OrthoGlob "/path/to/fastoma_results/splits/*.orthoxml" \
139
+ --outpath "/path/to/output_database/" \
140
+ --mastertree "/path/to/fastoma_results/species_tree_checked.nwk" \
141
+ --reformat_names True \
142
+ --slicesubhogs True \
143
+ --eventslim 1 \
144
+ --nthreads 20
145
+ ```
146
+
147
+ Required parameters:
148
+ - `--OrthoGlob`: glob matching the HOG-specific OrthoXML files created in Step 1.
149
+ - `--outpath`: output directory for the HogProf database.
150
+ - `--mastertree`: species tree corresponding to the FastOMA run.
151
+ - `--slicesubhogs True`: enables levels mode by generating profiles for subHOGs.
152
+
153
+ Common optional parameters:
154
+ - `--eventslim`: minimum number of evolutionary events required to retain a subHOG (e.g. `1`).
155
+ - `--specieslim`: minimum number of species required in a subHOG (default: `10`).
156
+ - `--nthreads`: number of CPU threads to use.
157
+ - `--reformat_names True`: recommended if the species tree labels need to be converted to numeric identifiers.
158
+
159
+ **Step 3**: generate Jaccard similarity distributions and compute threshold tables from the HogProf database.
160
+
161
+ This step analyzes the output of `lshbuilder` and produces the **bin-wise Jaccard threshold table** used for downstream filtering and scoring.
162
+
163
+ ```bash
164
+ python path/to/HogProf/src/HogProf/generate_jaccard_distr.py \
165
+ --hogprof_folder "/path/to/2a_hogprof_output/" \
166
+ --output "/path/to/output_distributions/" \
167
+ --profiler-path "/path/to/profiler.py"
168
+ ```
169
+
170
+ Required parameters:
171
+ - `--hogprof_folder`: folder containing the HogProf LSHbuilder output (Step 2).
172
+ - `--output`: directory where distribution plots and threshold tables will be written.
173
+
174
+ Optional parameters:
175
+ - `--profiler-path`: path to `profiler.py`.
176
+ By default, this points to the `profiler.py` located in the same directory as the script.
177
+
178
+ ### Output
179
+
180
+ This step produces a key file used for thresholding:
181
+
182
+ - `bins_jaccard_thresholds.csv`
183
+ → table of Jaccard similarity thresholds computed per bin, used for downstream scoring and filtering.
184
+
185
+ The file is saved in the directory specified by `--output`.
186
+
187
+ **Step 4**: extract level-specific hits using the HogProf profiler.
188
+
189
+ This step runs `extract_levels_hits.py` to query the HogProf database built in Step 2 and generate a ranked list of hits per subHOG using the threshold table generated in Step 3.
190
+
191
+ ```bash
192
+ python path/to/HogProf/src/HogProf/extract_levels_hits.py \
193
+ --input "/path/to/hogprof_output/" \
194
+ --outputfile "/path/to/output/extracted_hits.csv" \
195
+ --queries_file "/path/to/queries.tsv" \
196
+ --thresholds "/path/to/bins_jaccard_thresholds.csv" \
197
+ --k 1000 \
198
+ --allvsall True \
199
+ --profilerpath "profiler.py"
200
+ ```
201
+
202
+ Required parameters:
203
+ - `--input`: HogProf LSHbuilder output directory (Step 2).
204
+ Must contain files such as:
205
+ `newlshforest.pkl`, `hashes.h5`, `reformatted_tree.nwk`, `fam2orthoxml.csv`, `profilersavingpath.csv`.
206
+ - `--outputfile`: path to the CSV file where extracted hits will be saved.
207
+ - `--queries_file`: table of query subHOGs (e.g. venom HOGs).
208
+ Must contain a `hashid` column and a subHOG identifier column.
209
+ - `--thresholds`: CSV file generated in Step 3 (`bins_jaccard_thresholds.csv`).
210
+
211
+ Optional parameters:
212
+ - `--k`: number of top hits to retain per query (default: `1000`).
213
+ - `--allvsall`: also performs all-vs-all comparisons (default: `True`, may be computationally expensive).
214
+ - `--profilerpath`: path to `profiler.py` from HogProf (default assumes local availability).
215
+
216
+ ### Output
217
+
218
+ This step produces:
219
+
220
+ - `extracted_hits.csv`
221
+ → ranked hit table containing similarity matches between query subHOGs and the HogProf database, filtered using bin-specific Jaccard thresholds.
222
+
223
+ **Step 5**: visualize coevolution networks in Cytoscape.
224
+
225
+ This final step uses the Jupyter notebook `cytoscape_import.ipynb` to generate and export coevolution networks from the extracted HogProf hits.
226
+
227
+ The notebook loads the output from Step 4 and prepares network files that can be visualized in Cytoscape.
228
+
229
+ In addition to the extracted hits, the notebook requires a **nodes metadata table** corresponding to the query subHOGs used in Step 4.
230
+
231
+ Once the database is completed it can be interogated using a profiler object. Construction and usage of this object should be done using a python script or notebook. This shown in the example notebook `searchenrich.ipynb` found in the examples. Please feel free to modify it to suit the needs of your own research.
@@ -0,0 +1,21 @@
1
+ hogprof/__init__.py,sha256=7rqlOVFXe5yUDqVX6h0Yem3IiY9cNQAVekevBdmyZ0o,116
2
+ hogprof/cli.py,sha256=nTWDx4R_WG3X5q6WYQaw6I4iLWHXyz_6d1r_nfV754w,17707
3
+ hogprof/extract_levels_hits.py,sha256=eftkHDYTG9H6zCD-zWnxLG6cvAgP9wtfb2KeAbI_Tyw,24079
4
+ hogprof/generate_jaccard_distr.py,sha256=6hG_NV3fIjj6ctNK1khe-fmQK0kQAfca7nUESrRYhtc,23385
5
+ hogprof/lshbuilder.py,sha256=4jw88UjF6CqTgO2Ie1QoZ0iPbQ2bd85i6z0r4D_aqp4,27643
6
+ hogprof/metadata.py,sha256=D3KkjPcx55FtsM5cXoWzoK-Y5iZDE8p_9OaUTuf1txQ,3736
7
+ hogprof/presets.py,sha256=OFrFbJLc2DJkvLuWKf8LLBISqeznCLqaPVa5UVwdzGc,886
8
+ hogprof/profiler.py,sha256=Bb7G_gB2rL1cu5YcKcUz1jjaBnVhhBId-JbURdSxgUI,12065
9
+ hogprof/splitter.py,sha256=MRrr1bafw-5k_-oAG56dBJgn-X4rYH8IXI5kKiAXKv8,1659
10
+ hogprof/utils/__init__.py,sha256=ARYQ-WG3KfimoQSbXHHTLaIxt159Z8nou0U3BVB2wwk,15
11
+ hogprof/utils/goautils.py,sha256=_7sGI8YWPUqfHfx-X4D5UcSUQlc8i38OmkCSSc6WLWg,7295
12
+ hogprof/utils/hashutils.py,sha256=3gBYZChcXhw84ZpNu2K4KXBftGOnWBWesFsSkJeVkwY,7512
13
+ hogprof/utils/orthoxml.py,sha256=9KJh7LqijvXz2yiDDlC30tAqkAgxYvfoZarjTn_hTw8,3132
14
+ hogprof/utils/phylo.py,sha256=uPjdTSTVgekgUleQutK4Vgysj3xKArfjpnFGi4UEKgs,10338
15
+ hogprof/utils/pyhamutils.py,sha256=RS9t1u29A1EjHBdqqB_A7zhjK9NlaXQwZcJPD2DVd6w,8610
16
+ hogprof-0.3.0.dist-info/licenses/LICENSE,sha256=IK4QE3H9NvFJ0rBXXqRL7x_eASMoUdRsaWW_AZ5bbpo,1066
17
+ hogprof-0.3.0.dist-info/METADATA,sha256=ZMBtkvbQJSbz-hzfEw5lrhEvVsoA2VvzzEvhhaXA2hw,10063
18
+ hogprof-0.3.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
19
+ hogprof-0.3.0.dist-info/entry_points.txt,sha256=oWplV2sOD59S9onpyjsvifG437ttqS5GILBB6UOP_eY,67
20
+ hogprof-0.3.0.dist-info/top_level.txt,sha256=vAhZifQO9UrL4XGD20aCcYKmleslCfSNsmSi8uSEOpE,8
21
+ hogprof-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ hogprof = hogprof.cli:main
3
+ hp = hogprof.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 David Moi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ hogprof