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

# Processing context
trait = "COVID-19"

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

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

import os
import pandas as pd

# Step 1: Check directories in tcga_root_dir for anything relevant to "COVID-19"
search_terms = ["covid", "covid-19"]
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):
        matching_dir = d
        break

if matching_dir is None:
    # No matching directory found. Mark the dataset as skipped for COVID-19.
    validate_and_save_cohort_info(
        is_final=False,
        cohort="TCGA_COVID-19",
        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())