Exemple #1
0
    def _initGP(self,colCovarType,rank_r,rank_g,rank_n):
        """
        Initializes genetic and noise LIMIX trait covar
        Args:
            colCovarType_g:     genetic trait covariance type
            colCovarType_n:     noise trait covariance type
            rank_r:     rank of region trait covar
            rank_g:     rank of genetic trait covar
            rank_n:     rank of noise trait covar
        """
        if self.P==1:
            self.rank_r = 1
            self.rank_g = 1
            self.rank_n = 1
            # ideally should be diag
            colCovarType = 'freeform'
        elif colCovarType is None:
            colCovarType='freeform'

        self.rank_r = rank_r
        self.rank_g = rank_g
        self.rank_n = rank_n
        self.colCovarType = colCovarType
        self.Cg = self._buildTraitCovar(colCovarType,rank_g)
        self.Cn = self._buildTraitCovar(colCovarType,rank_n)
        XXnotNone = self.XX is not None
        SUnotNone = self.S_XX is not None and self.U_XX is not None
        # build mean
        if self.bgRE:
            self.gp = gp3kronSum(self.mean,self.Cg,self.Cn,XX=self.XX,S_XX=self.S_XX,U_XX=self.U_XX,rank=self.rank_r)
        else:
            self.gp = gp2kronSumLR(self.Y,self.Cn,F=self.F,rank=self.rank_r)
    def _initGP(self, colCovarType, rank_r, rank_g, rank_n):
        """
        Initializes genetic and noise LIMIX trait covar
        Args:
            colCovarType_g:     genetic trait covariance type
            colCovarType_n:     noise trait covariance type
            rank_r:     rank of region trait covar
            rank_g:     rank of genetic trait covar
            rank_n:     rank of noise trait covar
        """
        if self.P == 1:
            self.rank_r = 1
            self.rank_g = 1
            self.rank_n = 1
            # ideally should be diag
            colCovarType = 'freeform'
        elif colCovarType is None:
            colCovarType = 'freeform'

        self.rank_r = rank_r
        self.rank_g = rank_g
        self.rank_n = rank_n
        self.colCovarType = colCovarType
        self.Cg = self._buildTraitCovar(colCovarType, rank_g)
        self.Cn = self._buildTraitCovar(colCovarType, rank_n)
        XXnotNone = self.XX is not None
        SUnotNone = self.S_XX is not None and self.U_XX is not None
        # build mean
        if self.bgRE:
            self.gp = gp3kronSum(self.mean,
                                 self.Cg,
                                 self.Cn,
                                 XX=self.XX,
                                 S_XX=self.S_XX,
                                 U_XX=self.U_XX,
                                 rank=self.rank_r)
        else:
            self.gp = gp2kronSumLR(self.Y, self.Cn, F=self.F, rank=self.rank_r)
Exemple #3
0
        gp.setParams(params)
        gp.checkGradient()
        print "test optimization"
        conv,info = OPT.opt_hyper(gp,params,factr=1e3)
        print conv
        ipdb.set_trace()

    if 1:
        # generate parameters
        params = {}
        params['Cr']   = SP.randn(P)
        params['Cg']   = SP.randn(int(0.5*P*(P+1)))
        params['Cn']   = SP.randn(int(0.5*P*(P+1)))
        params['mean'] = 1e-2*SP.randn(mean.getParams().shape[0])
        print "check gradient with gp3kronSum"
        gp = gp3kronSum(mean,Cg,Cn,XX,Xr=Xr)
        gp.setParams(params)
        gp.LMLgrad()
        gp.checkGradient()
        print "test optimization"
        conv,info = OPT.opt_hyper(gp,params,factr=1e3)
        ipdb.set_trace()
        m,cov,M,S = gp.getPosteriorSnpWeights(matrix=True)
        print conv
        ipdb.set_trace()

    if 1:
        # generate parameters
        params = {}
        params['Cr']   = SP.randn(P)
        params['Cn']   = SP.randn(int(0.5*P*(P+1)))