Skip to content

Commit 18cef0e

Browse files
committed
Fix versions and packages dependencies
1 parent be0e5e6 commit 18cef0e

File tree

8 files changed

+48
-27
lines changed

8 files changed

+48
-27
lines changed

clarite/internal/calculations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import re
2+
13
import numpy as np
24
from scipy import stats
35
from scipy.optimize import brentq as root
46

5-
import re
6-
77
from clarite.modules.analyze.utils import statsmodels_var_regex
88

99

@@ -30,7 +30,7 @@ def regTermTest(full_model, restricted_model, ddf, X_names, var_name):
3030

3131
def _pFsum(x, df, a, ddf):
3232
tr = a.mean()
33-
tr2 = (a ** 2).mean() / tr ** 2
33+
tr2 = (a**2).mean() / tr**2
3434
scale = tr * tr2
3535
ndf = len(a) / tr2
3636

@@ -63,7 +63,7 @@ def kprime0(z):
6363
return (lam / (1 - 2 * z * lam)).sum()
6464

6565
def kpprime0(z):
66-
return 2 * (lam ** 2 / (1 - 2 * z * lam) ** 2).sum()
66+
return 2 * (lam**2 / (1 - 2 * z * lam) ** 2).sum()
6767

6868
if any(lam < 0):
6969
lam_min = (1 / (2 * lam[lam < 0])).max() * 0.99999

clarite/modules/analyze/regression/glm_regression.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ def __init__(
127127
counts = self.data[self.outcome_variable].value_counts().to_dict()
128128

129129
categories = self.data[self.outcome_variable].cat.categories
130-
categories = sorted(categories, reverse=True) # Sort reverse to keep control as 0 and case as 1
130+
# Sort reverse to keep control as 0 and case as 1
131+
if categories[0] == "Case" and categories[1] == "Control":
132+
categories = sorted(categories, reverse=True)
131133
codes, categories = zip(*enumerate(categories))
132134
self.data[self.outcome_variable].replace(categories, codes, inplace=True)
133135
self.description += (

clarite/modules/analyze/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import re
2-
from typing import Optional, List, Union
2+
from typing import List, Optional, Union
33

44
import numpy as np
55
import pandas as pd
@@ -148,4 +148,4 @@ def statsmodels_var_regex(variable_name) -> str:
148148
1) Categoricals may have the value encoded at the end (for example, Male[T.1.0])
149149
2) Symbols in the variable name must be accounted for: (, ), -, +, etc
150150
"""
151-
return fr"^{re.escape(variable_name)}(\[T\..*\])?$"
151+
return rf"^{re.escape(variable_name)}(\[T\..*\])?$"

pyproject.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "clarite"
3-
version = "2.2.0"
3+
version = "2.2.2"
44
description = "CLeaning to Analysis: Reproducibility-based Interface for Traits and Exposures"
55
authors = ["Hall Lab <mah546@psu.edu>"]
66
license = "BSD-3-Clause"
@@ -16,12 +16,12 @@ classifiers=[
1616
]
1717

1818
[tool.poetry.dependencies]
19-
python = ">=3.7.1,<3.10"
19+
python = ">=3.7.1,<3.8"
2020
click = ">7"
21-
pandas = ">1.1"
22-
scipy = ">1.5"
21+
pandas = "^1.2"
22+
scipy = "^1.6"
2323
seaborn = ">0.9"
24-
statsmodels = ">0.10"
24+
statsmodels = "^0.12"
2525
matplotlib = "^3.4.2"
2626
numpy = "^1.21.0"
2727
rpy2 = "^3.4.5"
@@ -31,9 +31,9 @@ numpydoc = {version = "^1.1.0", optional = true}
3131
sphinx_rtd_theme = {version = "^0.5.0", optional = true}
3232
sphinx-copybutton = {version = "^0.3.0", optional = true}
3333
ipython = {version = "^7.18.1", optional = true}
34-
sphinx-click = {version = "^2.6", optional = true}
34+
sphinx-click = {version = "^4", optional = true}
3535
importlib-metadata = {version = "^2.0", python = "<3.8"}
36-
pandas-genomics = ">=0.10.1"
36+
pandas-genomics = "^0.11"
3737

3838
[tool.poetry.dev-dependencies]
3939
codecov = "^2.1.11"
@@ -42,7 +42,7 @@ flake8 = "^3.9.2"
4242
pytest = ">=4.6"
4343
pytest-cov = "^2.12.1"
4444
pytest-xdist = "^2.3.0"
45-
black = "^21.6b0"
45+
black = ">=22"
4646

4747
[tool.poetry.extras]
4848
docs = ["sphinx", "numpydoc", "sphinx_rtd_theme", "sphinx-copybutton", "ipython", "sphinx-click"]

tests/analyze/test_association_study.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -987,15 +987,34 @@ def test_edge_encondig_logistic_regression():
987987
from pandas_genomics import sim
988988

989989
# Additive Main Effect for SNP1 without interaction
990-
train_add_main_effect45 = sim.BAMS.from_model(eff1=sim.SNPEffectEncodings.ADDITIVE, eff2=sim.SNPEffectEncodings.ADDITIVE,
991-
penetrance_base=0.45, main1=1, main2=0, interaction=0, random_seed=2021)
992-
test_add_main_effect45 = sim.BAMS.from_model(eff1=sim.SNPEffectEncodings.ADDITIVE,
993-
eff2=sim.SNPEffectEncodings.ADDITIVE, penetrance_base=0.45, main1=1, main2=0, interaction=0)
994-
train_add_me_pb045 = train_add_main_effect45.generate_case_control(n_cases=5000, n_controls=5000)
995-
test_add_me_pb045 = test_add_main_effect45.generate_case_control(n_cases=5000, n_controls=5000)
996-
edge_weights_add_me_pb045 = train_add_me_pb045.genomics.calculate_edge_encoding_values(data=train_add_me_pb045["Outcome"], outcome_variable="Outcome")
997-
998-
edge_results_add_me_pb045 = clarite.analyze.association_study(
999-
data=test_add_me_pb045, outcomes="Outcome", encoding="edge", edge_encoding_info=edge_weights_add_me_pb045)
1000-
1001-
assert 2 == 2
990+
train = sim.BAMS.from_model(
991+
eff1=sim.SNPEffectEncodings.ADDITIVE,
992+
eff2=sim.SNPEffectEncodings.ADDITIVE,
993+
penetrance_base=0.45,
994+
main1=1,
995+
main2=0,
996+
interaction=0,
997+
random_seed=2021,
998+
)
999+
test = sim.BAMS.from_model(
1000+
eff1=sim.SNPEffectEncodings.ADDITIVE,
1001+
eff2=sim.SNPEffectEncodings.ADDITIVE,
1002+
penetrance_base=0.45,
1003+
main1=1,
1004+
main2=0,
1005+
interaction=0,
1006+
)
1007+
train_add = train.generate_case_control(n_cases=5000, n_controls=5000)
1008+
test_add = test.generate_case_control(n_cases=5000, n_controls=5000)
1009+
edge_weights = train_add.genomics.calculate_edge_encoding_values(
1010+
data=train_add["Outcome"], outcome_variable="Outcome"
1011+
)
1012+
1013+
edge_results = clarite.analyze.association_study(
1014+
data=test_add,
1015+
outcomes="Outcome",
1016+
encoding="edge",
1017+
edge_encoding_info=edge_weights,
1018+
)
1019+
1020+
assert edge_results["Variable_type"][0] == "continuous"
-12.8 KB
Loading
-13 KB
Loading
-13.4 KB
Loading

0 commit comments

Comments
 (0)