# Path Configuration | |
from tools.preprocess import * | |
# Processing context | |
trait = "Bipolar_disorder" | |
# Input paths | |
tcga_root_dir = "../DATA/TCGA" | |
# Output paths | |
out_data_file = "./output/preprocess/1/Bipolar_disorder/TCGA.csv" | |
out_gene_data_file = "./output/preprocess/1/Bipolar_disorder/gene_data/TCGA.csv" | |
out_clinical_data_file = "./output/preprocess/1/Bipolar_disorder/clinical_data/TCGA.csv" | |
json_path = "./output/preprocess/1/Bipolar_disorder/cohort_info.json" | |
import os | |
import pandas as pd | |
# Step 1: Check directories in tcga_root_dir for anything relevant to "Bipolar_disorder" | |
search_terms = ["bipolar", "bipolar_disorder", "mania"] | |
dir_list = os.listdir(tcga_root_dir) | |
matching_dir = None | |
for d in dir_list: | |
d_lower = d.lower() | |
if any(term in d_lower for term in search_terms): | |
# Found a match, select this directory | |
matching_dir = d | |
break | |
if matching_dir is None: | |
# No matching directory found. Mark the dataset as skipped. | |
validate_and_save_cohort_info( | |
is_final=False, | |
cohort="TCGA", | |
info_path=json_path, | |
is_gene_available=False, | |
is_trait_available=False | |
) | |
else: | |
# 2. Identify the clinicalMatrix and PANCAN files | |
cohort_dir = os.path.join(tcga_root_dir, matching_dir) | |
clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir) | |
# 3. Load both data files | |
clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\t') | |
genetic_df = pd.read_csv(genetic_file_path, index_col=0, sep='\t') | |
# 4. Print the column names of the clinical data | |
print("Clinical Data Columns:") | |
print(clinical_df.columns.tolist()) |