# Path Configuration from tools.preprocess import * # Processing context trait = "Cystic_Fibrosis" # Input paths tcga_root_dir = "../DATA/TCGA" # Output paths out_data_file = "./output/z2/preprocess/Cystic_Fibrosis/TCGA.csv" out_gene_data_file = "./output/z2/preprocess/Cystic_Fibrosis/gene_data/TCGA.csv" out_clinical_data_file = "./output/z2/preprocess/Cystic_Fibrosis/clinical_data/TCGA.csv" json_path = "./output/z2/preprocess/Cystic_Fibrosis/cohort_info.json" # Step 1: Initial Data Loading import os import pandas as pd # List subdirectories under TCGA root subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))] # Try to find a cohort matching Cystic Fibrosis (CF). TCGA is cancer-focused; CF is not a cancer. # Only match strict synonyms to avoid inappropriate selection. keywords = ["cystic fibrosis", "mucoviscidosis", "cf"] matched_dirs = [] for d in subdirs: name_l = d.lower() if any(k in name_l for k in keywords): matched_dirs.append(d) if len(matched_dirs) == 0: # No suitable cohort found; record and skip this trait for TCGA _ = validate_and_save_cohort_info( is_final=False, cohort="TCGA", info_path=json_path, is_gene_available=False, is_trait_available=False ) clinical_df = None genetic_df = None else: # If multiple matches, choose the most specific (longest name as proxy) selected_dir = sorted(matched_dirs, key=len, reverse=True)[0] cohort_dir = os.path.join(tcga_root_dir, selected_dir) # Locate clinical and genetic file paths clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir) # Load dataframes 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') # Print clinical columns print(clinical_df.columns.tolist())