Liu-Hy's picture
Add files using upload-large-folder tool
d818561 verified
Raw
History Blame Contribute Delete
1.84 kB
# Path Configuration
from tools.preprocess import *
# Processing context
trait = "Canavan_Disease"
# Input paths
tcga_root_dir = "../DATA/TCGA"
# Output paths
out_data_file = "./output/z2/preprocess/Canavan_Disease/TCGA.csv"
out_gene_data_file = "./output/z2/preprocess/Canavan_Disease/gene_data/TCGA.csv"
out_clinical_data_file = "./output/z2/preprocess/Canavan_Disease/clinical_data/TCGA.csv"
json_path = "./output/z2/preprocess/Canavan_Disease/cohort_info.json"
# Step 1: Initial Data Loading
import os
import pandas as pd
# Step 1: Find matching TCGA cohort directory for the trait
subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))]
trait_keywords = {"canavan", "leukodystrophy", "aspartoacylase", "aspa"}
matches = []
for d in subdirs:
name_l = d.lower()
if any(k in name_l for k in trait_keywords):
matches.append(d)
selected_dir = None
if matches:
# Choose the most specific match (longest name as proxy for specificity)
selected_dir = sorted(matches, key=len, reverse=True)[0]
if selected_dir is None:
# No suitable TCGA cohort for Canavan Disease; 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
)
else:
# Step 2: Identify clinical and genetic 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 dataframes
clinical_df = pd.read_csv(clinical_file_path, sep='\t', index_col=0, low_memory=False)
genetic_df = pd.read_csv(genetic_file_path, sep='\t', index_col=0, low_memory=False)
# Step 4: Print clinical column names
print(clinical_df.columns.tolist())