File size: 9,934 Bytes
92d2f89 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "8be23d5f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-25T06:27:08.878150Z",
"iopub.status.busy": "2025-03-25T06:27:08.878039Z",
"iopub.status.idle": "2025-03-25T06:27:09.037020Z",
"shell.execute_reply": "2025-03-25T06:27:09.036638Z"
}
},
"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 = \"Alzheimers_Disease\"\n",
"cohort = \"GSE167559\"\n",
"\n",
"# Input paths\n",
"in_trait_dir = \"../../input/GEO/Alzheimers_Disease\"\n",
"in_cohort_dir = \"../../input/GEO/Alzheimers_Disease/GSE167559\"\n",
"\n",
"# Output paths\n",
"out_data_file = \"../../output/preprocess/Alzheimers_Disease/GSE167559.csv\"\n",
"out_gene_data_file = \"../../output/preprocess/Alzheimers_Disease/gene_data/GSE167559.csv\"\n",
"out_clinical_data_file = \"../../output/preprocess/Alzheimers_Disease/clinical_data/GSE167559.csv\"\n",
"json_path = \"../../output/preprocess/Alzheimers_Disease/cohort_info.json\"\n"
]
},
{
"cell_type": "markdown",
"id": "564bf08f",
"metadata": {},
"source": [
"### Step 1: Initial Data Loading"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f281910e",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-25T06:27:09.038252Z",
"iopub.status.busy": "2025-03-25T06:27:09.038104Z",
"iopub.status.idle": "2025-03-25T06:27:09.078126Z",
"shell.execute_reply": "2025-03-25T06:27:09.077646Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Background Information:\n",
"!Series_title\t\"Dementia subtype prediction models constructed by penalized regression methods for multiclass classification using serum microRNA expression data\"\n",
"!Series_summary\t\"There are many subtypes of dementia, and identification of diagnostic biomarkers that are minimally-invasive, low-cost, and efficient is desired. Circulating microRNAs (miRNAs) have recently gained attention as easily accessible and non-invasive biomarkers. We conducted a comprehensive miRNA expression analysis of serum samples from 1348 Japanese dementia patients, composed of four subtypes—Alzheimer’s disease (AD), vascular dementia, dementia with Lewy bodies (DLB), and normal pressure hydrocephalus—and 246 control subjects. We used this data to construct dementia subtype prediction models based on penalized regression models with the multiclass classification. We constructed a final prediction model using 46 miRNAs, which classified dementia patients from an independent validation set into four subtypes of dementia. Network analysis of miRNA target genes revealed important hub genes, SRC and CHD3, associated with the AD pathogenesis. Moreover, MCU and CASP3, which are known to be associated with DLB pathogenesis, were identified from our DLB-specific target genes. Our study demonstrates the potential of blood-based biomarkers for use in dementia-subtype prediction models. We believe that further investigation using larger sample sizes will contribute to the accurate classification of subtypes of dementia.\"\n",
"!Series_overall_design\t\"Serum samples from 84 patients of normal pressure hydrocephalus (NPH)\"\n",
"Sample Characteristics Dictionary:\n",
"{0: ['tissue: serum'], 1: ['diagnosis: NPH'], 2: ['age: 83', 'age: 75', 'age: 87', 'age: 73', 'age: 79', 'age: 85', 'age: 69', 'age: 76', 'age: 88', 'age: 82', 'age: 80', 'age: 84', 'age: 71', 'age: 77', 'age: 81', 'age: 74', 'age: 86', 'age: 78', 'age: 65', 'age: 67', 'age: 70'], 3: ['Sex: male', 'Sex: female'], 4: ['apoe4: 0', 'apoe4: 2', 'apoe4: 1']}\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": "e87f1a12",
"metadata": {},
"source": [
"### Step 2: Dataset Analysis and Clinical Feature Extraction"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "03c23a8f",
"metadata": {
"execution": {
"iopub.execute_input": "2025-03-25T06:27:09.079713Z",
"iopub.status.busy": "2025-03-25T06:27:09.079607Z",
"iopub.status.idle": "2025-03-25T06:27:09.087656Z",
"shell.execute_reply": "2025-03-25T06:27:09.087232Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import os\n",
"import json\n",
"from typing import Optional, Callable, Dict, Any, List, Union\n",
"\n",
"# 1. Determine gene expression data availability\n",
"# This dataset contains microRNA expression data, not gene expression data\n",
"is_gene_available = False # miRNA data is not suitable for our gene expression analysis\n",
"\n",
"# 2. Check for variable availability and define conversion functions\n",
"\n",
"# 2.1 Trait (Alzheimer's Disease) data\n",
"# Looking at the sample characteristics, row 1 contains 'diagnosis: NPH'\n",
"# NPH stands for normal pressure hydrocephalus, which is not Alzheimer's Disease\n",
"# All samples are NPH, so this is a constant feature\n",
"trait_row = None # All samples are NPH patients, not AD patients\n",
"\n",
"# 2.2 Age data\n",
"# Row 2 contains age information\n",
"age_row = 2\n",
"\n",
"def convert_age(age_str: str) -> Optional[float]:\n",
" \"\"\"Convert age string to float.\"\"\"\n",
" if not age_str or not isinstance(age_str, str):\n",
" return None\n",
" try:\n",
" # Extract the value after the colon\n",
" if ':' in age_str:\n",
" age_value = age_str.split(':', 1)[1].strip()\n",
" return float(age_value)\n",
" else:\n",
" return float(age_str.strip())\n",
" except (ValueError, IndexError):\n",
" return None\n",
"\n",
"# 2.3 Gender data\n",
"# Row 3 contains gender information\n",
"gender_row = 3\n",
"\n",
"def convert_gender(gender_str: str) -> Optional[int]:\n",
" \"\"\"Convert gender string to binary (0 for female, 1 for male).\"\"\"\n",
" if not gender_str or not isinstance(gender_str, str):\n",
" return None\n",
" \n",
" # Extract the value after the colon\n",
" if ':' in gender_str:\n",
" gender_value = gender_str.split(':', 1)[1].strip().lower()\n",
" else:\n",
" gender_value = gender_str.strip().lower()\n",
" \n",
" if 'female' in gender_value:\n",
" return 0\n",
" elif 'male' in gender_value:\n",
" return 1\n",
" else:\n",
" return None\n",
"\n",
"# Trait conversion function (even though trait data is not available)\n",
"def convert_trait(trait_str: str) -> Optional[int]:\n",
" \"\"\"Convert trait string to binary (0 for control, 1 for AD).\"\"\"\n",
" if not trait_str or not isinstance(trait_str, str):\n",
" return None\n",
" \n",
" # Extract the value after the colon\n",
" if ':' in trait_str:\n",
" value = trait_str.split(':', 1)[1].strip().lower()\n",
" else:\n",
" value = trait_str.strip().lower()\n",
" \n",
" # In this dataset, all samples are NPH, not AD\n",
" if 'nph' in value:\n",
" return 0 # Not AD\n",
" elif 'ad' in value or 'alzheimer' in value:\n",
" return 1 # AD\n",
" else:\n",
" return None\n",
"\n",
"# 3. Save metadata about dataset usability\n",
"is_trait_available = trait_row is not None\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",
"# We skip this step since trait_row is None (clinical data for our trait is not available)\n",
"# This dataset contains only NPH patients, not AD patients"
]
}
],
"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
}
|