示例#1
0
 def association_scan(self):
     print "Association scan... ",
     K = self.kernel_testing(genetics=False, confounders=True)
     pval = testing.interface(self.S_centered, self.Y, K, I = None,
                              model='LMM', parallel=False, # TODO parallelize
                              file_directory = None, jobs = 0)[0]
     print "[DONE]"
     # convert to qvalues
     qval = qvalue.estimate(pval)
     return qval, pval
示例#2
0
    def panama_step(self):
        X = self.get_latent()
        K = self.kernel_testing(genetics=False, confounders=False)
        K = scaleK(K)
        if len(self.candidate_associations) != 0:
            covs = self.S_centered[:, self.candidate_associations].copy()
        else:
            covs = None

        pv = testing.interface(self.S_centered, X[:, :self.Q], K, covs=covs, model = "LMM",
                               parallel = False, jobs = 0,
                               file_directory=None)[0] # TODO cleanup


        # Number of tests conducted
        num_tests = X.shape[1]*self.S.shape[1]*self.iteration
        qv = qvalue.estimate(pv, m=num_tests)

        # Set the qvalue of the current associations to 1
        qv[self.candidate_associations,:] = 1

        # Greedily construct addition set by adding the BEST (lowest qv) SNP for each factor
        # (if significant)
        new_candidates = []

        for i in xrange(qv.shape[1]):
            i_best = qv[:,i].argmin()
            qv_best = qv[:,i].min()
            # if significant, add it
            if qv_best<=self.FDR_associations:
                new_candidates.append(i_best)
                # and set the corrisponding qvalue to 1
                qv[i_best,:] = 1

        # Add candidates
        nc_old = len(self.candidate_associations)
        self.candidate_associations.extend(new_candidates)
        nc = len(self.candidate_associations)
        dl = nc-nc_old

        assert len(np.unique(self.candidate_associations)) == len(self.candidate_associations)

        return dl