{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "73c23ae9", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:05:09.250914Z", "iopub.status.busy": "2025-03-25T07:05:09.250687Z", "iopub.status.idle": "2025-03-25T07:05:09.415584Z", "shell.execute_reply": "2025-03-25T07:05:09.415251Z" } }, "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 = \"Brugada_Syndrome\"\n", "\n", "# Input paths\n", "tcga_root_dir = \"../../input/TCGA\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Brugada_Syndrome/TCGA.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Brugada_Syndrome/gene_data/TCGA.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Brugada_Syndrome/clinical_data/TCGA.csv\"\n", "json_path = \"../../output/preprocess/Brugada_Syndrome/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "8d2e6ed2", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "637c46a4", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:05:09.416856Z", "iopub.status.busy": "2025-03-25T07:05:09.416715Z", "iopub.status.idle": "2025-03-25T07:05:09.421639Z", "shell.execute_reply": "2025-03-25T07:05:09.421342Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Looking for a relevant cohort directory for Brugada_Syndrome...\n", "Available cohorts: ['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", "Coronary artery disease-related cohorts: []\n", "No suitable cohort found for Brugada_Syndrome.\n" ] } ], "source": [ "import os\n", "\n", "# Check if there's a suitable cohort directory for Coronary artery disease\n", "print(f\"Looking for a relevant cohort directory for {trait}...\")\n", "\n", "# Check available cohorts\n", "available_dirs = os.listdir(tcga_root_dir)\n", "print(f\"Available cohorts: {available_dirs}\")\n", "\n", "# Coronary artery disease-related keywords\n", "cad_keywords = ['coronary', 'artery', 'heart', 'cardiac', 'cardiovascular']\n", "\n", "# Look for coronary artery disease-related directories\n", "cad_related_dirs = []\n", "for d in available_dirs:\n", " if any(keyword in d.lower() for keyword in cad_keywords):\n", " cad_related_dirs.append(d)\n", "\n", "print(f\"Coronary artery disease-related cohorts: {cad_related_dirs}\")\n", "\n", "if not cad_related_dirs:\n", " print(f\"No suitable cohort found for {trait}.\")\n", " # Mark the task as completed by recording the unavailability\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", " # Exit the script early since no suitable cohort was found\n", " selected_cohort = None\n", "else:\n", " # Select the most relevant cohort if multiple are found\n", " selected_cohort = cad_related_dirs[0]\n", " print(f\"Selected cohort: {selected_cohort}\")\n", " \n", " # Get the full path to the selected cohort directory\n", " cohort_dir = os.path.join(tcga_root_dir, selected_cohort)\n", " \n", " # Get the clinical and genetic data file paths\n", " clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)\n", " \n", " print(f\"Clinical data file: {os.path.basename(clinical_file_path)}\")\n", " print(f\"Genetic data file: {os.path.basename(genetic_file_path)}\")\n", " \n", " # Load the clinical and genetic data\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", " # Print the column names of the clinical data\n", " print(\"\\nClinical data columns:\")\n", " print(clinical_df.columns.tolist())\n", " \n", " # Basic info about the datasets\n", " print(f\"\\nClinical data shape: {clinical_df.shape}\")\n", " print(f\"Genetic data shape: {genetic_df.shape}\")" ] } ], "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 }