File size: 1,977 Bytes
21a514e | 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 | # Path Configuration
from tools.preprocess import *
# Processing context
trait = "Fibromyalgia"
# Input paths
tcga_root_dir = "../DATA/TCGA"
# Output paths
out_data_file = "./output/z3/preprocess/Fibromyalgia/TCGA.csv"
out_gene_data_file = "./output/z3/preprocess/Fibromyalgia/gene_data/TCGA.csv"
out_clinical_data_file = "./output/z3/preprocess/Fibromyalgia/clinical_data/TCGA.csv"
json_path = "./output/z3/preprocess/Fibromyalgia/cohort_info.json"
# Step 1: Initial Data Loading
import os
import pandas as pd
# Step 1: Select the most relevant TCGA cohort directory for Fibromyalgia (likely none)
synonym_terms = [
'fibromyalgia',
'myalgia',
'chronic pain',
'central sensitization',
'musculoskeletal pain'
]
# List available subdirectories
all_subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))]
# Find matches
matches = []
for d in all_subdirs:
name_l = d.lower()
score = sum(term in name_l for term in synonym_terms)
if score > 0:
matches.append((score, d))
if not matches:
# No suitable TCGA cohort for Fibromyalgia; record and skip
validate_and_save_cohort_info(
is_final=False,
cohort="TCGA",
info_path=json_path,
is_gene_available=False,
is_trait_available=False
)
else:
# Choose the most specific match (highest score, then longest matched directory name)
matches.sort(key=lambda x: (x[0], len(x[1])), reverse=True)
selected_dir = matches[0][1]
cohort_dir = os.path.join(tcga_root_dir, selected_dir)
# Step 2: Identify clinical and genetic file paths
clinical_fp, genetic_fp = tcga_get_relevant_filepaths(cohort_dir)
# Step 3: Load both files
clinical_df = pd.read_csv(clinical_fp, sep='\t', index_col=0, low_memory=False)
genetic_df = pd.read_csv(genetic_fp, sep='\t', index_col=0, low_memory=False)
# Step 4: Print clinical column names
print(clinical_df.columns.tolist()) |