From da0c03c2e0e276cc86e4e03f461d513006b18211 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Mon, 13 Jul 2020 12:20:43 +0100 Subject: [PATCH] trying to resolve copy warning in code --- scripts/or_kinship_link.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/or_kinship_link.py b/scripts/or_kinship_link.py index 2ddac12..5d4bc6b 100755 --- a/scripts/or_kinship_link.py +++ b/scripts/or_kinship_link.py @@ -34,8 +34,8 @@ arg_parser.add_argument('-i', '--input_dir', help = 'Input dir containing pdb fi arg_parser.add_argument('-o', '--output_dir', help = 'Output dir for results. By default, it assmes homedir + + output') # FIXME: remove defaults -arg_parser.add_argument('-s', '--start_coord', help = 'start of coding region (cds) of gene', default = 2288681) # pnca cds -arg_parser.add_argument('-e', '--end_coord', help = 'end of coding region (cds) of gene', default = 2289241) # pnca cds +arg_parser.add_argument('-sc', '--start_coord', help = 'start of coding region (cds) of gene', default = None, type = int) # pnca cds +arg_parser.add_argument('-ec', '--end_coord', help = 'end of coding region (cds) of gene', default = None, type = int) # pnca cds arg_parser.add_argument('--debug', action ='store_true', help = 'Debug Mode') @@ -314,18 +314,21 @@ print('No. of cols pre-formatting data:', df_ncols #1) Add column: OR for kinship calculated from beta coef ncols_add = 0 if not 'or_kin' in dfm2_mis.columns: - dfm2_mis['or_kin'] = np.exp(dfm2_mis['beta']) + #dfm2_mis['or_kin'] = np.exp(dfm2_mis['beta']) # gives copy warning + dfm2_mis.loc[:,'or_kin'] = np.exp(dfm2_mis.loc[:,'beta']) + print(dfm2_mis['or_kin'].head()) ncols_add+=1 print('Calculating OR from beta coeff by exponent function and adding column:' - , '\nNo. of cols added:', ncols_add, '\n' - , dfm2_mis['beta'].head() + , '\nNo. of cols added:', ncols_add + , '\n', dfm2_mis['beta'].head() + , '\nNo. of cols after adding OR_kin:', len(dfm2_mis.columns) , '\n===================================================================') if dfm2_mis.shape[1] == df_ncols + ncols_add: print('PASS: Dimension of df match' , '\nDim of df:', dfm2_mis.shape - , 'n================================================================') + , '\n================================================================') else: print('FAIL: Dim mismatch' , '\nOriginal no. of cols:', df_ncols @@ -333,8 +336,6 @@ else: , '\nGot:', dfm2_mis.shape[1]) sys.exit() -print('No. of cols after adding OR_kin:', len(dfm2_mis.columns)) - #2) rename columns to reflect that it is coming from kinship matrix adjustment dfm2_mis.rename(columns = {'af': 'af_kin' , 'beta': 'beta_kin' @@ -399,7 +400,7 @@ else: sys.exit() del(df_ncols) -#%% +#%%===================================================================== #4) reorder columnn print('Reordering', dfm2_mis.shape[1], 'columns' , '\n===============================================')