# Path Configuration from tools.preprocess import * # Processing context trait = "Craniosynostosis" # Input paths tcga_root_dir = "../DATA/TCGA" # Output paths out_data_file = "./output/z2/preprocess/Craniosynostosis/TCGA.csv" out_gene_data_file = "./output/z2/preprocess/Craniosynostosis/gene_data/TCGA.csv" out_clinical_data_file = "./output/z2/preprocess/Craniosynostosis/clinical_data/TCGA.csv" json_path = "./output/z2/preprocess/Craniosynostosis/cohort_info.json" # Step 1: Initial Data Loading # Step 1: Identify the most relevant TCGA subdirectory for Craniosynostosis (none expected) subdirs = os.listdir(tcga_root_dir) # Define keywords related to Craniosynostosis keywords = [ ("craniosynostosis", 5), ("synostosis", 4), ("cranio", 3), ("skull", 2), ("suture", 1), ] def score_dir(name: str) -> int: lname = name.lower() return max((w for k, w in keywords if k in lname), default=0) scored = [(d, score_dir(d)) for d in subdirs] # Select dir with highest score if any > 0 selected_dir = None if scored: best_dir, best_score = max(scored, key=lambda x: x[1]) if best_score > 0: selected_dir = best_dir clinical_df, genetic_df = pd.DataFrame(), pd.DataFrame() if selected_dir is None: # No suitable TCGA cohort for Craniosynostosis; record and skip _ = 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. Clinical columns: []") else: # Step 2: Identify file paths cohort_dir = os.path.join(tcga_root_dir, selected_dir) clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir) # Step 3: Load both files as DataFrames def read_tcga_file(path: str) -> pd.DataFrame: compression = 'gzip' if path.endswith('.gz') else None return pd.read_csv(path, sep='\t', index_col=0, low_memory=False, compression=compression) clinical_df = read_tcga_file(clinical_file_path) genetic_df = read_tcga_file(genetic_file_path) # Step 4: Print column names of the clinical data print(list(clinical_df.columns))