File size: 1,688 Bytes
24fe0da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Path Configuration
from tools.preprocess import *

# Processing context
trait = "Epilepsy"

# Input paths
tcga_root_dir = "../DATA/TCGA"

# Output paths
out_data_file = "./output/preprocess/1/Epilepsy/TCGA.csv"
out_gene_data_file = "./output/preprocess/1/Epilepsy/gene_data/TCGA.csv"
out_clinical_data_file = "./output/preprocess/1/Epilepsy/clinical_data/TCGA.csv"
json_path = "./output/preprocess/1/Epilepsy/cohort_info.json"

import os
import pandas as pd

# 1. Identify subdirectories under tcga_root_dir
subdirectories = os.listdir(tcga_root_dir)

trait_subdir = None
for d in subdirectories:
    # Check if the directory name contains "epilepsy" or synonyms (lowercase match)
    if "epilepsy" in d.lower():
        trait_subdir = d
        break

# 2. If none found, skip this trait
if not trait_subdir:
    print(f"No suitable subdirectory found for trait '{trait}'. 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:
    # Identify the 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())