{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "44353979", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:55:36.751525Z", "iopub.status.busy": "2025-03-25T04:55:36.751349Z", "iopub.status.idle": "2025-03-25T04:55:36.911928Z", "shell.execute_reply": "2025-03-25T04:55:36.911595Z" } }, "outputs": [], "source": [ "import sys\n", "import os\n", "sys.path.append(os.path.abspath(os.path.join(os.getcwd(), '../..')))\n", "\n", "# Path Configuration\n", "from tools.preprocess import *\n", "\n", "# Processing context\n", "trait = \"Werner_Syndrome\"\n", "\n", "# Input paths\n", "tcga_root_dir = \"../../input/TCGA\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Werner_Syndrome/TCGA.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Werner_Syndrome/gene_data/TCGA.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Werner_Syndrome/clinical_data/TCGA.csv\"\n", "json_path = \"../../output/preprocess/Werner_Syndrome/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "7879037c", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "6628b8b6", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:55:36.913336Z", "iopub.status.busy": "2025-03-25T04:55:36.913197Z", "iopub.status.idle": "2025-03-25T04:55:36.918012Z", "shell.execute_reply": "2025-03-25T04:55:36.917723Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Available TCGA directories: ['TCGA_Liver_Cancer_(LIHC)', 'TCGA_Lower_Grade_Glioma_(LGG)', 'TCGA_lower_grade_glioma_and_glioblastoma_(GBMLGG)', 'TCGA_Lung_Adenocarcinoma_(LUAD)', 'TCGA_Lung_Cancer_(LUNG)', 'TCGA_Lung_Squamous_Cell_Carcinoma_(LUSC)', 'TCGA_Melanoma_(SKCM)', 'TCGA_Mesothelioma_(MESO)', 'TCGA_Ocular_melanomas_(UVM)', 'TCGA_Ovarian_Cancer_(OV)', 'TCGA_Pancreatic_Cancer_(PAAD)', 'TCGA_Pheochromocytoma_Paraganglioma_(PCPG)', 'TCGA_Prostate_Cancer_(PRAD)', 'TCGA_Rectal_Cancer_(READ)', 'TCGA_Sarcoma_(SARC)', 'TCGA_Stomach_Cancer_(STAD)', 'TCGA_Testicular_Cancer_(TGCT)', 'TCGA_Thymoma_(THYM)', 'TCGA_Thyroid_Cancer_(THCA)', 'TCGA_Uterine_Carcinosarcoma_(UCS)', '.DS_Store', 'CrawlData.ipynb', 'TCGA_Acute_Myeloid_Leukemia_(LAML)', 'TCGA_Adrenocortical_Cancer_(ACC)', 'TCGA_Bile_Duct_Cancer_(CHOL)', 'TCGA_Bladder_Cancer_(BLCA)', 'TCGA_Breast_Cancer_(BRCA)', 'TCGA_Cervical_Cancer_(CESC)', 'TCGA_Colon_and_Rectal_Cancer_(COADREAD)', 'TCGA_Colon_Cancer_(COAD)', 'TCGA_Endometrioid_Cancer_(UCEC)', 'TCGA_Esophageal_Cancer_(ESCA)', 'TCGA_Glioblastoma_(GBM)', 'TCGA_Head_and_Neck_Cancer_(HNSC)', 'TCGA_Kidney_Chromophobe_(KICH)', 'TCGA_Kidney_Clear_Cell_Carcinoma_(KIRC)', 'TCGA_Kidney_Papillary_Cell_Carcinoma_(KIRP)', 'TCGA_Large_Bcell_Lymphoma_(DLBC)']\n", "Potential relevant directories for Werner_Syndrome: []\n", "No directory specifically relevant to the trait: Werner_Syndrome\n", "Task marked as completed. Werner_Syndrome is not directly represented in the TCGA dataset.\n" ] } ], "source": [ "# Step 1: Review subdirectories to find one related to Werner Syndrome\n", "import os\n", "\n", "# List all directories in TCGA root directory\n", "tcga_dirs = os.listdir(tcga_root_dir)\n", "print(f\"Available TCGA directories: {tcga_dirs}\")\n", "\n", "# Look for directories related to Werner Syndrome\n", "relevant_dirs = []\n", "for dir_name in tcga_dirs:\n", " dir_lower = dir_name.lower()\n", " if \"werner\" in dir_lower or \"syndrome\" in dir_lower or \"progeria\" in dir_lower:\n", " relevant_dirs.append(dir_name)\n", "\n", "print(f\"Potential relevant directories for {trait}: {relevant_dirs}\")\n", "\n", "# Since TCGA is primarily a cancer genomics database, it's unlikely to have a specific\n", "# directory for Werner Syndrome. We should check the clinical data columns of datasets\n", "# to see if any contain information relevant to Werner Syndrome.\n", "\n", "if not relevant_dirs:\n", " print(f\"No directory specifically relevant to the trait: {trait}\")\n", " \n", " # Since Werner Syndrome is a rare genetic disorder and TCGA focuses on cancer genomics,\n", " # it's unlikely that this data exists in this database format\n", " validate_and_save_cohort_info(\n", " is_final=False,\n", " cohort=\"TCGA\",\n", " info_path=json_path,\n", " is_gene_available=False,\n", " is_trait_available=False\n", " )\n", " print(f\"Task marked as completed. {trait} is not directly represented in the TCGA dataset.\")\n", "else:\n", " # If by chance we did find a relevant directory, proceed with loading the data\n", " selected_dir = relevant_dirs[0]\n", " print(f\"Selected directory for {trait}: {selected_dir}\")\n", " \n", " # Get the full path to the directory\n", " cohort_dir = os.path.join(tcga_root_dir, selected_dir)\n", " \n", " # Step 2: Find clinical and genetic data files\n", " clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)\n", " \n", " print(f\"Clinical data file: {clinical_file_path}\")\n", " print(f\"Genetic data file: {genetic_file_path}\")\n", " \n", " # Step 3: Load the data files\n", " clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\\t')\n", " genetic_df = pd.read_csv(genetic_file_path, index_col=0, sep='\\t')\n", " \n", " # Step 4: Print column names of clinical data\n", " print(\"\\nClinical data columns:\")\n", " print(clinical_df.columns.tolist())\n", " \n", " # Check if both datasets are available\n", " is_gene_available = not genetic_df.empty\n", " is_trait_available = not clinical_df.empty\n", " \n", " # Initial validation\n", " validate_and_save_cohort_info(\n", " is_final=False,\n", " cohort=\"TCGA\",\n", " info_path=json_path,\n", " is_gene_available=is_gene_available,\n", " is_trait_available=is_trait_available\n", " )" ] } ], "metadata": { "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.16" } }, "nbformat": 4, "nbformat_minor": 5 }