{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "d03a883e", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:54:59.287024Z", "iopub.status.busy": "2025-03-25T04:54:59.286908Z", "iopub.status.idle": "2025-03-25T04:54:59.453166Z", "shell.execute_reply": "2025-03-25T04:54:59.452685Z" } }, "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 = \"Vitamin_D_Levels\"\n", "\n", "# Input paths\n", "tcga_root_dir = \"../../input/TCGA\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Vitamin_D_Levels/TCGA.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Vitamin_D_Levels/gene_data/TCGA.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Vitamin_D_Levels/clinical_data/TCGA.csv\"\n", "json_path = \"../../output/preprocess/Vitamin_D_Levels/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "49e47da7", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "c8ad9157", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:54:59.454558Z", "iopub.status.busy": "2025-03-25T04:54:59.454413Z", "iopub.status.idle": "2025-03-25T04:54:59.459884Z", "shell.execute_reply": "2025-03-25T04:54:59.459490Z" } }, "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 Vitamin_D_Levels: []\n", "No directory specifically relevant to the trait: Vitamin_D_Levels\n", "Task marked as completed. Vitamin_D_Levels is not directly represented in the TCGA dataset.\n" ] } ], "source": [ "# Step 1: Review subdirectories to find one related to Vitamin D Levels\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 Vitamin D Levels\n", "relevant_dirs = []\n", "for dir_name in tcga_dirs:\n", " dir_lower = dir_name.lower()\n", " if \"vitamin\" in dir_lower or \"vitamin d\" in dir_lower or \"vitamin_d\" 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 Vitamin D Levels. We should check the clinical data columns of datasets\n", "# to see if any contain Vitamin D measurements.\n", "\n", "if not relevant_dirs:\n", " print(f\"No directory specifically relevant to the trait: {trait}\")\n", " \n", " # Since Vitamin D Levels is not a cancer type 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 }