changed ml output dirs and ready to run fs

This commit is contained in:
Tanushree Tunstall 2022-07-01 21:40:14 +01:00
parent 57348f1874
commit 11af00f1db
5 changed files with 67 additions and 152 deletions

View file

@ -80,6 +80,8 @@ homedir = os.path.expanduser("~")
sys.path.append(homedir + '/git/LSHTM_analysis/scripts/ml/ml_functions')
sys.path
###############################################################################
outdir = homedir + '/git/LSHTM_ML/output/combined/
#====================
# Import ML functions
#====================
@ -92,6 +94,9 @@ skf_cv = StratifiedKFold(n_splits = 10 , shuffle = True, random_state = 42)
#logo = LeaveOneGroupOut()
########################################################################
# COMPLETE data: No tts_split
########################################################################
#%%
def CMLogoSkf(combined_df
, all_genes = ["embb", "katg", "rpob", "pnca", "gid", "alr"]
@ -125,7 +130,8 @@ def CMLogoSkf(combined_df
tts_split_type = "logo_skf_BT_" + bts_gene
outFile = "/home/tanu/git/Data/ml_combined/" + str(n_tr_genes+1) + "genes_" + tts_split_type + ".csv"
outFile = outdir + str(n_tr_genes+1) + "genes_" + tts_split_type + ".csv"
print(outFile)
#-------

View file

@ -15,19 +15,19 @@ homedir = os.path.expanduser("~")
sys.path.append(homedir + '/git/LSHTM_analysis/scripts/ml/ml_functions')
sys.path
###############################################################################
outdir = homedir + '/git/LSHTM_ML/output/combined/
#====================
# Import ML functions
#====================
from MultClfs import *
#from MultClfs import *
from MultClfs_logo_skf import *
from GetMLData import *
from SplitTTS import *
# param dict for getmldata()
combined_model_paramD = {'data_combined_model' : False
, 'use_or' : False
, 'omit_all_genomic_features': False
, 'write_maskfile' : False
, 'write_outfile' : False }
# Input data
from ml_data_combined import *
###############################################################################
#ml_genes = ["pncA", "embB", "katG", "rpoB", "gid"]
@ -54,7 +54,7 @@ for gene, drug in ml_gene_drugD.items():
for split_type in split_types:
for data_type in split_data_types:
out_filename = (gene.lower()+'_'+split_type+'_'+data_type+'.csv')
out_filename = outdir + gene.lower()+ '_' + split_type + '_' + data_type + '.csv'
tempD=split_tts(gene_dataD[gene_low]
, data_type = data_type
, split_type = split_type
@ -88,14 +88,8 @@ for gene, drug in ml_gene_drugD.items():
mmDD = {}
for k, v in paramD.items():
scoresD = MultModelsCl(**paramD[k]
, tts_split_type = split_type
, skf_cv = skf_cv
, blind_test_df = tempD['X_bts']
, blind_test_target = tempD['y_bts']
, add_cm = True
, add_yn = True
, return_formatted_output = True)
scoresD = MultModelsCl_logo_skf(**paramD[k]
XXXXXXXXXXXXXXXXXXXXXXX
mmDD[k] = scoresD
# Extracting the dfs from within the dict and concatenating to output as one df