Mercurial > repos > bimib > cobraxy
comparison COBRAxy/ras_to_bounds.py @ 60:547942aa1a93 draft
Uploaded
author | luca_milaz |
---|---|
date | Sun, 13 Oct 2024 07:21:04 +0000 |
parents | 42a8ccae86cd |
children | 455e8945d02a |
comparison
equal
deleted
inserted
replaced
59:d4162562c8f5 | 60:547942aa1a93 |
---|---|
56 | 56 |
57 parser.add_argument('-rs', '--ras_selector', | 57 parser.add_argument('-rs', '--ras_selector', |
58 required = True, | 58 required = True, |
59 type=utils.Bool("using_RAS"), | 59 type=utils.Bool("using_RAS"), |
60 help = 'ras selector') | 60 help = 'ras selector') |
61 | |
62 parser.add_argument('-c', '--classes', | |
63 type = str, | |
64 required = False, | |
65 help = 'input classes') | |
66 | 61 |
67 parser.add_argument('-cc', '--cell_class', | 62 parser.add_argument('-cc', '--cell_class', |
68 type = str, | 63 type = str, |
69 help = 'output of cell class') | 64 help = 'output of cell class') |
70 | 65 |
216 | 211 |
217 ARGS.output_folder = 'ras_to_bounds/' | 212 ARGS.output_folder = 'ras_to_bounds/' |
218 | 213 |
219 if(ARGS.ras_selector == True): | 214 if(ARGS.ras_selector == True): |
220 ras_file_list = ARGS.input_ras.split(",") | 215 ras_file_list = ARGS.input_ras.split(",") |
221 if(len(ras_file_list)>1): | 216 ras_class_names = [] |
222 ras_class_names = [cls.strip() for cls in ARGS.classes.split(',')] | 217 for file in ras_file_list: |
223 else: | 218 ras_class_names.append(file.split(".")[0]) |
224 ras_class_names = ["placeHolder"] | |
225 ras_list = [] | 219 ras_list = [] |
226 class_assignments = pd.DataFrame(columns=["Patient_ID", "Class"]) | 220 class_assignments = pd.DataFrame(columns=["Patient_ID", "Class"]) |
227 for ras_matrix, ras_class_name in zip(ras_file_list, ras_class_names): | 221 for ras_matrix, ras_class_name in zip(ras_file_list, ras_class_names): |
228 ras = read_dataset(ras_matrix, "ras dataset") | 222 ras = read_dataset(ras_matrix, "ras dataset") |
229 ras.replace("None", None, inplace=True) | 223 ras.replace("None", None, inplace=True) |
230 ras.set_index("Reactions", drop=True, inplace=True) | 224 ras.set_index("Reactions", drop=True, inplace=True) |
231 ras = ras.T | 225 ras = ras.T |
232 ras = ras.astype(float) | 226 ras = ras.astype(float) |
233 ras_list.append(ras) | 227 ras_list.append(ras) |
234 for patient_id in ras.index: | 228 for patient_id in ras.index: |
235 class_assignments = pd.concat([class_assignments, pd.DataFrame({"Patient_ID": ras.index, "Class": ras_class_name})]) | 229 class_assignments = pd.concat([class_assignments, pd.DataFrame({"Patient_ID": patient_id, "Class": ras_class_name})]) |
236 | 230 |
237 | 231 |
238 # Concatenate all ras DataFrames into a single DataFrame | 232 # Concatenate all ras DataFrames into a single DataFrame |
239 ras_combined = pd.concat(ras_list, axis=1) | 233 ras_combined = pd.concat(ras_list, axis=1) |
240 # Normalize the RAS values by max RAS | 234 # Normalize the RAS values by max RAS |