# Path Configuration from tools.preprocess import * # Processing context trait = "Alopecia" # Input paths tcga_root_dir = "../DATA/TCGA" # Output paths out_data_file = "./output/z1/preprocess/Alopecia/TCGA.csv" out_gene_data_file = "./output/z1/preprocess/Alopecia/gene_data/TCGA.csv" out_clinical_data_file = "./output/z1/preprocess/Alopecia/clinical_data/TCGA.csv" json_path = "./output/z1/preprocess/Alopecia/cohort_info.json" # Step 1: Initial Data Loading import os import pandas as pd # Step 1: Identify the most relevant TCGA cohort directory for the trait "Alopecia" subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))] trait_terms = ['alopecia', 'hair', 'hairloss', 'hair_loss', 'hypotrich', 'atrich', 'trichotillomania'] selected_subdir = None for d in subdirs: name_l = d.lower() if any(term in name_l for term in trait_terms): selected_subdir = d break clinical_df = None genetic_df = None if selected_subdir is None: # No suitable cohort found for Alopecia in TCGA; record and skip further processing. 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 found for the trait; skipping.") else: # Step 2: Locate clinicalMatrix and PANCAN files within the selected cohort directory cohort_dir = os.path.join(tcga_root_dir, selected_subdir) clinical_path, genetic_path = tcga_get_relevant_filepaths(cohort_dir) # Step 3: Load both files into DataFrames clinical_df = pd.read_csv(clinical_path, sep='\t', index_col=0, low_memory=False) genetic_df = pd.read_csv(genetic_path, sep='\t', index_col=0, low_memory=False) # Step 4: Print clinical column names print(clinical_df.columns.tolist())