Commit 44b870ae authored by Alessia Marcolini's avatar Alessia Marcolini
Browse files

Update argument parser help

parent 60b08093
......@@ -17,22 +17,10 @@ def load_data(filename):
#%%
class myArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super(myArgumentParser, self).__init__(*args, **kwargs)
def convert_arg_line_to_args(self, line):
for arg in line.split():
if not arg.strip():
continue
if arg[0] == '#':
break
yield arg
parser = myArgumentParser(
description='Concatenate omic layers files', fromfile_prefix_chars='@'
parser = argparse.ArgumentParser(
description='Compute Borda of Bordas for juXT and rSNF'
)
parser.add_argument('--datafolder', type=str, help='Main data folder')
parser.add_argument('--outfolder', type=str, help='Results folder')
parser.add_argument('--dataset', type=str, help='Dataset name')
......@@ -40,10 +28,12 @@ parser.add_argument('--target', type=str, help='Clinical endpoint')
parser.add_argument(
'--model', type=str, help='Classifiers implemented, randomForest or LSVM'
)
parser.add_argument('--layers', type=str, nargs='+', help='')
parser.add_argument('--n_splits_end', type=int, help='')
parser.add_argument('--n_splits_start', type=int, help='')
parser.add_argument('--mode', type=str, help='rSNF, rSNFi, single')
parser.add_argument('--layers', type=str, nargs='+', help='List of omic layers')
parser.add_argument(
'--n_splits_end', type=int, help='Upper end of splits range - not inclusive'
)
parser.add_argument('--n_splits_start', type=int, help='Lower end of splits range')
parser.add_argument('--mode', type=str, help='juXT or rSNF')
args = parser.parse_args()
......@@ -57,7 +47,7 @@ LAYERS = args.layers
N_SPLITS_START = args.n_splits_start
N_SPLITS_END = args.n_splits_end
MODE = args.mode
assert MODE in ['juxt', 'rSNF', 'single']
assert MODE in ['juxt', 'rSNF']
N_LAYERS = len(LAYERS)
......
......@@ -7,24 +7,11 @@ from itertools import combinations
import numpy as np
import pandas as pd
#%%
class myArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super(myArgumentParser, self).__init__(*args, **kwargs)
def convert_arg_line_to_args(self, line):
for arg in line.split():
if not arg.strip():
continue
if arg[0] == '#':
break
yield arg
parser = myArgumentParser(
description='Concatenate omic layers files', fromfile_prefix_chars='@'
parser = argparse.ArgumentParser(
description='Compute Borda of Bordas for juXT and rSNF'
)
parser.add_argument('--datafolder', type=str, help='Main data folder')
parser.add_argument('--outfolder', type=str, help='Results folder')
parser.add_argument('--dataset', type=str, help='Dataset name')
......@@ -32,10 +19,12 @@ parser.add_argument('--target', type=str, help='Clinical endpoint')
parser.add_argument(
'--model', type=str, help='Classifiers implemented, randomForest or LSVM'
)
parser.add_argument('--layers', type=str, nargs='+', help='')
parser.add_argument('--n_splits_end', type=int, help='')
parser.add_argument('--n_splits_start', type=int, help='')
parser.add_argument('--mode', type=str, help='rSNFi custom Borda')
parser.add_argument('--layers', type=str, nargs='+', help='List of omic layers')
parser.add_argument(
'--n_splits_end', type=int, help='Upper end of splits range - not inclusive'
)
parser.add_argument('--n_splits_start', type=int, help='Lower end of splits range')
parser.add_argument('--mode', type=str, help='rSNF')
args = parser.parse_args()
......@@ -49,6 +38,7 @@ LAYERS = args.layers
N_SPLITS_START = args.n_splits_start
N_SPLITS_END = args.n_splits_end
MODE = args.mode
assert MODE == 'rSNFi'
N_LAYERS = len(LAYERS)
......
......@@ -10,23 +10,9 @@ import bootstrapped.stats_functions as bs_stats
import numpy as np
import pandas as pd
#%%
class myArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super(myArgumentParser, self).__init__(*args, **kwargs)
def convert_arg_line_to_args(self, line):
for arg in line.split():
if not arg.strip():
continue
if arg[0] == '#':
break
yield arg
parser = myArgumentParser(
description='Compute metrics on all splits', fromfile_prefix_chars='@'
parser = argparse.ArgumentParser(
description='Compute Borda of Bordas for juXT and rSNF'
)
parser.add_argument('--outfolder', type=str, help='Results folder')
parser.add_argument('--dataset', type=str, help='Dataset name')
......@@ -34,10 +20,12 @@ parser.add_argument('--target', type=str, help='Clinical endpoint')
parser.add_argument(
'--model', type=str, help='classifiers implemented, randomForest or LSVM'
)
parser.add_argument('--layers', type=str, nargs='+', help='')
parser.add_argument('--n_splits_end', type=int, help='')
parser.add_argument('--n_splits_start', type=int, help='')
parser.add_argument('--mode', type=str, help='juxt, rSNF, rSNFi, single')
parser.add_argument('--layers', type=str, nargs='+', help='List of omic layers')
parser.add_argument(
'--n_splits_end', type=int, help='Upper end of splits range - not inclusive'
)
parser.add_argument('--n_splits_start', type=int, help='Lower end of splits range')
parser.add_argument('--mode', type=str, help='juXT, rSNF, rSNFi or single')
args = parser.parse_args()
......
# %%
import numpy as np
from sklearn.model_selection import StratifiedKFold
import argparse
import os
import numpy as np
import pandas as pd
from sklearn.model_selection import StratifiedKFold
from tqdm import tqdm
import argparse
#%%
class myArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super(myArgumentParser, self).__init__(*args, **kwargs)
def convert_arg_line_to_args(self, line):
for arg in line.split():
if not arg.strip():
continue
if arg[0] == '#':
break
yield arg
parser = myArgumentParser(
description='Run a training experiment (10x5-CV fold) using Random Forest as classifier.',
fromfile_prefix_chars='@',
)
parser = argparse.ArgumentParser()
parser.add_argument('--datafiles', type=str, nargs='+', help='Training datafile')
parser.add_argument('--labelsfile', type=str, help='Sample labels')
......@@ -61,7 +46,6 @@ for datafile in DATAFILES:
cv_data = original_data.iloc[idx_tr]
cv_labels = original_labels.iloc[idx_tr]
# print(cv_data.shape)
layer_filename = os.path.splitext(datafile)[0]
layer_ext = os.path.splitext(datafile)[1]
layer_filename_new = f'{layer_filename}_{n}_{i}{layer_ext}'
......
......@@ -5,28 +5,14 @@ from itertools import combinations
import pandas as pd
#%%
parser = argparse.ArgumentParser(description='Concatenate omic layers files')
class myArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super(myArgumentParser, self).__init__(*args, **kwargs)
def convert_arg_line_to_args(self, line):
for arg in line.split():
if not arg.strip():
continue
if arg[0] == '#':
break
yield arg
parser = myArgumentParser(
description='Concatenate omic layers files', fromfile_prefix_chars='@'
)
parser.add_argument('--datafolder', type=str, help='Main data folder')
parser.add_argument('--dataset', type=str, help='Dataset name')
parser.add_argument('--target', type=str, help='Clinical endpoint')
parser.add_argument('--split_id', type=int, help='')
parser.add_argument('--layers', type=str, nargs='+', help='')
parser.add_argument('--split_id', type=int, help='Split ID')
parser.add_argument('--layers', type=str, nargs='+', help='List of omic layers')
args = parser.parse_args()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment