| |
| from tools.preprocess import * |
|
|
| |
| trait = "Aniridia" |
|
|
| |
| tcga_root_dir = "../DATA/TCGA" |
|
|
| |
| out_data_file = "./output/z1/preprocess/Aniridia/TCGA.csv" |
| out_gene_data_file = "./output/z1/preprocess/Aniridia/gene_data/TCGA.csv" |
| out_clinical_data_file = "./output/z1/preprocess/Aniridia/clinical_data/TCGA.csv" |
| json_path = "./output/z1/preprocess/Aniridia/cohort_info.json" |
|
|
|
|
| |
| import os |
| import pandas as pd |
|
|
| |
| subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))] |
|
|
| |
| keywords_weights = [ |
| ("aniridia", 10), |
| ("iris", 6), |
| ("ocular", 5), |
| ("eye", 4), |
| ("uveal", 4), |
| ("uvea", 4), |
| ("retina", 3), |
| ("optic", 2), |
| ("ophthalm", 2) |
| ] |
|
|
| def score_dir(name: str) -> int: |
| ln = name.lower() |
| return sum(w for k, w in keywords_weights if k in ln) |
|
|
| scored = [(d, score_dir(d)) for d in subdirs] |
| scored.sort(key=lambda x: x[1], reverse=True) |
| selected_dir = scored[0][0] if scored and scored[0][1] > 0 else None |
|
|
| if selected_dir is None: |
| |
| validate_and_save_cohort_info( |
| is_final=False, |
| cohort="TCGA", |
| info_path=json_path, |
| is_gene_available=False, |
| is_trait_available=False |
| ) |
| print("No suitable TCGA cohort directory found for the trait. Skipping.") |
| else: |
| cohort_dir = os.path.join(tcga_root_dir, selected_dir) |
|
|
| |
| clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir) |
|
|
| |
| clinical_df = pd.read_csv(clinical_file_path, sep='\t', index_col=0, low_memory=False, compression='infer') |
| genetic_df = pd.read_csv(genetic_file_path, sep='\t', index_col=0, low_memory=False, compression='infer') |
|
|
| |
| SELECTED_TCGA_DIR = selected_dir |
| SELECTED_CLINICAL_PATH = clinical_file_path |
| SELECTED_GENETIC_PATH = genetic_file_path |
| TCGA_CLINICAL_DF = clinical_df |
| TCGA_GENETIC_DF = genetic_df |
|
|
| |
| print(list(clinical_df.columns)) |