Liu-Hy's picture
Add files using upload-large-folder tool
0815237 verified
raw
history blame contribute delete
1.83 kB
# Path Configuration
from tools.preprocess import *
# Processing context
trait = "Cystic_Fibrosis"
# Input paths
tcga_root_dir = "../DATA/TCGA"
# Output paths
out_data_file = "./output/preprocess/1/Cystic_Fibrosis/TCGA.csv"
out_gene_data_file = "./output/preprocess/1/Cystic_Fibrosis/gene_data/TCGA.csv"
out_clinical_data_file = "./output/preprocess/1/Cystic_Fibrosis/clinical_data/TCGA.csv"
json_path = "./output/preprocess/1/Cystic_Fibrosis/cohort_info.json"
import os
import pandas as pd
# 1. Identify subdirectories under tcga_root_dir
subdirectories = os.listdir(tcga_root_dir)
# Attempt to locate a subdirectory related to "Cystic_Fibrosis"
# (Looking for any name containing "cystic" or "fibrosis")
trait_subdir = None
for d in subdirectories:
lower_d = d.lower().replace('_', ' ')
if "cystic" in lower_d and "fibrosis" in lower_d:
trait_subdir = d
break
# If none found, skip this trait
if not trait_subdir:
print("No suitable subdirectory found for trait 'Cystic_Fibrosis'. Skipping...")
is_gene_available = False
is_trait_available = False
validate_and_save_cohort_info(
is_final=False,
cohort="TCGA",
info_path=json_path,
is_gene_available=is_gene_available,
is_trait_available=is_trait_available
)
else:
# 2. Identify paths to the clinical and genetic data files
full_subdir_path = os.path.join(tcga_root_dir, trait_subdir)
clinical_path, genetic_path = tcga_get_relevant_filepaths(full_subdir_path)
# 3. Load data into DataFrames
clinical_df = pd.read_csv(clinical_path, index_col=0, sep='\t')
genetic_df = pd.read_csv(genetic_path, index_col=0, sep='\t')
# 4. Print the column names of the clinical data for inspection
print("Clinical Data Columns:")
print(clinical_df.columns.tolist())