| |
| from tools.preprocess import * |
|
|
| |
| trait = "Fibromyalgia" |
|
|
| |
| tcga_root_dir = "../DATA/TCGA" |
|
|
| |
| out_data_file = "./output/z3/preprocess/Fibromyalgia/TCGA.csv" |
| out_gene_data_file = "./output/z3/preprocess/Fibromyalgia/gene_data/TCGA.csv" |
| out_clinical_data_file = "./output/z3/preprocess/Fibromyalgia/clinical_data/TCGA.csv" |
| json_path = "./output/z3/preprocess/Fibromyalgia/cohort_info.json" |
|
|
|
|
| |
| import os |
| import pandas as pd |
|
|
| |
| synonym_terms = [ |
| 'fibromyalgia', |
| 'myalgia', |
| 'chronic pain', |
| 'central sensitization', |
| 'musculoskeletal pain' |
| ] |
|
|
| |
| all_subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))] |
|
|
| |
| matches = [] |
| for d in all_subdirs: |
| name_l = d.lower() |
| score = sum(term in name_l for term in synonym_terms) |
| if score > 0: |
| matches.append((score, d)) |
|
|
| if not matches: |
| |
| validate_and_save_cohort_info( |
| is_final=False, |
| cohort="TCGA", |
| info_path=json_path, |
| is_gene_available=False, |
| is_trait_available=False |
| ) |
| else: |
| |
| matches.sort(key=lambda x: (x[0], len(x[1])), reverse=True) |
| selected_dir = matches[0][1] |
| cohort_dir = os.path.join(tcga_root_dir, selected_dir) |
|
|
| |
| clinical_fp, genetic_fp = tcga_get_relevant_filepaths(cohort_dir) |
|
|
| |
| clinical_df = pd.read_csv(clinical_fp, sep='\t', index_col=0, low_memory=False) |
| genetic_df = pd.read_csv(genetic_fp, sep='\t', index_col=0, low_memory=False) |
|
|
| |
| print(clinical_df.columns.tolist()) |