{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "5e7501b6", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T03:51:16.525789Z", "iopub.status.busy": "2025-03-25T03:51:16.525538Z", "iopub.status.idle": "2025-03-25T03:51:16.691650Z", "shell.execute_reply": "2025-03-25T03:51:16.691225Z" } }, "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 = \"Rheumatoid_Arthritis\"\n", "cohort = \"GSE143153\"\n", "\n", "# Input paths\n", "in_trait_dir = \"../../input/GEO/Rheumatoid_Arthritis\"\n", "in_cohort_dir = \"../../input/GEO/Rheumatoid_Arthritis/GSE143153\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Rheumatoid_Arthritis/GSE143153.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Rheumatoid_Arthritis/gene_data/GSE143153.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Rheumatoid_Arthritis/clinical_data/GSE143153.csv\"\n", "json_path = \"../../output/preprocess/Rheumatoid_Arthritis/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "3fa38c19", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "4d2387f9", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T03:51:16.693142Z", "iopub.status.busy": "2025-03-25T03:51:16.692991Z", "iopub.status.idle": "2025-03-25T03:51:16.858167Z", "shell.execute_reply": "2025-03-25T03:51:16.857810Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Background Information:\n", "!Series_title\t\"Microarray analysis of salivary gland CD4+ T cells\"\n", "!Series_summary\t\"Whole human genome arrays were used to assess the transcriptome differences in CD3+CD4+CD45RA- memory T cells isolated and sorted from minor salivary gland biopsy tissue of individuals who met 2002 American European Consensus Group classification criteria for primary Sjogren’s syndrome (SS) and subjects who did not meet criteria for SS, lacked focal lymphocytic sialoadenitis, lacked anti-Ro antibodies, lacked anti-La antibodies, but who had subjective symptoms of dryness (non-SS, sicca controls).\"\n", "!Series_overall_design\t\"Samples from 17 pSS and 15 non-SS subjects were hybridized to Agilent Whole Human Genome 8x60K microarrays in three batches (Batch 1: 2 pSS, 3 non-SS; Batch 2: 6 pSS, 5 non-SS; Batch 3: 9 pSS, 7 non-SS).  All data were pooled to assess potential batch effects by principal components analysis and gene expression data were quality control checked using the arrayQualityMetrics R package. Batch effects were equalized via ComBat analysis (‘Surrogate Variable Analysis’ R package Ver 3.8.0; manual specification of batches).\"\n", "Sample Characteristics Dictionary:\n", "{0: ['subject id: Subject 1', 'subject id: Subject 2', 'subject id: Subject 3', 'subject id: Subject 4', 'subject id: Subject 5', 'subject id: Subject 6', 'subject id: Subject 7', 'subject id: Subject 8', 'subject id: Subject 9', 'subject id: Subject 10', 'subject id: Subject 11', 'subject id: Subject 12', 'subject id: Subject 13', 'subject id: Subject 14', 'subject id: Subject 15', 'subject id: Subject 16', 'subject id: Subject 17', 'subject id: Subject 18', 'subject id: Subject 19', 'subject id: Subject 20', 'subject id: Subject 21', 'subject id: Subject 22', 'subject id: Subject 23', 'subject id: Subject 24', 'subject id: Subject 25', 'subject id: Subject 26', 'subject id: Subject 27', 'subject id: Subject 28', 'subject id: Subject 29', 'subject id: Subject 30'], 1: ['aecg disease classification: Primary SS', 'aecg disease classification: non-SS'], 2: ['age: 56', 'age: 51', 'age: 37', 'age: 40', 'age: 41', 'age: 50', 'age: 38', 'age: 58', 'age: 55', 'age: 35', 'age: 43', 'age: 62', 'age: 46', 'age: 66', 'age: 60', 'age: 63', 'age: 19', 'age: 64', 'age: 71', 'age: 30', 'age: 31', 'age: 45'], 3: ['Sex: M', 'Sex: F'], 4: ['race: White', 'race: More Than One', 'race: Native American', 'race: Black'], 5: ['batch: Batch 1', 'batch: Batch 2', 'batch: Batch 3'], 6: ['cell type: Minor salivary gland memory CD4 T cells']}\n" ] } ], "source": [ "from tools.preprocess import *\n", "# 1. Identify the paths to the SOFT file and the matrix file\n", "soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)\n", "\n", "# 2. Read the matrix file to obtain background information and sample characteristics data\n", "background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']\n", "clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']\n", "background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)\n", "\n", "# 3. Obtain the sample characteristics dictionary from the clinical dataframe\n", "sample_characteristics_dict = get_unique_values_by_row(clinical_data)\n", "\n", "# 4. Explicitly print out all the background information and the sample characteristics dictionary\n", "print(\"Background Information:\")\n", "print(background_info)\n", "print(\"Sample Characteristics Dictionary:\")\n", "print(sample_characteristics_dict)\n" ] }, { "cell_type": "markdown", "id": "3f71ab0c", "metadata": {}, "source": [ "### Step 2: Dataset Analysis and Clinical Feature Extraction" ] }, { "cell_type": "code", "execution_count": 3, "id": "c3f49037", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T03:51:16.859493Z", "iopub.status.busy": "2025-03-25T03:51:16.859380Z", "iopub.status.idle": "2025-03-25T03:51:16.864840Z", "shell.execute_reply": "2025-03-25T03:51:16.864528Z" } }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "import os\n", "import json\n", "from typing import Callable, Optional, Dict, Any\n", "\n", "# 1. Gene Expression Data Availability\n", "# Based on the background information, this dataset uses \"Agilent Whole Human Genome 8x60K microarrays\"\n", "# which indicates it contains gene expression data (not just miRNA or methylation)\n", "is_gene_available = True\n", "\n", "# 2. Variable Availability and Data Type Conversion\n", "# After analyzing the background information, this dataset is actually about Sjögren's syndrome (SS), \n", "# not Rheumatoid Arthritis. Therefore, we should mark the trait as not available for our study.\n", "is_trait_available = False\n", "trait_row = None # The dataset is not about the trait of interest (Rheumatoid_Arthritis)\n", "\n", "# For age and gender, values exist in the sample characteristics, but they are irrelevant \n", "# since the dataset is not about our target trait\n", "age_row = None\n", "gender_row = None\n", "\n", "# Define conversion functions (even though we won't use them for this dataset)\n", "def convert_trait(value):\n", " \"\"\"Convert trait value to binary (0 for control, 1 for case)\"\"\"\n", " return None # Not applicable since dataset doesn't match our trait\n", "\n", "def convert_age(value):\n", " \"\"\"Convert age value to continuous\"\"\"\n", " return None # Not applicable since dataset doesn't match our trait\n", "\n", "def convert_gender(value):\n", " \"\"\"Convert gender value to binary (0 for female, 1 for male)\"\"\"\n", " return None # Not applicable since dataset doesn't match our trait\n", "\n", "# 3. Save Metadata\n", "# Initial filtering and metadata saving - reject this dataset due to trait mismatch\n", "validate_and_save_cohort_info(\n", " is_final=False,\n", " cohort=cohort,\n", " info_path=json_path,\n", " is_gene_available=is_gene_available,\n", " is_trait_available=is_trait_available,\n", ")\n", "\n", "# 4. Clinical Feature Extraction\n", "# Skip this step since trait data is not available for our target trait (Rheumatoid_Arthritis)" ] } ], "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 }