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.
- {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/METADATA +51 -70
- pg_sui-1.6.8.dist-info/RECORD +78 -0
- {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info}/WHEEL +1 -1
- pg_sui-1.6.8.dist-info/entry_points.txt +4 -0
- pg_sui-1.6.8.dist-info/top_level.txt +1 -0
- pgsui/__init__.py +35 -54
- pgsui/_version.py +34 -0
- pgsui/cli.py +635 -0
- pgsui/data_processing/config.py +576 -0
- pgsui/data_processing/containers.py +1782 -0
- pgsui/data_processing/transformers.py +121 -1103
- pgsui/electron/app/__main__.py +5 -0
- pgsui/electron/app/icons/icons/1024x1024.png +0 -0
- pgsui/electron/app/icons/icons/128x128.png +0 -0
- pgsui/electron/app/icons/icons/16x16.png +0 -0
- pgsui/electron/app/icons/icons/24x24.png +0 -0
- pgsui/electron/app/icons/icons/256x256.png +0 -0
- pgsui/electron/app/icons/icons/32x32.png +0 -0
- pgsui/electron/app/icons/icons/48x48.png +0 -0
- pgsui/electron/app/icons/icons/512x512.png +0 -0
- pgsui/electron/app/icons/icons/64x64.png +0 -0
- pgsui/electron/app/icons/icons/icon.icns +0 -0
- pgsui/electron/app/icons/icons/icon.ico +0 -0
- pgsui/electron/app/main.js +189 -0
- pgsui/electron/app/package-lock.json +6893 -0
- pgsui/electron/app/package.json +50 -0
- pgsui/electron/app/preload.js +15 -0
- pgsui/electron/app/server.py +146 -0
- pgsui/electron/app/ui/logo.png +0 -0
- pgsui/electron/app/ui/renderer.js +130 -0
- pgsui/electron/app/ui/styles.css +59 -0
- pgsui/electron/app/ui/ui_shim.js +72 -0
- pgsui/electron/bootstrap.py +43 -0
- pgsui/electron/launch.py +59 -0
- pgsui/electron/package.json +14 -0
- pgsui/example_data/popmaps/{test.popmap → phylogen_nomx.popmap} +185 -99
- pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz +0 -0
- pgsui/example_data/vcf_files/phylogen_subset14K.vcf.gz.tbi +0 -0
- pgsui/impute/deterministic/imputers/allele_freq.py +691 -0
- pgsui/impute/deterministic/imputers/mode.py +679 -0
- pgsui/impute/deterministic/imputers/nmf.py +221 -0
- pgsui/impute/deterministic/imputers/phylo.py +971 -0
- pgsui/impute/deterministic/imputers/ref_allele.py +530 -0
- pgsui/impute/supervised/base.py +339 -0
- pgsui/impute/supervised/imputers/hist_gradient_boosting.py +293 -0
- pgsui/impute/supervised/imputers/random_forest.py +287 -0
- pgsui/impute/unsupervised/base.py +924 -0
- pgsui/impute/unsupervised/callbacks.py +89 -263
- pgsui/impute/unsupervised/imputers/autoencoder.py +972 -0
- pgsui/impute/unsupervised/imputers/nlpca.py +1264 -0
- pgsui/impute/unsupervised/imputers/ubp.py +1288 -0
- pgsui/impute/unsupervised/imputers/vae.py +957 -0
- pgsui/impute/unsupervised/loss_functions.py +158 -0
- pgsui/impute/unsupervised/models/autoencoder_model.py +208 -558
- pgsui/impute/unsupervised/models/nlpca_model.py +149 -468
- pgsui/impute/unsupervised/models/ubp_model.py +198 -1317
- pgsui/impute/unsupervised/models/vae_model.py +259 -618
- pgsui/impute/unsupervised/nn_scorers.py +215 -0
- pgsui/utils/classification_viz.py +591 -0
- pgsui/utils/misc.py +35 -480
- pgsui/utils/plotting.py +514 -824
- pgsui/utils/scorers.py +212 -438
- pg_sui-1.0.2.1.dist-info/RECORD +0 -75
- pg_sui-1.0.2.1.dist-info/top_level.txt +0 -3
- pgsui/example_data/phylip_files/test_n10.phy +0 -118
- pgsui/example_data/phylip_files/test_n100.phy +0 -118
- pgsui/example_data/phylip_files/test_n2.phy +0 -118
- pgsui/example_data/phylip_files/test_n500.phy +0 -118
- pgsui/example_data/structure_files/test.nopops.1row.10sites.str +0 -117
- pgsui/example_data/structure_files/test.nopops.2row.100sites.str +0 -234
- pgsui/example_data/structure_files/test.nopops.2row.10sites.str +0 -234
- pgsui/example_data/structure_files/test.nopops.2row.30sites.str +0 -234
- pgsui/example_data/structure_files/test.nopops.2row.allsites.str +0 -234
- pgsui/example_data/structure_files/test.pops.1row.10sites.str +0 -117
- pgsui/example_data/structure_files/test.pops.2row.10sites.str +0 -234
- pgsui/example_data/trees/test.iqtree +0 -376
- pgsui/example_data/trees/test.qmat +0 -5
- pgsui/example_data/trees/test.rate +0 -2033
- pgsui/example_data/trees/test.tre +0 -1
- pgsui/example_data/trees/test_n10.rate +0 -19
- pgsui/example_data/trees/test_n100.rate +0 -109
- pgsui/example_data/trees/test_n500.rate +0 -509
- pgsui/example_data/trees/test_siterates.txt +0 -2024
- pgsui/example_data/trees/test_siterates_n10.txt +0 -10
- pgsui/example_data/trees/test_siterates_n100.txt +0 -100
- pgsui/example_data/trees/test_siterates_n500.txt +0 -500
- pgsui/example_data/vcf_files/test.vcf +0 -244
- pgsui/example_data/vcf_files/test.vcf.gz +0 -0
- pgsui/example_data/vcf_files/test.vcf.gz.tbi +0 -0
- pgsui/impute/estimators.py +0 -735
- pgsui/impute/impute.py +0 -1486
- pgsui/impute/simple_imputers.py +0 -1439
- pgsui/impute/supervised/iterative_imputer_fixedparams.py +0 -785
- pgsui/impute/supervised/iterative_imputer_gridsearch.py +0 -1027
- pgsui/impute/unsupervised/keras_classifiers.py +0 -702
- pgsui/impute/unsupervised/models/in_development/cnn_model.py +0 -486
- pgsui/impute/unsupervised/neural_network_imputers.py +0 -1424
- pgsui/impute/unsupervised/neural_network_methods.py +0 -1549
- pgsui/pg_sui.py +0 -261
- pgsui/utils/sequence_tools.py +0 -407
- simulation/sim_benchmarks.py +0 -333
- simulation/sim_treeparams.py +0 -475
- test/__init__.py +0 -0
- test/pg_sui_simtest.py +0 -215
- test/pg_sui_testing.py +0 -523
- test/test.py +0 -297
- test/test_pgsui.py +0 -374
- test/test_tkc.py +0 -214
- {pg_sui-1.0.2.1.dist-info → pg_sui-1.6.8.dist-info/licenses}/LICENSE +0 -0
- /pgsui/{example_data/trees → electron/app}/__init__.py +0 -0
- /pgsui/impute/{unsupervised/models/in_development → supervised/imputers}/__init__.py +0 -0
- {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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|