File size: 1,829 Bytes
0815237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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())