Skip to content

Commit

Permalink
feat: New primary error type for zero p-values (EBISPOT#42)
Browse files Browse the repository at this point in the history
* feat: New primary error type for zero p-values

* docs: Update how to run tests
  • Loading branch information
karatugo authored Jun 28, 2024
1 parent 7821643 commit 9deb9e3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ To run the tests:
1. [install poetry](https://python-poetry.org/docs/#installation)
2. `git clone https://github.com/EBISPOT/gwas-sumstats-tools.git`
3. `cd gwas-sumstats-tools`
3. `python3 -m venv env`
3. `pip install poetry`
4. `poetry install`
5. `poetry run pytest`
5. `poetry run pytest -s`

To make a change:
branch from master -> PR to master -> poetry version -> git add pyproject.toml -> git commit -> git tag <version> -> git push origin master --tags
Expand Down
1 change: 1 addition & 0 deletions gwas_sumstats_tools/schema/data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class SumStatsSchema:
])
}
PVALUE_FIELD_DEFINITIONS = {
# 'p_value': Column(float, [
'p_value': Column(float if platform.system() == "Windows" else Float128, [
Check.in_range(0, 1,
include_min=True,
Expand Down
2 changes: 2 additions & 0 deletions gwas_sumstats_tools/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def _evaluate_errors(self) -> None:
self.primary_error_type = 'headers'
elif 'Column' in self.errors_table['schema_context']:
self.primary_error_type = 'data'
if '_p_value_mantissa' in self.errors_table['column']:
self.primary_error_type = 'p_val'


def validate(filename: Path,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ def test_zero_pvalue(self, sumstats_file):
sumstats_file.to_file()
v = Validator(sumstats_file=sumstats_file.filepath, minimum_rows=4)
assert v.validate()[0] is False
assert v.primary_error_type == "data"
# print(v.errors_table)
assert v.primary_error_type == "p_val"
assert v.errors_table.nrows() == 4
v = Validator(sumstats_file=sumstats_file.filepath, minimum_rows=4,
pval_zero=True)
Expand Down Expand Up @@ -293,7 +294,7 @@ def test_invalid_pvalue(self, sumstats_file):
sumstats_file.to_file()
v = Validator(sumstats_file=sumstats_file.filepath, minimum_rows=4)
assert v.validate()[0] is False
assert v.primary_error_type == "data"
assert v.primary_error_type == "p_val"
print(v.errors_table.look(limit=10))
assert v.errors_table.nrows() == 6

Expand Down

0 comments on commit 9deb9e3

Please sign in to comment.