From bfc099c45ac1ea50580f3bc70f4ced352251b45e Mon Sep 17 00:00:00 2001 From: Alexander Young Date: Thu, 2 Nov 2023 16:31:34 -0700 Subject: [PATCH] Update pgs.py fix grandparental pgs colnames --- snipar/pgs.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snipar/pgs.py b/snipar/pgs.py index 11b985a3..39beec60 100644 --- a/snipar/pgs.py +++ b/snipar/pgs.py @@ -504,7 +504,7 @@ def compute_grandpar(self, r): gpar[i_index, 2:4] = parent_means[1]+(1+r)*(self.gts[i_index, maternal_index]-parent_means[1])/2.0 ## Append to PGS matrix self.gts = np.hstack((self.gts,gpar)) - self.sid = np.hstack((self.sid,np.array(['gpp','gpm','gmp','gmm']))) + self.sid = np.hstack((self.sid,np.array(['gpp','gmp','gpm','gmm']))) return bpg_ped def opg_am_adj(pgi_imp, pgi_obs, r, n): @@ -644,9 +644,9 @@ def fit_pgs_model(y, pg, ngen, ibdrel_path=None, covariates=None, fit_sib=False, elif ngen==3: print('Fitting 3 generation model: observed proband and observed parents, and observed/imputed grandparents') if gparsum: - if 'gpp' in pg.sid and 'gpm' in pg.sid and 'gmp' in pg.sid and 'gmm' in pg.sid: + if 'gpp' in pg.sid and 'gmp' in pg.sid and 'gpm' in pg.sid and 'gmm' in pg.sid: # Sum of paternal grandparents - gparcols = np.sort(np.array([np.where(pg.sid==x)[0][0] for x in ['gpp','gpm']])) + gparcols = np.sort(np.array([np.where(pg.sid==x)[0][0] for x in ['gpp','gmp']])) trans_matrix = np.identity(pg.gts.shape[1]) trans_matrix[:,gparcols[0]] += trans_matrix[:,gparcols[1]] trans_matrix = np.delete(trans_matrix,gparcols[1],1) @@ -654,7 +654,7 @@ def fit_pgs_model(y, pg, ngen, ibdrel_path=None, covariates=None, fit_sib=False, pg.sid = np.delete(pg.sid,gparcols[1]) pg.sid[gparcols[0]] = 'gp' # Sum of maternal grandparents - gparcols = np.sort(np.array([np.where(pg.sid==x)[0][0] for x in ['gmp','gmm']])) + gparcols = np.sort(np.array([np.where(pg.sid==x)[0][0] for x in ['gpm','gmm']])) trans_matrix = np.identity(pg.gts.shape[1]) trans_matrix[:,gparcols[0]] += trans_matrix[:,gparcols[1]] trans_matrix = np.delete(trans_matrix,gparcols[1],1) @@ -832,4 +832,4 @@ def am_adj_2gen(estimates, estimate_cols, h2f, h2f_se, rk=None, rk_se=None, pg=N estimate[1,0], np.sqrt(estimate_cov[0,0]), estimate_cov[0,1]/np.sqrt(estimate_cov[0,0]*estimate_cov[1,1]), h2f, h2f_se, rk, rk_se, verbose=True) - return adj_estimates, adj_ses \ No newline at end of file + return adj_estimates, adj_ses