pheval 0.4.5__py3-none-any.whl → 0.4.7__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 pheval might be problematic. Click here for more details.
- pheval/cli.py +1 -1
- pheval/post_processing/post_processing.py +52 -20
- {pheval-0.4.5.dist-info → pheval-0.4.7.dist-info}/METADATA +1 -1
- {pheval-0.4.5.dist-info → pheval-0.4.7.dist-info}/RECORD +7 -7
- {pheval-0.4.5.dist-info → pheval-0.4.7.dist-info}/WHEEL +1 -1
- {pheval-0.4.5.dist-info → pheval-0.4.7.dist-info}/LICENSE +0 -0
- {pheval-0.4.5.dist-info → pheval-0.4.7.dist-info}/entry_points.txt +0 -0
pheval/cli.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import operator
|
|
3
|
-
from dataclasses import dataclass
|
|
3
|
+
from dataclasses import dataclass, field
|
|
4
4
|
from enum import Enum
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import List, Union
|
|
@@ -96,6 +96,7 @@ class PhEvalVariantResult(PhEvalResult):
|
|
|
96
96
|
ref: str
|
|
97
97
|
alt: str
|
|
98
98
|
score: float
|
|
99
|
+
grouping_id: str = field(default=None)
|
|
99
100
|
|
|
100
101
|
|
|
101
102
|
@dataclass
|
|
@@ -105,7 +106,7 @@ class RankedPhEvalVariantResult(PhEvalVariantResult):
|
|
|
105
106
|
rank (int): The rank for the result entry
|
|
106
107
|
"""
|
|
107
108
|
|
|
108
|
-
rank: int
|
|
109
|
+
rank: int = 0
|
|
109
110
|
|
|
110
111
|
@staticmethod
|
|
111
112
|
def from_variant_result(pheval_variant_result: PhEvalVariantResult, rank: int):
|
|
@@ -228,26 +229,57 @@ class ResultSorter:
|
|
|
228
229
|
)
|
|
229
230
|
|
|
230
231
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
class ResultRanker:
|
|
233
|
+
def __init__(self, pheval_result: List[PhEvalResult], sort_order: SortOrder):
|
|
234
|
+
"""
|
|
235
|
+
Initialise the PhEvalRanker.
|
|
236
|
+
Args:
|
|
237
|
+
pheval_result (List[PhEvalResult]): PhEval results to rank.
|
|
238
|
+
sort_order (SortOrder): Sorting order based on which ranking is performed.
|
|
239
|
+
"""
|
|
240
|
+
self.pheval_result = pheval_result
|
|
241
|
+
self.sort_order = sort_order
|
|
242
|
+
self.ascending = sort_order == SortOrder.ASCENDING
|
|
234
243
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
244
|
+
def rank(self) -> pd.DataFrame:
|
|
245
|
+
"""
|
|
246
|
+
Rank PhEval results, managing tied scores (ex aequo) and handling grouping_id if present.
|
|
238
247
|
|
|
239
|
-
|
|
240
|
-
|
|
248
|
+
Returns:
|
|
249
|
+
pd.DataFrame : Ranked PhEval results with tied scores managed.
|
|
250
|
+
"""
|
|
251
|
+
pheval_result_df = pd.DataFrame([data.__dict__ for data in self.pheval_result])
|
|
241
252
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
253
|
+
if self._has_valid_grouping_id(pheval_result_df):
|
|
254
|
+
pheval_result_df = self._rank_with_grouping_id(pheval_result_df)
|
|
255
|
+
else:
|
|
256
|
+
pheval_result_df = self._rank_without_grouping_id(pheval_result_df)
|
|
257
|
+
return pheval_result_df.drop(columns=["min_rank", "grouping_id"], errors="ignore")
|
|
258
|
+
|
|
259
|
+
@staticmethod
|
|
260
|
+
def _has_valid_grouping_id(pheval_result_df: pd.DataFrame) -> bool:
|
|
261
|
+
"""Check if grouping_id exists and has no None values."""
|
|
262
|
+
return (
|
|
263
|
+
"grouping_id" in pheval_result_df.columns
|
|
264
|
+
and not pheval_result_df["grouping_id"].isnull().any()
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
def _rank_with_grouping_id(self, pheval_result_df: pd.DataFrame) -> pd.DataFrame:
|
|
268
|
+
"""Apply ranking when grouping_id is present and has no None values."""
|
|
269
|
+
pheval_result_df["min_rank"] = (
|
|
270
|
+
pheval_result_df.groupby(["score", "grouping_id"])
|
|
271
|
+
.ngroup()
|
|
272
|
+
.rank(method="dense", ascending=self.ascending)
|
|
273
|
+
).astype(int)
|
|
274
|
+
pheval_result_df["rank"] = pheval_result_df.groupby("score")["min_rank"].transform("max")
|
|
275
|
+
return pheval_result_df
|
|
276
|
+
|
|
277
|
+
def _rank_without_grouping_id(self, pheval_result_df: pd.DataFrame) -> pd.DataFrame:
|
|
278
|
+
"""Apply ranking without using grouping_id."""
|
|
279
|
+
pheval_result_df["rank"] = (
|
|
280
|
+
pheval_result_df["score"].rank(method="max", ascending=self.ascending).astype(int)
|
|
281
|
+
)
|
|
282
|
+
return pheval_result_df
|
|
251
283
|
|
|
252
284
|
|
|
253
285
|
def _return_sort_order(sort_order_str: str) -> SortOrder:
|
|
@@ -282,7 +314,7 @@ def _create_pheval_result(pheval_result: [PhEvalResult], sort_order_str: str) ->
|
|
|
282
314
|
"""
|
|
283
315
|
sort_order = _return_sort_order(sort_order_str)
|
|
284
316
|
sorted_pheval_result = ResultSorter(pheval_result, sort_order).sort_pheval_results()
|
|
285
|
-
return
|
|
317
|
+
return ResultRanker(sorted_pheval_result, sort_order).rank()
|
|
286
318
|
|
|
287
319
|
|
|
288
320
|
def _write_pheval_gene_result(
|
|
@@ -16,7 +16,7 @@ pheval/analyse/prioritisation_result_types.py,sha256=qJoB6O-lFYmzAMcTQeDJZQNLJ6h
|
|
|
16
16
|
pheval/analyse/rank_stats.py,sha256=vNLVuG_NzhKDXxKmklYNPz44MczlyKUqcuHqbiuOXwI,17993
|
|
17
17
|
pheval/analyse/run_data_parser.py,sha256=VQBUoOIRYRWc5uqURUvaWdaW3E3C7Su0JvLavQLHQaY,4105
|
|
18
18
|
pheval/analyse/variant_prioritisation_analysis.py,sha256=HhDeczF7wmJjXt0ejAtF0qdczyMe25glqiS6uX_TFl8,6408
|
|
19
|
-
pheval/cli.py,sha256=
|
|
19
|
+
pheval/cli.py,sha256=SPB8-BCIRt1fUaAalhZ5Y6JUlnJX6Cj2S52QXCovJR8,1526
|
|
20
20
|
pheval/cli_pheval.py,sha256=fWbKUcPTZZSa1EJEtH_lNn1XE6qRApRHihqUZS5owrA,2424
|
|
21
21
|
pheval/cli_pheval_utils.py,sha256=O6tWnE85QQHGNcP08OwJGANMfXJPsZtFEu-D6ATld00,16700
|
|
22
22
|
pheval/config_parser.py,sha256=lh-Dy_FflXJUnRC3HYaEdSvPAsNZWQZlEr1hHQigrTM,1227
|
|
@@ -24,7 +24,7 @@ pheval/implementations/__init__.py,sha256=BMUTotjTdgy5j5xubWCIQgRXrSQ1ZIcjooer7r
|
|
|
24
24
|
pheval/infra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
pheval/infra/exomiserdb.py,sha256=pM9-TfjrgurtH4OtM1Enk5oVhIxGQN3rKRlrxHuObTM,5080
|
|
26
26
|
pheval/post_processing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
pheval/post_processing/post_processing.py,sha256=
|
|
27
|
+
pheval/post_processing/post_processing.py,sha256=MdacHoVjmwvmWBnHCSSKBboCgMW4MRGP-d_7-t1zZew,14808
|
|
28
28
|
pheval/prepare/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
29
|
pheval/prepare/create_noisy_phenopackets.py,sha256=ydhA4mpqKTDc4hBu8YfvNW2nMubHK3dbO-cv0lA4JFQ,11504
|
|
30
30
|
pheval/prepare/create_spiked_vcf.py,sha256=90A-Mi8QKhvN036vtFEVWAHgzHO37itiLYrqYlG4LiA,23953
|
|
@@ -50,8 +50,8 @@ pheval/utils/file_utils.py,sha256=m21cz-qjDYqnI8ClUv3J9fKizex98a-9bSEerQ75i_c,35
|
|
|
50
50
|
pheval/utils/phenopacket_utils.py,sha256=6xQ8WCLdR1VhiU3nCDzaqEVKjGvDWrzvPA50_6ZAHXM,27310
|
|
51
51
|
pheval/utils/semsim_utils.py,sha256=s7ZCR2VfPYnOh7ApX6rv66eGoVSm9QJaVYOWBEhlXpo,6151
|
|
52
52
|
pheval/utils/utils.py,sha256=9V6vCT8l1g4O2-ZATYqsVyd7AYZdWGd-Ksy7_oIC3eE,2343
|
|
53
|
-
pheval-0.4.
|
|
54
|
-
pheval-0.4.
|
|
55
|
-
pheval-0.4.
|
|
56
|
-
pheval-0.4.
|
|
57
|
-
pheval-0.4.
|
|
53
|
+
pheval-0.4.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
54
|
+
pheval-0.4.7.dist-info/METADATA,sha256=JfraeowwRp8eQjKiFBBrIVUoA0fchchznGj4t8sXgFE,6469
|
|
55
|
+
pheval-0.4.7.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
56
|
+
pheval-0.4.7.dist-info/entry_points.txt,sha256=o9gSwDkvT4-lqKy4mlsftd1nzP9WUOXQCfnbqycURd0,81
|
|
57
|
+
pheval-0.4.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|