Skip to content

Commit

Permalink
Merge pull request #43 from Bonder-MJ/develop
Browse files Browse the repository at this point in the history
Interaction update to allow permutation for genotypes. S1
  • Loading branch information
horta committed Jul 11, 2018
2 parents f794777 + 3f9c357 commit f344935
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions limix/qtl/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .util import print_analysis


def iscan(G, y, lik, inter, K=None, M=None, verbose=True):
def iscan(G, y, lik, inter, Ginter=None, K=None, M=None, verbose=True):
r"""Interaction single-variant association testing via mixed models.
It supports Normal (linear mixed model), Bernoulli, Binomial, and Poisson
Expand All @@ -35,6 +35,9 @@ def iscan(G, y, lik, inter, K=None, M=None, verbose=True):
Sample likelihood describing the residual distribution.
inter : array_like
`n` individuals by `i` interaction factors.
Ginter : array_like
`n` individuals by `s` candidate markers. used for interaction.
Defaults to ``None``, in which case G is used.
K : array_like, optional
`n` by `n` covariance matrix (e.g., kinship coefficients).
Set to ``None`` for a generalised linear model without random effects.
Expand Down Expand Up @@ -103,7 +106,10 @@ def iscan(G, y, lik, inter, K=None, M=None, verbose=True):
SNP09 0.64945 0.67185 0.76600
"""
lik = lik.lower()


if Ginter is None:
Ginter = G

if verbose:
print_analysis(lik, "Interaction QTL analysis")

Expand All @@ -126,7 +132,7 @@ def iscan(G, y, lik, inter, K=None, M=None, verbose=True):
y = _binomial_y(y.values, 'normal')

if lik == 'normal':
model = _perform_lmm(y, M, QS, G, inter, mixed, verbose)
model = _perform_lmm(y, M, QS, G, inter, Ginter, mixed, verbose)
else:
raise NotImplementedError

Expand All @@ -136,7 +142,7 @@ def iscan(G, y, lik, inter, K=None, M=None, verbose=True):
return model


def _perform_lmm(y, M, QS, G, inter, mixed, verbose):
def _perform_lmm(y, M, QS, G, inter, Ginter, mixed, verbose):
from pandas import DataFrame, Series

alt_lmls = dict()
Expand All @@ -145,8 +151,8 @@ def _perform_lmm(y, M, QS, G, inter, mixed, verbose):
null_lmls = []
interv = inter.values

for c in tqdm(G.columns, disable=not verbose):
g = G[c].values[:, newaxis]
for c in tqdm(Ginter.columns, disable=not verbose):
g = Ginter[c].values[:, newaxis]
X1 = g * interv

covariates = concatenate((M.values, g), axis=1)
Expand Down

0 comments on commit f344935

Please sign in to comment.