Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/python/black
rev: 21.10b0
rev: 22.3.0
hooks:
- id: black
language_version: python3
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ partd
bed-reader
rechunker == 0.3.3
cbgen
cyvcf2; platform_system != "Windows"
cyvcf2 < 0.30.15; platform_system != "Windows"
yarl
matplotlib
asv
Expand Down
3 changes: 0 additions & 3 deletions requirements-doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ myst_nb
pydata-sphinx-theme
sphinx>4,<=4.2.0
sphinx_autodoc_typehints>=1.14.0
# Work around problem with autodoc_typehints
# https://github.com/theislab/scanpydoc/pull/32
git+https://github.com/theislab/scanpydoc.git#egg=scanpydoc
sphinx-book-theme
scanpydoc
ipython
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ plink =
bed-reader
vcf =
aiohttp
cyvcf2
cyvcf2 < 0.30.15
requests
yarl
bgen =
Expand Down
2 changes: 1 addition & 1 deletion sgkit/stats/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def individual_heterozygosity(
# use nan denominator to avoid divide by zero with K - 1
K2 = da.where(K > 1, K, np.nan)
AF = AC / K2[..., None]
HI = (1 - da.sum(AF ** 2, axis=-1)) * (K / (K2 - 1))
HI = (1 - da.sum(AF**2, axis=-1)) * (K / (K2 - 1))
new_ds = create_dataset(
{variables.call_heterozygosity: (("variants", "samples"), HI)}
)
Expand Down
6 changes: 3 additions & 3 deletions sgkit/stats/association.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ def linear_regression(
# from projection require no extra terms in variance
# estimate for loop covariates (columns of G), which is
# only true when an intercept is present.
XLPS = (XLP ** 2).sum(axis=0, keepdims=True).T
XLPS = (XLP**2).sum(axis=0, keepdims=True).T
assert XLPS.shape == (n_loop_covar, 1)
B = (XLP.T @ YP) / XLPS
assert B.shape == (n_loop_covar, n_outcome)

# Compute residuals for each loop covariate and outcome separately
YR = YP[:, np.newaxis, :] - XLP[..., np.newaxis] * B[np.newaxis, ...]
assert YR.shape == (n_obs, n_loop_covar, n_outcome)
RSS = (YR ** 2).sum(axis=0)
RSS = (YR**2).sum(axis=0)
assert RSS.shape == (n_loop_covar, n_outcome)
# Get t-statistics for coefficient estimates
T = B / np.sqrt(RSS / dof / XLPS)
Expand Down Expand Up @@ -382,7 +382,7 @@ def regenie_loco_regression(
Y -= Y.mean(axis=0)
# Orthogonally project covariates out of phenotype matrix
Y -= Q @ (Q.T @ Y)
Y_scale = da.sqrt(da.sum(Y ** 2, axis=0) / (Y.shape[0] - Q.shape[1]))
Y_scale = da.sqrt(da.sum(Y**2, axis=0) / (Y.shape[0] - Q.shape[1]))
# Scale
Y /= Y_scale[None, :]

Expand Down
4 changes: 2 additions & 2 deletions sgkit/stats/ld.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def rogers_huff_r_between(gn0: ArrayLike, gn1: ArrayLike) -> float: # pragma: n
n += 1
m0 += x
m1 += y
v0 += x ** 2
v1 += y ** 2
v0 += x**2
v1 += y**2
cov += x * y

# early out
Expand Down
8 changes: 4 additions & 4 deletions sgkit/stats/popgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,11 @@ def Tajimas_D(
# calculate the denominator (standard deviation)
a2 = (1 / (da.arange(1, n) ** 2)).sum()
b1 = (n + 1) / (3 * (n - 1))
b2 = 2 * (n ** 2 + n + 3) / (9 * n * (n - 1))
b2 = 2 * (n**2 + n + 3) / (9 * n * (n - 1))
c1 = b1 - (1 / a1)
c2 = b2 - ((n + 2) / (a1 * n)) + (a2 / (a1 ** 2))
c2 = b2 - ((n + 2) / (a1 * n)) + (a2 / (a1**2))
e1 = c1 / a1
e2 = c2 / (a1 ** 2 + a2)
e2 = c2 / (a1**2 + a2)
d_stdev = da.sqrt((e1 * S) + (e2 * S * (S - 1)))

# Let IEEE decide the semantics of division by zero here. The return value
Expand Down Expand Up @@ -770,7 +770,7 @@ def _Garud_h(haplotypes: ArrayLike) -> ArrayLike:
f = counts / n # type: ignore[operator]

# compute H1
h1 = np.sum(f ** 2)
h1 = np.sum(f**2)

# compute H12
h12 = np.sum(f[:2]) ** 2 + np.sum(f[2:] ** 2) # type: ignore[index]
Expand Down