File size: 3,917 Bytes
f811ee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Path Configuration
from tools.preprocess import *

# Processing context
trait = "Lactose_Intolerance"

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

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

# 1. From the subdirectories list, select stomach cancer data since lactose intolerance 
# involves digestive system, particularly stomach and small intestine
cohort_dir = os.path.join(tcga_root_dir, 'TCGA_Stomach_Cancer_(STAD)')

# 2. Get the clinical and genetic data file paths
clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)

# 3. Load the 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 clinical data columns
print("Clinical data columns:")
print(clinical_df.columns.tolist())
# Identify candidate demographic columns 
candidate_age_cols = ['age_at_initial_pathologic_diagnosis', 'days_to_birth']
candidate_gender_cols = ['gender']

# Load clinical data to preview columns using helper function
clinical_file_path, _ = tcga_get_relevant_filepaths(os.path.join(tcga_root_dir, "STAD"))
clinical_df = pd.read_csv(clinical_file_path, index_col=0)

# Extract and preview age columns
age_preview = preview_df(clinical_df[candidate_age_cols])
print("Age columns preview:")
print(age_preview)

# Extract and preview gender columns 
gender_preview = preview_df(clinical_df[candidate_gender_cols])
print("\nGender columns preview:")
print(gender_preview)
# 1. From the subdirectories list, select stomach cancer data since lactose intolerance 
# involves digestive system, particularly stomach and small intestine
cohort_dir = os.path.join(tcga_root_dir, 'TCGA_Stomach_Cancer_(STAD)')

# 2. Get the clinical and genetic data file paths
clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)

# 3. Load the 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 clinical data columns
print("Clinical data columns:")
print(clinical_df.columns.tolist())
# Define candidate columns
candidate_age_cols = ['age_at_initial_pathologic_diagnosis', 'days_to_birth']
candidate_gender_cols = ['gender']

# Get proper file paths for STAD cohort
cohort_dir = os.path.join(tcga_root_dir, "STAD")
clinical_file_path, _ = tcga_get_relevant_filepaths(cohort_dir)

# Read with more robust parsing
clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\t')

age_preview = {}
for col in candidate_age_cols:
    if col in clinical_df.columns:
        age_preview[col] = clinical_df[col].head().tolist()

gender_preview = {}
for col in candidate_gender_cols:
    if col in clinical_df.columns:
        gender_preview[col] = clinical_df[col].head().tolist()

print("Age columns preview:")
print(age_preview)
print("\nGender columns preview:")
print(gender_preview)
# Since TCGA data doesn't contain suitable information about lactose intolerance,
# we need to skip this trait and record this decision
is_usable = validate_and_save_cohort_info(
    is_final=False, 
    cohort="TCGA_STAD",
    info_path=json_path,
    is_gene_available=True,  # Gene expression data is available
    is_trait_available=False,  # But no suitable trait information
    is_biased=None,
    df=None,
    note="TCGA datasets focus on cancer diagnoses and do not contain reliable information about lactose intolerance. Cannot use stomach cancer status as proxy since there's no established relationship between these conditions."
)

print("Lactose intolerance trait cannot be studied using TCGA data.")