{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "58d0ddef", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:56:09.807344Z", "iopub.status.busy": "2025-03-25T07:56:09.807239Z", "iopub.status.idle": "2025-03-25T07:56:09.963914Z", "shell.execute_reply": "2025-03-25T07:56:09.963487Z" } }, "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 = \"Lupus_(Systemic_Lupus_Erythematosus)\"\n", "\n", "# Input paths\n", "tcga_root_dir = \"../../input/TCGA\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Lupus_(Systemic_Lupus_Erythematosus)/TCGA.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Lupus_(Systemic_Lupus_Erythematosus)/gene_data/TCGA.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Lupus_(Systemic_Lupus_Erythematosus)/clinical_data/TCGA.csv\"\n", "json_path = \"../../output/preprocess/Lupus_(Systemic_Lupus_Erythematosus)/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "d525a32d", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "9a07215e", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:56:09.965194Z", "iopub.status.busy": "2025-03-25T07:56:09.965051Z", "iopub.status.idle": "2025-03-25T07:56:09.969994Z", "shell.execute_reply": "2025-03-25T07:56:09.969601Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Available TCGA directories:\n", "['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", "No directories found related to Lupus (Systemic Lupus Erythematosus) in the TCGA dataset.\n", "TCGA primarily contains cancer datasets, while Lupus is an autoimmune disease.\n" ] } ], "source": [ "import os\n", "import pandas as pd\n", "\n", "# Review subdirectories to find the most relevant match for Lupus (Systemic Lupus Erythematosus)\n", "all_dirs = os.listdir(tcga_root_dir)\n", "\n", "# Print all available directories for debugging\n", "print(\"Available TCGA directories:\")\n", "print(all_dirs)\n", "\n", "# Looking for directories related to Lupus or autoimmune diseases\n", "lupus_related_dirs = [d for d in all_dirs if \"lupus\" in d.lower() or \"autoimmune\" in d.lower()]\n", "\n", "if len(lupus_related_dirs) > 0:\n", " # If we found related directories, choose the most specific one\n", " selected_dir = lupus_related_dirs[0]\n", " selected_path = os.path.join(tcga_root_dir, selected_dir)\n", " \n", " # Get paths to the clinical and genetic data files\n", " clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(selected_path)\n", " \n", " # Load the data files\n", " clinical_data = pd.read_csv(clinical_file_path, index_col=0, sep='\\t')\n", " genetic_data = pd.read_csv(genetic_file_path, index_col=0, sep='\\t')\n", " \n", " # Print the column names of the clinical data\n", " print(\"Clinical data columns:\")\n", " print(clinical_data.columns.tolist())\n", " \n", " # Also print basic information about both datasets\n", " print(\"\\nClinical data shape:\", clinical_data.shape)\n", " print(\"Genetic data shape:\", genetic_data.shape)\n", "else:\n", " print(\"No directories found related to Lupus (Systemic Lupus Erythematosus) in the TCGA dataset.\")\n", " print(\"TCGA primarily contains cancer datasets, while Lupus is an autoimmune disease.\")\n", " \n", " # Mark this task as completed with no suitable directory found\n", " is_gene_available = False\n", " is_trait_available = False\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 }