hide-deconv 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 (51) hide show
  1. hide_deconv-0.1.0/LICENSE +21 -0
  2. hide_deconv-0.1.0/PKG-INFO +165 -0
  3. hide_deconv-0.1.0/README.md +130 -0
  4. hide_deconv-0.1.0/pyproject.toml +47 -0
  5. hide_deconv-0.1.0/src/hide_deconv/__init__.py +0 -0
  6. hide_deconv-0.1.0/src/hide_deconv/cli.py +592 -0
  7. hide_deconv-0.1.0/src/hide_deconv/cli_commands/__init__.py +36 -0
  8. hide_deconv-0.1.0/src/hide_deconv/cli_commands/analyze_command.py +601 -0
  9. hide_deconv-0.1.0/src/hide_deconv/cli_commands/anndata_command.py +205 -0
  10. hide_deconv-0.1.0/src/hide_deconv/cli_commands/config_command.py +175 -0
  11. hide_deconv-0.1.0/src/hide_deconv/cli_commands/deconvolve_command.py +139 -0
  12. hide_deconv-0.1.0/src/hide_deconv/cli_commands/download_command.py +72 -0
  13. hide_deconv-0.1.0/src/hide_deconv/cli_commands/help_command.py +69 -0
  14. hide_deconv-0.1.0/src/hide_deconv/cli_commands/preprocess_command.py +46 -0
  15. hide_deconv-0.1.0/src/hide_deconv/cli_commands/setup_command.py +241 -0
  16. hide_deconv-0.1.0/src/hide_deconv/cli_commands/simulate_command.py +154 -0
  17. hide_deconv-0.1.0/src/hide_deconv/cli_commands/train_command.py +29 -0
  18. hide_deconv-0.1.0/src/hide_deconv/config.py +106 -0
  19. hide_deconv-0.1.0/src/hide_deconv/constants/__init__.py +29 -0
  20. hide_deconv-0.1.0/src/hide_deconv/constants/messages.py +18 -0
  21. hide_deconv-0.1.0/src/hide_deconv/constants/misc.py +9 -0
  22. hide_deconv-0.1.0/src/hide_deconv/download/__init__.py +3 -0
  23. hide_deconv-0.1.0/src/hide_deconv/download/download_file.py +60 -0
  24. hide_deconv-0.1.0/src/hide_deconv/download/sc_repos.txt +11 -0
  25. hide_deconv-0.1.0/src/hide_deconv/models/HIDE.py +222 -0
  26. hide_deconv-0.1.0/src/hide_deconv/models/__init__.py +3 -0
  27. hide_deconv-0.1.0/src/hide_deconv/pipelines/__init__.py +14 -0
  28. hide_deconv-0.1.0/src/hide_deconv/pipelines/anndata_preprocess_pipeline.py +117 -0
  29. hide_deconv-0.1.0/src/hide_deconv/pipelines/deconvolve_hide_pipeline.py +113 -0
  30. hide_deconv-0.1.0/src/hide_deconv/pipelines/init_pipeline.py +80 -0
  31. hide_deconv-0.1.0/src/hide_deconv/pipelines/preprocess_pipeline.py +124 -0
  32. hide_deconv-0.1.0/src/hide_deconv/pipelines/training_pipeline.py +68 -0
  33. hide_deconv-0.1.0/src/hide_deconv/preprocessing/__init__.py +21 -0
  34. hide_deconv-0.1.0/src/hide_deconv/preprocessing/bulk_preprocessing.py +69 -0
  35. hide_deconv-0.1.0/src/hide_deconv/preprocessing/train_preprocessing.py +350 -0
  36. hide_deconv-0.1.0/src/hide_deconv/simulation/__init__.py +1 -0
  37. hide_deconv-0.1.0/src/hide_deconv/statistic/__init__.py +14 -0
  38. hide_deconv-0.1.0/src/hide_deconv/statistic/kruskal_wallis.py +86 -0
  39. hide_deconv-0.1.0/src/hide_deconv/statistic/mann_whitney_u.py +141 -0
  40. hide_deconv-0.1.0/src/hide_deconv/statistic/posthoc_dunn.py +129 -0
  41. hide_deconv-0.1.0/src/hide_deconv/statistic/survival_analysis.py +207 -0
  42. hide_deconv-0.1.0/src/hide_deconv/utils/__init__.py +21 -0
  43. hide_deconv-0.1.0/src/hide_deconv/utils/cli_utils.py +330 -0
  44. hide_deconv-0.1.0/src/hide_deconv/utils/config_utils.py +11 -0
  45. hide_deconv-0.1.0/src/hide_deconv/utils/download_utils.py +47 -0
  46. hide_deconv-0.1.0/src/hide_deconv/utils/optimization_utils.py +5 -0
  47. hide_deconv-0.1.0/src/hide_deconv/utils/sample_sheet_utils.py +18 -0
  48. hide_deconv-0.1.0/src/hide_deconv/visualization/__init__.py +5 -0
  49. hide_deconv-0.1.0/src/hide_deconv/visualization/compositions.py +189 -0
  50. hide_deconv-0.1.0/src/hide_deconv/visualization/loss.py +48 -0
  51. hide_deconv-0.1.0/src/hide_deconv/visualization/survival.py +220 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dennis Voelkl
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,165 @@
1
+ Metadata-Version: 2.4
2
+ Name: hide-deconv
3
+ Version: 0.1.0
4
+ Summary: HIDE-Deconv - Hierarchical Cell Type Deconvolution
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Author: Dennis Voelkl
8
+ Author-email: dennis.k.volkl@uib.no
9
+ Requires-Python: >=3.12,<3.15
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Requires-Dist: anndata (>=0.12.10,<0.13.0)
15
+ Requires-Dist: click (>=8.3.2,<9.0.0)
16
+ Requires-Dist: cvxpy (>=1.8.2,<2.0.0)
17
+ Requires-Dist: gurobipy (>=13.0.1,<14.0.0)
18
+ Requires-Dist: inquirerpy (>=0.3.4,<0.4.0)
19
+ Requires-Dist: lifelines (>=0.30.3,<0.31.0)
20
+ Requires-Dist: numpy (>=2.4.4,<3.0.0)
21
+ Requires-Dist: pandas (>=2.3.3,<3.0.0)
22
+ Requires-Dist: requests (>=2.33.1,<3.0.0)
23
+ Requires-Dist: rich (>=14.3.3,<15.0.0)
24
+ Requires-Dist: scanpy (>=1.12.1,<2.0.0)
25
+ Requires-Dist: scikit-learn (>=1.8.0,<2.0.0)
26
+ Requires-Dist: scikit-posthocs (>=0.12.0,<0.13.0)
27
+ Requires-Dist: scipy (>=1.17.1,<2.0.0)
28
+ Requires-Dist: seaborn (>=0.13.2,<0.14.0)
29
+ Requires-Dist: torch (>=2.11.0,<3.0.0)
30
+ Project-URL: Homepage, https://github.com/dvoelkl/HIDE-deconv
31
+ Project-URL: Issues, https://github.com/dvoelkl/HIDE-deconv/issues
32
+ Project-URL: Repository, https://github.com/dvoelkl/HIDE-deconv
33
+ Description-Content-Type: text/markdown
34
+
35
+ # HIDE-deconv
36
+
37
+ **Interactive command line tool and python package for hierarchical deconvolution and analysis of bulk RNA-seq data.**
38
+
39
+ ---
40
+
41
+ ## Features
42
+
43
+ - Designed for AnnData single cell datasets
44
+ - Open Source package, that can be run on safe servers
45
+ - Hierarchical cell type deconvolution for any number of cell type annotation layers
46
+ - Includes methods for post-deconvolution analysis
47
+ - Usable via command line interface and Python API
48
+ - Provides a guided workflow that allows users without programming experience to perform deconvolution
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ # Create and activate a new virtual environment (recommended)
54
+ python3 -m venv .venv
55
+ source .venv/bin/activate
56
+
57
+ # Install HIDE-deconv
58
+ pip install hide-deconv
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Necessary Data
64
+
65
+ - **Single-cell data:** Annotated AnnData (.h5ad) file with gene names in `adata.var_names` and cell type annotations for each desired layer in `adata.obs` (at least one layer of cell type annotations is necessary).
66
+ - **Bulk RNA-seq data:** CSV file, genes as row index, samples as columns. Gene IDs must match single-cell data.
67
+ - **Sample sheet (optional):** CSV with sample meta-information (e.g., cohort, survival time, event).
68
+ - **Data Normalization:** We recommend to use raw counts for all datasets.
69
+
70
+ ---
71
+
72
+ ## Command Line Workflow
73
+
74
+ **Deconvolution (standard workflow):**
75
+ ```bash
76
+ hide-deconv run --path <project_dir>
77
+ ```
78
+ This initializes the project, preprocesses data, trains the model, and runs deconvolution.
79
+
80
+ **Difference in composition & survival analysis:**
81
+ ```bash
82
+ hide-deconv analyze diff --path <project_dir>
83
+ hide-deconv analyze survival --path <project_dir>
84
+ ```
85
+ - For difference analysis, the sample sheet must contain columns for sample ID and cohort.
86
+ - For survival analysis, the sample sheet must contain columns for sample ID, survival time, and event.
87
+
88
+ **Command overview:**
89
+ ```bash
90
+ hide-deconv help
91
+ ```
92
+
93
+ This displays a short introduction to the command line interface and gives an overview of all available commands.
94
+
95
+ ---
96
+
97
+ ## API Example
98
+
99
+ ```python
100
+ import anndata as ad
101
+ import pandas as pd
102
+ import numpy as np
103
+ from hide_deconv.preprocessing import (
104
+ train_test_split_adata,
105
+ create_reference,
106
+ create_hierarchy,
107
+ create_bulks,
108
+ )
109
+ from hide_deconv.models import HIDE
110
+ from hide_deconv.statistic import run_mann_whitney_u
111
+
112
+ # 1. Load AnnData
113
+ adata = ad.read_h5ad("single_cells.h5ad")
114
+
115
+ # 2. Split into training and test set
116
+ adata_train, adata_test = train_test_split_adata(adata, celltype_col="cell_type", train_frac=0.7)
117
+
118
+ # 3. Create reference profiles and hierarchy (single layer example)
119
+ X_sub = create_reference(adata_train, celltype_col="cell_type")
120
+ A_l = [pd.DataFrame(np.eye(X_sub.shape[1]), index=X_sub.columns, columns=X_sub.columns)]
121
+ X_l = [X_sub]
122
+
123
+ # 4. Simulate training bulks
124
+ Y_train, C_train = create_bulks(adata_train, n_bulks=1000, n_cells_per_bulk=100, celltype_col="cell_type")
125
+
126
+ # 5. Simulate test bulks
127
+ Y_test, C_test = create_bulks(adata_test, n_bulks=100, n_cells_per_bulk=100, celltype_col="cell_type")
128
+
129
+ # 6. Initialize and train model
130
+ hide = HIDE(X_l, A_l)
131
+ hide.train(Y_train, C_train, iter=1000)
132
+
133
+ # 7. Deconvolution on test data
134
+ results = hide.predict(Y_test, norm=True)["prediction"]
135
+
136
+ # 8. Optional: Difference in composition analysis
137
+ # (requires a sample sheet with columns 'SampleID' and 'Cohort')
138
+
139
+ # sample_sheet = read_csv("sample_sheet.csv")
140
+ # diff = run_mann_whitney_u(results[0], sample_sheet, sample_id_col="SampleID", cohort_col="Cohort")
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Citation
146
+ HIDE-deconv's deconvolution algorithm is based on HIDE: Hierarchical Cell Type Deconvolution. If you use HIDE-deconv, please cite the following article.
147
+
148
+ Dennis Völkl, Malte Mensching-Buhr, Thomas Sterr, Sarah Bolz, Andreas Schäfer, Nicole Seifert, Jana Tauschke, Austin Rayford, Oddbjørn Straume, Helena U Zacharias, Sushma Nagaraja Grellscheid, Tim Beissbarth, Michael Altenbuchinger, Franziska Görtler, HIDE: hierarchical cell-type deconvolution, Bioinformatics, Volume 41, Issue Supplement_1, July 2025, Pages i207–i216, https://doi.org/10.1093/bioinformatics/btaf179
149
+
150
+ ---
151
+
152
+ ## License
153
+
154
+ This project is licensed under the MIT License.
155
+
156
+ ---
157
+
158
+ ## Contact
159
+
160
+ For questions, support or scientific collaboration:
161
+ - Dennis Voelkl: dennis.k.voelkl(at)uib.no
162
+ - Franziska Goertler: Franziska.Gortler(at)uib.no
163
+
164
+ ---
165
+
@@ -0,0 +1,130 @@
1
+ # HIDE-deconv
2
+
3
+ **Interactive command line tool and python package for hierarchical deconvolution and analysis of bulk RNA-seq data.**
4
+
5
+ ---
6
+
7
+ ## Features
8
+
9
+ - Designed for AnnData single cell datasets
10
+ - Open Source package, that can be run on safe servers
11
+ - Hierarchical cell type deconvolution for any number of cell type annotation layers
12
+ - Includes methods for post-deconvolution analysis
13
+ - Usable via command line interface and Python API
14
+ - Provides a guided workflow that allows users without programming experience to perform deconvolution
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ # Create and activate a new virtual environment (recommended)
20
+ python3 -m venv .venv
21
+ source .venv/bin/activate
22
+
23
+ # Install HIDE-deconv
24
+ pip install hide-deconv
25
+ ```
26
+
27
+ ---
28
+
29
+ ## Necessary Data
30
+
31
+ - **Single-cell data:** Annotated AnnData (.h5ad) file with gene names in `adata.var_names` and cell type annotations for each desired layer in `adata.obs` (at least one layer of cell type annotations is necessary).
32
+ - **Bulk RNA-seq data:** CSV file, genes as row index, samples as columns. Gene IDs must match single-cell data.
33
+ - **Sample sheet (optional):** CSV with sample meta-information (e.g., cohort, survival time, event).
34
+ - **Data Normalization:** We recommend to use raw counts for all datasets.
35
+
36
+ ---
37
+
38
+ ## Command Line Workflow
39
+
40
+ **Deconvolution (standard workflow):**
41
+ ```bash
42
+ hide-deconv run --path <project_dir>
43
+ ```
44
+ This initializes the project, preprocesses data, trains the model, and runs deconvolution.
45
+
46
+ **Difference in composition & survival analysis:**
47
+ ```bash
48
+ hide-deconv analyze diff --path <project_dir>
49
+ hide-deconv analyze survival --path <project_dir>
50
+ ```
51
+ - For difference analysis, the sample sheet must contain columns for sample ID and cohort.
52
+ - For survival analysis, the sample sheet must contain columns for sample ID, survival time, and event.
53
+
54
+ **Command overview:**
55
+ ```bash
56
+ hide-deconv help
57
+ ```
58
+
59
+ This displays a short introduction to the command line interface and gives an overview of all available commands.
60
+
61
+ ---
62
+
63
+ ## API Example
64
+
65
+ ```python
66
+ import anndata as ad
67
+ import pandas as pd
68
+ import numpy as np
69
+ from hide_deconv.preprocessing import (
70
+ train_test_split_adata,
71
+ create_reference,
72
+ create_hierarchy,
73
+ create_bulks,
74
+ )
75
+ from hide_deconv.models import HIDE
76
+ from hide_deconv.statistic import run_mann_whitney_u
77
+
78
+ # 1. Load AnnData
79
+ adata = ad.read_h5ad("single_cells.h5ad")
80
+
81
+ # 2. Split into training and test set
82
+ adata_train, adata_test = train_test_split_adata(adata, celltype_col="cell_type", train_frac=0.7)
83
+
84
+ # 3. Create reference profiles and hierarchy (single layer example)
85
+ X_sub = create_reference(adata_train, celltype_col="cell_type")
86
+ A_l = [pd.DataFrame(np.eye(X_sub.shape[1]), index=X_sub.columns, columns=X_sub.columns)]
87
+ X_l = [X_sub]
88
+
89
+ # 4. Simulate training bulks
90
+ Y_train, C_train = create_bulks(adata_train, n_bulks=1000, n_cells_per_bulk=100, celltype_col="cell_type")
91
+
92
+ # 5. Simulate test bulks
93
+ Y_test, C_test = create_bulks(adata_test, n_bulks=100, n_cells_per_bulk=100, celltype_col="cell_type")
94
+
95
+ # 6. Initialize and train model
96
+ hide = HIDE(X_l, A_l)
97
+ hide.train(Y_train, C_train, iter=1000)
98
+
99
+ # 7. Deconvolution on test data
100
+ results = hide.predict(Y_test, norm=True)["prediction"]
101
+
102
+ # 8. Optional: Difference in composition analysis
103
+ # (requires a sample sheet with columns 'SampleID' and 'Cohort')
104
+
105
+ # sample_sheet = read_csv("sample_sheet.csv")
106
+ # diff = run_mann_whitney_u(results[0], sample_sheet, sample_id_col="SampleID", cohort_col="Cohort")
107
+ ```
108
+
109
+ ---
110
+
111
+ ## Citation
112
+ HIDE-deconv's deconvolution algorithm is based on HIDE: Hierarchical Cell Type Deconvolution. If you use HIDE-deconv, please cite the following article.
113
+
114
+ Dennis Völkl, Malte Mensching-Buhr, Thomas Sterr, Sarah Bolz, Andreas Schäfer, Nicole Seifert, Jana Tauschke, Austin Rayford, Oddbjørn Straume, Helena U Zacharias, Sushma Nagaraja Grellscheid, Tim Beissbarth, Michael Altenbuchinger, Franziska Görtler, HIDE: hierarchical cell-type deconvolution, Bioinformatics, Volume 41, Issue Supplement_1, July 2025, Pages i207–i216, https://doi.org/10.1093/bioinformatics/btaf179
115
+
116
+ ---
117
+
118
+ ## License
119
+
120
+ This project is licensed under the MIT License.
121
+
122
+ ---
123
+
124
+ ## Contact
125
+
126
+ For questions, support or scientific collaboration:
127
+ - Dennis Voelkl: dennis.k.voelkl(at)uib.no
128
+ - Franziska Goertler: Franziska.Gortler(at)uib.no
129
+
130
+ ---
@@ -0,0 +1,47 @@
1
+ [project]
2
+ name = "hide-deconv"
3
+ version = "0.1.0"
4
+ description = "HIDE-Deconv - Hierarchical Cell Type Deconvolution"
5
+ authors = [
6
+ {name = "Dennis Voelkl",email = "dennis.k.volkl@uib.no"},
7
+ {name = "Franziska Goertler",email = "Franziska.Gortler@uib.no"}
8
+ ]
9
+ license = "MIT"
10
+ readme = "README.md"
11
+ requires-python = ">=3.12,<3.15"
12
+ dependencies = [
13
+ "anndata (>=0.12.10,<0.13.0)",
14
+ "torch (>=2.11.0,<3.0.0)",
15
+ "cvxpy (>=1.8.2,<2.0.0)",
16
+ "gurobipy (>=13.0.1,<14.0.0)",
17
+ "numpy (>=2.4.4,<3.0.0)",
18
+ "pandas (>=2.3.3,<3.0.0)",
19
+ "click (>=8.3.2,<9.0.0)",
20
+ "scikit-learn (>=1.8.0,<2.0.0)",
21
+ "scipy (>=1.17.1,<2.0.0)",
22
+ "inquirerpy (>=0.3.4,<0.4.0)",
23
+ "rich (>=14.3.3,<15.0.0)",
24
+ "seaborn (>=0.13.2,<0.14.0)",
25
+ "scikit-posthocs (>=0.12.0,<0.13.0)",
26
+ "requests (>=2.33.1,<3.0.0)",
27
+ "scanpy (>=1.12.1,<2.0.0)",
28
+ "lifelines (>=0.30.3,<0.31.0)"
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/dvoelkl/HIDE-deconv"
33
+ Repository = "https://github.com/dvoelkl/HIDE-deconv"
34
+ Issues = "https://github.com/dvoelkl/HIDE-deconv/issues"
35
+
36
+
37
+
38
+ [build-system]
39
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
40
+ build-backend = "poetry.core.masonry.api"
41
+
42
+ [project.scripts]
43
+ hide-deconv = "hide_deconv.cli:cli"
44
+ [dependency-groups]
45
+ dev = [
46
+ "pytest (>=9.0.3,<10.0.0)"
47
+ ]
File without changes