pg-sui 1.0.2.1__py3-none-any.whl → 1.6.8__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.

Potentially problematic release.


This version of pg-sui might be problematic. Click here for more details.

Files changed (112) hide show
  1. {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/METADATA +51 -70
  2. pg_sui-1.6.8.dist-info/RECORD +78 -0
  3. {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/WHEEL +1 -1
  4. pg_sui-1.6.8.dist-info/entry_points.txt +4 -0
  5. pg_sui-1.6.8.dist-info/top_level.txt +1 -0
  6. pgsui/__init__.py +35 -54
  7. pgsui/_version.py +34 -0
  8. pgsui/cli.py +635 -0
  9. pgsui/data_processing/config.py +576 -0
  10. pgsui/data_processing/containers.py +1782 -0
  11. pgsui/data_processing/transformers.py +121 -1103
  12. pgsui/electron/app/__main__.py +5 -0
  13. pgsui/electron/app/icons/icons/1024x1024.png +0 -0
  14. pgsui/electron/app/icons/icons/128x128.png +0 -0
  15. pgsui/electron/app/icons/icons/16x16.png +0 -0
  16. pgsui/electron/app/icons/icons/24x24.png +0 -0
  17. pgsui/electron/app/icons/icons/256x256.png +0 -0
  18. pgsui/electron/app/icons/icons/32x32.png +0 -0
  19. pgsui/electron/app/icons/icons/48x48.png +0 -0
  20. pgsui/electron/app/icons/icons/512x512.png +0 -0
  21. pgsui/electron/app/icons/icons/64x64.png +0 -0
  22. pgsui/electron/app/icons/icons/icon.icns +0 -0
  23. pgsui/electron/app/icons/icons/icon.ico +0 -0
  24. pgsui/electron/app/main.js +189 -0
  25. pgsui/electron/app/package-lock.json +6893 -0
  26. pgsui/electron/app/package.json +50 -0
  27. pgsui/electron/app/preload.js +15 -0
  28. pgsui/electron/app/server.py +146 -0
  29. pgsui/electron/app/ui/logo.png +0 -0
  30. pgsui/electron/app/ui/renderer.js +130 -0
  31. pgsui/electron/app/ui/styles.css +59 -0
  32. pgsui/electron/app/ui/ui_shim.js +72 -0
  33. pgsui/electron/bootstrap.py +43 -0
  34. pgsui/electron/launch.py +59 -0
  35. pgsui/electron/package.json +14 -0
  36. pgsui/example_data/popmaps/{test.popmap → phylogen_nomx.popmap} +185 -99
  37. pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz +0 -0
  38. pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz.tbi +0 -0
  39. pgsui/impute/deterministic/imputers/allele_freq.py +691 -0
  40. pgsui/impute/deterministic/imputers/mode.py +679 -0
  41. pgsui/impute/deterministic/imputers/nmf.py +221 -0
  42. pgsui/impute/deterministic/imputers/phylo.py +971 -0
  43. pgsui/impute/deterministic/imputers/ref_allele.py +530 -0
  44. pgsui/impute/supervised/base.py +339 -0
  45. pgsui/impute/supervised/imputers/hist_gradient_boosting.py +293 -0
  46. pgsui/impute/supervised/imputers/random_forest.py +287 -0
  47. pgsui/impute/unsupervised/base.py +924 -0
  48. pgsui/impute/unsupervised/callbacks.py +89 -263
  49. pgsui/impute/unsupervised/imputers/autoencoder.py +972 -0
  50. pgsui/impute/unsupervised/imputers/nlpca.py +1264 -0
  51. pgsui/impute/unsupervised/imputers/ubp.py +1288 -0
  52. pgsui/impute/unsupervised/imputers/vae.py +957 -0
  53. pgsui/impute/unsupervised/loss_functions.py +158 -0
  54. pgsui/impute/unsupervised/models/autoencoder_model.py +208 -558
  55. pgsui/impute/unsupervised/models/nlpca_model.py +149 -468
  56. pgsui/impute/unsupervised/models/ubp_model.py +198 -1317
  57. pgsui/impute/unsupervised/models/vae_model.py +259 -618
  58. pgsui/impute/unsupervised/nn_scorers.py +215 -0
  59. pgsui/utils/classification_viz.py +591 -0
  60. pgsui/utils/misc.py +35 -480
  61. pgsui/utils/plotting.py +514 -824
  62. pgsui/utils/scorers.py +212 -438
  63. pg_sui-1.0.2.1.dist-info/RECORD +0 -75
  64. pg_sui-1.0.2.1.dist-info/top_level.txt +0 -3
  65. pgsui/example_data/phylip_files/test_n10.phy +0 -118
  66. pgsui/example_data/phylip_files/test_n100.phy +0 -118
  67. pgsui/example_data/phylip_files/test_n2.phy +0 -118
  68. pgsui/example_data/phylip_files/test_n500.phy +0 -118
  69. pgsui/example_data/structure_files/test.nopops.1row.10sites.str +0 -117
  70. pgsui/example_data/structure_files/test.nopops.2row.100sites.str +0 -234
  71. pgsui/example_data/structure_files/test.nopops.2row.10sites.str +0 -234
  72. pgsui/example_data/structure_files/test.nopops.2row.30sites.str +0 -234
  73. pgsui/example_data/structure_files/test.nopops.2row.allsites.str +0 -234
  74. pgsui/example_data/structure_files/test.pops.1row.10sites.str +0 -117
  75. pgsui/example_data/structure_files/test.pops.2row.10sites.str +0 -234
  76. pgsui/example_data/trees/test.iqtree +0 -376
  77. pgsui/example_data/trees/test.qmat +0 -5
  78. pgsui/example_data/trees/test.rate +0 -2033
  79. pgsui/example_data/trees/test.tre +0 -1
  80. pgsui/example_data/trees/test_n10.rate +0 -19
  81. pgsui/example_data/trees/test_n100.rate +0 -109
  82. pgsui/example_data/trees/test_n500.rate +0 -509
  83. pgsui/example_data/trees/test_siterates.txt +0 -2024
  84. pgsui/example_data/trees/test_siterates_n10.txt +0 -10
  85. pgsui/example_data/trees/test_siterates_n100.txt +0 -100
  86. pgsui/example_data/trees/test_siterates_n500.txt +0 -500
  87. pgsui/example_data/vcf_files/test.vcf +0 -244
  88. pgsui/example_data/vcf_files/test.vcf.gz +0 -0
  89. pgsui/example_data/vcf_files/test.vcf.gz.tbi +0 -0
  90. pgsui/impute/estimators.py +0 -735
  91. pgsui/impute/impute.py +0 -1486
  92. pgsui/impute/simple_imputers.py +0 -1439
  93. pgsui/impute/supervised/iterative_imputer_fixedparams.py +0 -785
  94. pgsui/impute/supervised/iterative_imputer_gridsearch.py +0 -1027
  95. pgsui/impute/unsupervised/keras_classifiers.py +0 -702
  96. pgsui/impute/unsupervised/models/in_development/cnn_model.py +0 -486
  97. pgsui/impute/unsupervised/neural_network_imputers.py +0 -1424
  98. pgsui/impute/unsupervised/neural_network_methods.py +0 -1549
  99. pgsui/pg_sui.py +0 -261
  100. pgsui/utils/sequence_tools.py +0 -407
  101. simulation/sim_benchmarks.py +0 -333
  102. simulation/sim_treeparams.py +0 -475
  103. test/__init__.py +0 -0
  104. test/pg_sui_simtest.py +0 -215
  105. test/pg_sui_testing.py +0 -523
  106. test/test.py +0 -297
  107. test/test_pgsui.py +0 -374
  108. test/test_tkc.py +0 -214
  109. {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info/licenses}/LICENSE +0 -0
  110. /pgsui/{example_data/trees → electron/app}/__init__.py +0 -0
  111. /pgsui/impute/{unsupervised/models/in_development → supervised/imputers}/__init__.py +0 -0
  112. {simulation → pgsui/impute/unsupervised/imputers}/__init__.py +0 -0
test/test_tkc.py DELETED
@@ -1,214 +0,0 @@
1
- import sys
2
- import os
3
- import copy
4
- import unittest
5
- import pprint
6
- from pgsui.impute.estimators import (
7
- ImputeKNN,
8
- ImputeRandomForest,
9
- ImputeXGBoost,
10
- ImputeVAE,
11
- ImputeStandardAutoEncoder,
12
- ImputeUBP,
13
- ImputeNLPCA,
14
- )
15
- from pgsui.impute.simple_imputers import (
16
- ImputePhylo,
17
- ImputeMF,
18
- ImputeAlleleFreq,
19
- ImputeRefAllele,
20
- )
21
-
22
- from snpio import GenotypeData
23
- from pgsui.data_processing.transformers import SimGenotypeDataTransformer
24
- import numpy as np
25
-
26
-
27
- class HiddenPrints:
28
- def __enter__(self):
29
- self._original_stdout = sys.stdout
30
- sys.stdout = open(os.devnull, "w")
31
-
32
- def __exit__(self, exc_type, exc_val, exc_tb):
33
- sys.stdout.close()
34
- sys.stdout = self._original_stdout
35
-
36
-
37
- class TestMyClasses(unittest.TestCase):
38
- def setUp(self):
39
- with HiddenPrints():
40
- self.genotype_data = GenotypeData(
41
- filename="pgsui/example_data/phylip_files/test_n100.phy",
42
- popmapfile="pgsui/example_data/popmaps/test.popmap",
43
- guidetree="pgsui/example_data/trees/test.tre",
44
- qmatrix="pgsui/example_data/trees/test.qmat",
45
- siterates="pgsui/example_data/trees/test_siterates_n100.txt",
46
- prefix="test_imputer",
47
- force_popmap=True,
48
- plot_format="png",
49
- )
50
-
51
- # Create a SimGenotypeDataTransformer instance and use it
52
- # to simulate missing data
53
- self.transformer = SimGenotypeDataTransformer(
54
- genotype_data=self.genotype_data,
55
- prop_missing=0.2,
56
- strategy="random_weighted",
57
- )
58
- self.transformer.fit(self.genotype_data.genotypes_012(fmt="numpy"))
59
- self.simulated_data = self.genotype_data.copy()
60
-
61
- self.simulated_data.genotypes_012 = self.transformer.transform(
62
- self.genotype_data.genotypes_012(fmt="numpy")
63
- )
64
-
65
- def _test_class(self, class_instance, do_gridsearch=False):
66
- print(f"\nMETHOD: {class_instance.__name__}\n")
67
-
68
- if do_gridsearch:
69
- # Do a simple test.
70
- if class_instance in [ImputeRandomForest, ImputeXGBoost]:
71
- param_grid = {"n_estimators": [50, 100]} # Do a simple test
72
- elif class_instance in [
73
- ImputeVAE,
74
- ImputeStandardAutoEncoder,
75
- ImputeNLPCA,
76
- ImputeUBP,
77
- ]:
78
- param_grid = {"dropout_rate": [0.1, 0.2]}
79
- elif class_instance == ImputeKNN:
80
- param_grid = {"n_neighbors": [5, 8]}
81
- else:
82
- param_grid = None
83
-
84
- kwargs = {
85
- 'sim_strategy': "random_weighted"
86
- }
87
-
88
- instance = class_instance(
89
- self.simulated_data,
90
- gridparams=param_grid,
91
- **kwargs)
92
-
93
- # Write the masks
94
- self.transformer.write_mask(filename_prefix="mask_test")
95
-
96
- imputed_data = instance.imputed.genotypes_012(fmt="numpy")
97
-
98
- # Test that the imputed values are close to the original values
99
- accuracy = self.transformer.accuracy(
100
- self.genotype_data.genotypes_012(fmt="numpy"), imputed_data
101
- )
102
-
103
- (
104
- auc_roc_scores,
105
- precision_scores,
106
- recall_scores,
107
- avg_precision_scores,
108
- ) = self.transformer.auc_roc_pr_ap(
109
- self.genotype_data.genotypes_012(fmt="numpy"), imputed_data
110
- )
111
-
112
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
113
- f"OVERALL ACCURACY: {accuracy}"
114
- )
115
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
116
- f"AUC-ROC PER CLASS: {dict(zip(range(3), auc_roc_scores))}"
117
- )
118
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
119
- f"PRECISION PER CLASS: {dict(zip(range(3), precision_scores))}"
120
- )
121
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
122
- f"RECALL PER CLASS: {dict(zip(range(3), recall_scores))}"
123
- )
124
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
125
- f"AVERAGE PRECISION PER CLASS: {dict(zip(range(3), avg_precision_scores))}"
126
- )
127
-
128
- # Read masks from file
129
- self.transformer.read_mask(filename_prefix="mask_test")
130
-
131
- # Recalculate accuracy after reading in the mask
132
- accuracy_after_read = self.transformer.accuracy(
133
- self.genotype_data.genotypes_012(fmt="numpy"), imputed_data
134
- )
135
-
136
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
137
- f"OVERALL ACCURACY AFTER READ: {accuracy_after_read}"
138
- )
139
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
140
- f"AUC-ROC PER CLASS AFTER READ: {dict(zip(range(3), auc_roc_scores))}"
141
- )
142
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
143
- f"PRECISION PER CLASS AFTER READ: {dict(zip(range(3), precision_scores))}"
144
- )
145
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
146
- f"RECALL PER CLASS AFTER READ: {dict(zip(range(3), recall_scores))}"
147
- )
148
- pprint.PrettyPrinter(indent=4, sort_dicts=True).pprint(
149
- f"AVERAGE PRECISION PER CLASS AFTER READ: {dict(zip(range(3), avg_precision_scores))}"
150
- )
151
-
152
-
153
- print("\n")
154
-
155
- # def test_ImputeKNN(self):
156
- # self._test_class(ImputeKNN)
157
-
158
- # def test_ImputeRandomForest(self):
159
- # self._test_class(ImputeRandomForest)
160
-
161
- # def test_ImputeXGBoost(self):
162
- # self._test_class(ImputeXGBoost)
163
-
164
- def test_ImputeVAE(self):
165
- self._test_class(ImputeVAE)
166
-
167
- # def test_ImputeStandardAutoEncoder(self):
168
- # self._test_class(ImputeStandardAutoEncoder)
169
-
170
- # def test_ImputeUBP(self):
171
- # self._test_class(ImputeUBP)
172
-
173
- # def test_ImputeNLPCA(self):
174
- # self._test_class(ImputeNLPCA)
175
-
176
- # def test_ImputeKNN_grid(self):
177
- # self._test_class(ImputeKNN, do_gridsearch=True)
178
-
179
- # def test_ImputeRandomForest_grid(self):
180
- # self._test_class(ImputeRandomForest, do_gridsearch=True)
181
-
182
- # def test_ImputeXGBoost_grid(self):
183
- # self._test_class(ImputeXGBoost, do_gridsearch=True)
184
-
185
- # def test_ImputeVAE_grid(self):
186
- # self._test_class(ImputeVAE, do_gridsearch=True)
187
-
188
- # def test_ImputeStandardAutoEncoder_grid(self):
189
- # self._test_class(ImputeStandardAutoEncoder, do_gridsearch=True)
190
-
191
- # def test_ImputeUBP_grid(self):
192
- # self._test_class(ImputeUBP, do_gridsearch=True)
193
-
194
- # def test_ImputeNLPCA_grid(self):
195
- # self._test_class(ImputeNLPCA, do_gridsearch=True)
196
-
197
- # def test_ImputePhylo(self):
198
- # self._test_class(ImputePhylo)
199
-
200
- # def test_ImputeAlleleFreq(self):
201
- # self._test_class(ImputeAlleleFreq)
202
-
203
- # def test_ImputeRefAllele(self):
204
- # self._test_class(ImputeRefAllele)
205
-
206
- # def test_ImputeMF(self):
207
- # self._test_class(ImputeMF)
208
-
209
- # def test_ImputeRefAllele(self):
210
- # self._test_class(ImputeRefAllele)
211
-
212
-
213
- if __name__ == "__main__":
214
- unittest.main()
File without changes