added cm run for logo_skf for actual data
This commit is contained in:
parent
9071a87056
commit
b2d0b827ad
4 changed files with 56 additions and 124 deletions
|
@ -98,13 +98,14 @@ skf_cv = StratifiedKFold(n_splits = 10 , shuffle = True, random_state = 42)
|
|||
# COMPLETE data: No tts_split
|
||||
########################################################################
|
||||
#%%
|
||||
def CMLogoSkf(combined_df
|
||||
def CMLogoSkf(cm_input_df
|
||||
, all_genes = ["embb", "katg", "rpob", "pnca", "gid", "alr"]
|
||||
, bts_genes = ["embb", "katg", "rpob", "pnca", "gid"]
|
||||
, cols_to_drop = ['dst', 'dst_mode', 'gene_name']
|
||||
, target_var = 'dst_mode'
|
||||
, gene_group = 'gene_name'
|
||||
, std_gene_omit = []
|
||||
, file_suffix = ""
|
||||
):
|
||||
|
||||
for bts_gene in bts_genes:
|
||||
|
@ -127,17 +128,24 @@ def CMLogoSkf(combined_df
|
|||
,'\nTraining on genes:', training_genesL
|
||||
, '\nOmitted genes:', tr_gene_omit
|
||||
, '\nBlind test gene:', bts_gene)
|
||||
|
||||
print('\nDim of data:', cm_input_df.shape)
|
||||
|
||||
tts_split_type = "logo_skf_BT_" + bts_gene
|
||||
|
||||
outFile = outdir + str(n_tr_genes+1) + "genes_" + tts_split_type + ".csv"
|
||||
|
||||
# if len(file_suffix) > 0:
|
||||
# file_suffix = '_' + file_suffix
|
||||
# else:
|
||||
# file_suffix = file_suffix
|
||||
|
||||
outFile = outdir + str(n_tr_genes+1) + "genes_" + tts_split_type + '_' + file_suffix + ".csv"
|
||||
|
||||
print(outFile)
|
||||
|
||||
#-------
|
||||
# training
|
||||
#------
|
||||
cm_training_df = combined_df[~combined_df['gene_name'].isin(tr_gene_omit)]
|
||||
cm_training_df = cm_input_df[~cm_input_df['gene_name'].isin(tr_gene_omit)]
|
||||
|
||||
cm_X = cm_training_df.drop(cols_to_drop, axis=1, inplace=False)
|
||||
#cm_y = cm_training_df.loc[:,'dst_mode']
|
||||
|
@ -156,7 +164,7 @@ def CMLogoSkf(combined_df
|
|||
#---------------
|
||||
# BTS: genes
|
||||
#---------------
|
||||
cm_test_df = combined_df[combined_df['gene_name'].isin([bts_gene])]
|
||||
cm_test_df = cm_input_df[cm_input_df['gene_name'].isin([bts_gene])]
|
||||
|
||||
cm_bts_X = cm_test_df.drop(cols_to_drop, axis = 1, inplace = False)
|
||||
#cm_bts_y = cm_test_df.loc[:, 'dst_mode']
|
||||
|
@ -165,31 +173,40 @@ def CMLogoSkf(combined_df
|
|||
print('\nTEST data dim:', cm_bts_X.shape
|
||||
, '\nTEST Target dim:', cm_bts_y.shape)
|
||||
|
||||
print("Running Multiple models on LOGO with SKF")
|
||||
# #%%:Running Multiple models on LOGO with SKF
|
||||
# cD3_v2 = MultModelsCl_logo_skf(input_df = cm_X
|
||||
# , target = cm_y
|
||||
# #, group = 'none'
|
||||
# , sel_cv = skf_cv
|
||||
|
||||
#%%:Running Multiple models on LOGO with SKF
|
||||
cD3_v2 = MultModelsCl_logo_skf(input_df = cm_X
|
||||
, target = cm_y
|
||||
#, group = 'none'
|
||||
, sel_cv = skf_cv
|
||||
# , blind_test_df = cm_bts_X
|
||||
# , blind_test_target = cm_bts_y
|
||||
|
||||
# , tts_split_type = tts_split_type
|
||||
|
||||
# , resampling_type = 'none' # default
|
||||
# , add_cm = True
|
||||
# , add_yn = True
|
||||
# , var_type = 'mixed'
|
||||
|
||||
# , run_blind_test = True
|
||||
# , return_formatted_output = True
|
||||
# , random_state = 42
|
||||
# , n_jobs = os.cpu_count() # the number of jobs should equal the number of CPU cores
|
||||
# )
|
||||
|
||||
, blind_test_df = cm_bts_X
|
||||
, blind_test_target = cm_bts_y
|
||||
|
||||
, tts_split_type = tts_split_type
|
||||
|
||||
, resampling_type = 'none' # default
|
||||
, add_cm = True
|
||||
, add_yn = True
|
||||
, var_type = 'mixed'
|
||||
|
||||
, run_blind_test = True
|
||||
, return_formatted_output = True
|
||||
, random_state = 42
|
||||
, n_jobs = os.cpu_count() # the number of jobs should equal the number of CPU cores
|
||||
)
|
||||
|
||||
cD3_v2.to_csv(outFile)
|
||||
# cD3_v2.to_csv(outFile)
|
||||
|
||||
#%%
|
||||
#CMLogoSkf(combined_df)
|
||||
CMLogoSkf(combined_df, std_gene_omit=['alr'])
|
||||
#%% RUN
|
||||
#===============
|
||||
# Complete Data
|
||||
#===============
|
||||
#CMLogoSkf(cm_input_df = combined_df,file_suffix = "complete")
|
||||
#CMLogoSkf(cm_input_df = combined_df, std_gene_omit=['alr'], file_suffix = "complete")
|
||||
|
||||
#===============
|
||||
# Actual Data
|
||||
#===============
|
||||
CMLogoSkf(cm_input_df = combined_df_actual, file_suffix = "actual")
|
||||
CMLogoSkf(cm_input_df = combined_df_actual, std_gene_omit=['alr'], file_suffix = "actual")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue