{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "f88252d5", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T06:30:52.473153Z", "iopub.status.busy": "2025-03-25T06:30:52.473042Z", "iopub.status.idle": "2025-03-25T06:30:52.637314Z", "shell.execute_reply": "2025-03-25T06:30:52.636933Z" } }, "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 = \"Ankylosing_Spondylitis\"\n", "\n", "# Input paths\n", "tcga_root_dir = \"../../input/TCGA\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Ankylosing_Spondylitis/TCGA.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Ankylosing_Spondylitis/gene_data/TCGA.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Ankylosing_Spondylitis/clinical_data/TCGA.csv\"\n", "json_path = \"../../output/preprocess/Ankylosing_Spondylitis/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "9eed7bbf", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "1de2aba3", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T06:30:52.638801Z", "iopub.status.busy": "2025-03-25T06:30:52.638653Z", "iopub.status.idle": "2025-03-25T06:30:52.643620Z", "shell.execute_reply": "2025-03-25T06:30:52.643301Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Available TCGA subdirectories: ['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 Ankylosing_Spondylitis-related directories found: []\n", "No TCGA subdirectory contains terms directly related to Ankylosing_Spondylitis.\n", "TCGA is primarily a cancer genomics database and may not have specific data for this inflammatory condition.\n", "Task completed: Ankylosing_Spondylitis data not available in TCGA dataset.\n" ] } ], "source": [ "import os\n", "\n", "# Step 1: Look for directories related to Ankylosing Spondylitis (inflammatory arthritis affecting the spine)\n", "tcga_subdirs = os.listdir(tcga_root_dir)\n", "print(f\"Available TCGA subdirectories: {tcga_subdirs}\")\n", "\n", "# Check if any directories contain relevant terms to Ankylosing Spondylitis\n", "as_related_terms = [\"spondylitis\", \"arthritis\", \"inflammatory\", \"spine\", \"joint\", \"sacroiliac\", \"rheumatic\"]\n", "potential_dirs = []\n", "\n", "for directory in tcga_subdirs:\n", " if any(term.lower() in directory.lower() for term in as_related_terms):\n", " potential_dirs.append(directory)\n", "\n", "print(f\"Potential {trait}-related directories found: {potential_dirs}\")\n", "\n", "if potential_dirs:\n", " # Select the most specific match if found\n", " target_dir = potential_dirs[0]\n", " target_path = os.path.join(tcga_root_dir, target_dir)\n", " \n", " print(f\"Selected directory: {target_dir}\")\n", " \n", " # Get the clinical and genetic data file paths\n", " clinical_path, genetic_path = tcga_get_relevant_filepaths(target_path)\n", " \n", " # Load the datasets\n", " clinical_df = pd.read_csv(clinical_path, sep='\\t', index_col=0)\n", " genetic_df = pd.read_csv(genetic_path, sep='\\t', index_col=0)\n", " \n", " # Print column names of clinical data\n", " print(\"\\nClinical data columns:\")\n", " print(clinical_df.columns.tolist())\n", " \n", " # Check if we have both gene data and potential trait data\n", " has_gene_data = not genetic_df.empty\n", " has_potential_trait_data = not clinical_df.empty\n", " \n", " # Record our initial assessment\n", " validate_and_save_cohort_info(\n", " is_final=False, \n", " cohort=\"TCGA\", \n", " info_path=json_path, \n", " is_gene_available=has_gene_data, \n", " is_trait_available=has_potential_trait_data\n", " )\n", "else:\n", " print(f\"No TCGA subdirectory contains terms directly related to {trait}.\")\n", " print(\"TCGA is primarily a cancer genomics database and may not have specific data for this inflammatory condition.\")\n", " \n", " # Marking the trait as unavailable in the cohort_info.json\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", " \n", " print(f\"Task completed: {trait} data not available in TCGA dataset.\")" ] } ], "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 }