{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "ea3e037f", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:24.034125Z", "iopub.status.busy": "2025-03-25T08:07:24.033948Z", "iopub.status.idle": "2025-03-25T08:07:24.199488Z", "shell.execute_reply": "2025-03-25T08:07:24.199137Z" } }, "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 = \"Metabolic_Rate\"\n", "cohort = \"GSE40589\"\n", "\n", "# Input paths\n", "in_trait_dir = \"../../input/GEO/Metabolic_Rate\"\n", "in_cohort_dir = \"../../input/GEO/Metabolic_Rate/GSE40589\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Metabolic_Rate/GSE40589.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Metabolic_Rate/gene_data/GSE40589.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Metabolic_Rate/clinical_data/GSE40589.csv\"\n", "json_path = \"../../output/preprocess/Metabolic_Rate/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "833ec5df", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "9962a773", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:24.200889Z", "iopub.status.busy": "2025-03-25T08:07:24.200750Z", "iopub.status.idle": "2025-03-25T08:07:24.513119Z", "shell.execute_reply": "2025-03-25T08:07:24.512750Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Files in the directory:\n", "['GSE40589_family.soft.gz', 'GSE40589_series_matrix.txt.gz']\n", "SOFT file: ../../input/GEO/Metabolic_Rate/GSE40589/GSE40589_family.soft.gz\n", "Matrix file: ../../input/GEO/Metabolic_Rate/GSE40589/GSE40589_series_matrix.txt.gz\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Background Information:\n", "!Series_title\t\"Gene expression in human subcutaneous adipose tissue after administration of Gastric Insulinotropic Peptide (GIP)\"\n", "!Series_summary\t\"The intention of this clinical study was to investigate the effect of GIP administration for 240 min on gene expression in human subcutaneous adipose tissue. Three conditions have been tersted: 1. Sole infusion of GIP or NaCl as control; 2. GIP or NaCl administration under euglycemic-hyperinsulinemic clamp conditions; 3. GIP or NaCl administration under hyperglycemic-hyperinsulinemic clamp conditions to mimic the postprandial state.\"\n", "!Series_overall_design\t\"In each participant a complete physical examination and evaluation of medical history was performed, including an oral glucose tolerance test (oGTT) with 75 g glucose after overnight fast to ensure the metabolic state. Standard fasting laboratory and clinical chemistry evaluations were done. Synthetic human GIP (1-42) was dissolved in saline (0.9% NaCl-solution) under sterile conditions. All studies were done in the morning in the overnight fasted state (>10h since last meal). The effect of GIP administration on gene expression in subcutaneous adipose tissue was studied under 3 different conditions in a single blind design. Either the participants received only a GIP- or a saline- infusion (0.9% NaCl-isotonic solution, Fresenius, Germany) for 240 min. At different investigation days participants underwent euglycemic (EU)- and hyperglycemic (HC), hyperinsulinemic clamps combined with GIP- or placebo-infusions for 240 min at different examination days in a randomized, single-blind, crossover design. The capillary glucose concentration was 80mg/dl during EU-clamp and 140mg/dl during HC-clamp. The following numbers of treatments were performed: EU with GIP-infusion (N=9); EU with NaCl-infusion (N=9); HC with GIP-infusion (N=8), HC with NaCl-infusion (N=8); sole GIP-infusion (N=11) and sole placebo-infusion (N=11). Between examination days an intermission time of at least 7 days was maintained.\"\n", "Sample Characteristics Dictionary:\n", "{0: ['tissue: subcutaneous adipose tissue']}\n" ] } ], "source": [ "# 1. Check what files are actually in the directory\n", "import os\n", "print(\"Files in the directory:\")\n", "files = os.listdir(in_cohort_dir)\n", "print(files)\n", "\n", "# 2. Find appropriate files with more flexible pattern matching\n", "soft_file = None\n", "matrix_file = None\n", "\n", "for file in files:\n", " file_path = os.path.join(in_cohort_dir, file)\n", " # Look for files that might contain SOFT or matrix data with various possible extensions\n", " if 'soft' in file.lower() or 'family' in file.lower() or file.endswith('.soft.gz'):\n", " soft_file = file_path\n", " if 'matrix' in file.lower() or file.endswith('.txt.gz') or file.endswith('.tsv.gz'):\n", " matrix_file = file_path\n", "\n", "if not soft_file:\n", " print(\"Warning: Could not find a SOFT file. Using the first .gz file as fallback.\")\n", " gz_files = [f for f in files if f.endswith('.gz')]\n", " if gz_files:\n", " soft_file = os.path.join(in_cohort_dir, gz_files[0])\n", "\n", "if not matrix_file:\n", " print(\"Warning: Could not find a matrix file. Using the second .gz file as fallback if available.\")\n", " gz_files = [f for f in files if f.endswith('.gz')]\n", " if len(gz_files) > 1 and soft_file != os.path.join(in_cohort_dir, gz_files[1]):\n", " matrix_file = os.path.join(in_cohort_dir, gz_files[1])\n", " elif len(gz_files) == 1 and not soft_file:\n", " matrix_file = os.path.join(in_cohort_dir, gz_files[0])\n", "\n", "print(f\"SOFT file: {soft_file}\")\n", "print(f\"Matrix file: {matrix_file}\")\n", "\n", "# 3. Read files if found\n", "if soft_file and matrix_file:\n", " # 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", " \n", " try:\n", " background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)\n", " \n", " # Obtain the sample characteristics dictionary from the clinical dataframe\n", " sample_characteristics_dict = get_unique_values_by_row(clinical_data)\n", " \n", " # 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", " except Exception as e:\n", " print(f\"Error processing files: {e}\")\n", " # Try swapping files if first attempt fails\n", " print(\"Trying to swap SOFT and matrix files...\")\n", " temp = soft_file\n", " soft_file = matrix_file\n", " matrix_file = temp\n", " try:\n", " background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)\n", " sample_characteristics_dict = get_unique_values_by_row(clinical_data)\n", " print(\"Background Information:\")\n", " print(background_info)\n", " print(\"Sample Characteristics Dictionary:\")\n", " print(sample_characteristics_dict)\n", " except Exception as e:\n", " print(f\"Still error after swapping: {e}\")\n", "else:\n", " print(\"Could not find necessary files for processing.\")\n" ] }, { "cell_type": "markdown", "id": "40e07722", "metadata": {}, "source": [ "### Step 2: Dataset Analysis and Clinical Feature Extraction" ] }, { "cell_type": "code", "execution_count": 3, "id": "b6ef62f2", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:24.514547Z", "iopub.status.busy": "2025-03-25T08:07:24.514437Z", "iopub.status.idle": "2025-03-25T08:07:24.521372Z", "shell.execute_reply": "2025-03-25T08:07:24.521097Z" } }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "import os\n", "import numpy as np\n", "from typing import Optional, Callable, Dict, Any\n", "import json\n", "import re\n", "\n", "# 1. Gene Expression Data Availability\n", "# From the background information, this dataset involves gene expression in human subcutaneous adipose tissue\n", "is_gene_available = True\n", "\n", "# 2. Variable Availability and Data Type Conversion\n", "# 2.1 Data Availability\n", "# Looking at the sample characteristics dictionary, we don't see trait (metabolic rate)\n", "# specific data in the limited information provided.\n", "# While the study is about metabolic effects, there's no explicit measurement of metabolic rate\n", "# in the available sample characteristics\n", "trait_row = None\n", "age_row = None\n", "gender_row = None\n", "\n", "# 2.2 Data Type Conversion\n", "def convert_trait(value: str) -> Optional[float]:\n", " if value is None or pd.isna(value):\n", " return None\n", " \n", " # Extract the value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip().lower()\n", " \n", " # Based on the study design, different conditions represent different metabolic states\n", " # But we don't have access to this information in the current sample characteristics\n", " return None\n", "\n", "def convert_age(value: str) -> Optional[float]:\n", " if value is None or pd.isna(value):\n", " return None\n", " \n", " # Extract the value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip()\n", " \n", " # Try to convert to float\n", " try:\n", " return float(value)\n", " except (ValueError, TypeError):\n", " return None\n", "\n", "def convert_gender(value: str) -> Optional[int]:\n", " if value is None or pd.isna(value):\n", " return None\n", " \n", " # Extract the value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip().lower()\n", " \n", " # Convert to binary (0 for female, 1 for male)\n", " if 'female' in value or 'f' == value:\n", " return 0\n", " elif 'male' in value or 'm' == value:\n", " return 1\n", " else:\n", " return None\n", "\n", "# 3. Save Metadata\n", "# Determine trait availability\n", "is_trait_available = trait_row is not None\n", "\n", "# Save cohort info\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_row is None (no clinical data available for trait)\n", "# We're not attempting to read from a file as the necessary data is not available\n" ] }, { "cell_type": "markdown", "id": "7eb4fe1a", "metadata": {}, "source": [ "### Step 3: Gene Data Extraction" ] }, { "cell_type": "code", "execution_count": 4, "id": "53614701", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:24.522725Z", "iopub.status.busy": "2025-03-25T08:07:24.522619Z", "iopub.status.idle": "2025-03-25T08:07:24.963407Z", "shell.execute_reply": "2025-03-25T08:07:24.963016Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This appears to be a SuperSeries. Looking at the SOFT file to find potential subseries:\n", "No subseries references found in the first 1000 lines of the SOFT file.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Gene data extraction result:\n", "Number of rows: 41000\n", "First 20 gene/probe identifiers:\n", "Index(['A_23_P100001', 'A_23_P100011', 'A_23_P100022', 'A_23_P100056',\n", " 'A_23_P100074', 'A_23_P100092', 'A_23_P100103', 'A_23_P100111',\n", " 'A_23_P100127', 'A_23_P100133', 'A_23_P100141', 'A_23_P100156',\n", " 'A_23_P100177', 'A_23_P100189', 'A_23_P100196', 'A_23_P100203',\n", " 'A_23_P100220', 'A_23_P100240', 'A_23_P10025', 'A_23_P100263'],\n", " dtype='object', name='ID')\n" ] } ], "source": [ "# 1. First get the path to the soft and matrix files\n", "soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)\n", "\n", "# 2. Looking more carefully at the background information\n", "# This is a SuperSeries which doesn't contain direct gene expression data\n", "# Need to investigate the soft file to find the subseries\n", "print(\"This appears to be a SuperSeries. Looking at the SOFT file to find potential subseries:\")\n", "\n", "# Open the SOFT file to try to identify subseries\n", "with gzip.open(soft_file, 'rt') as f:\n", " subseries_lines = []\n", " for i, line in enumerate(f):\n", " if 'Series_relation' in line and 'SuperSeries of' in line:\n", " subseries_lines.append(line.strip())\n", " if i > 1000: # Limit search to first 1000 lines\n", " break\n", "\n", "# Display the subseries found\n", "if subseries_lines:\n", " print(\"Found potential subseries references:\")\n", " for line in subseries_lines:\n", " print(line)\n", "else:\n", " print(\"No subseries references found in the first 1000 lines of the SOFT file.\")\n", "\n", "# Despite trying to extract gene data, we expect it might fail because this is a SuperSeries\n", "try:\n", " gene_data = get_genetic_data(matrix_file)\n", " print(\"\\nGene data extraction result:\")\n", " print(\"Number of rows:\", len(gene_data))\n", " print(\"First 20 gene/probe identifiers:\")\n", " print(gene_data.index[:20])\n", "except Exception as e:\n", " print(f\"Error extracting gene data: {e}\")\n", " print(\"This confirms the dataset is a SuperSeries without direct gene expression data.\")\n" ] }, { "cell_type": "markdown", "id": "f42ecbff", "metadata": {}, "source": [ "### Step 4: Gene Identifier Review" ] }, { "cell_type": "code", "execution_count": 5, "id": "85c9b7b4", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:24.965111Z", "iopub.status.busy": "2025-03-25T08:07:24.964982Z", "iopub.status.idle": "2025-03-25T08:07:24.966971Z", "shell.execute_reply": "2025-03-25T08:07:24.966683Z" } }, "outputs": [], "source": [ "# Analyzing the gene identifiers from the previous step\n", "# These identifiers (like 'A_23_P100001') appear to be probe IDs from an Agilent microarray platform,\n", "# not standard human gene symbols.\n", "# Agilent probe IDs follow this pattern where A_23_P refers to the platform and the numbers identify specific probes.\n", "# These need to be mapped to actual gene symbols for biological interpretation.\n", "\n", "requires_gene_mapping = True\n" ] }, { "cell_type": "markdown", "id": "247a2965", "metadata": {}, "source": [ "### Step 5: Gene Annotation" ] }, { "cell_type": "code", "execution_count": 6, "id": "046033ec", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:24.968659Z", "iopub.status.busy": "2025-03-25T08:07:24.968543Z", "iopub.status.idle": "2025-03-25T08:07:31.474517Z", "shell.execute_reply": "2025-03-25T08:07:31.473902Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gene annotation preview:\n", "{'ID': ['A_23_P100001', 'A_23_P100011', 'A_23_P100022', 'A_23_P100056', 'A_23_P100074'], 'SPOT_ID': ['A_23_P100001', 'A_23_P100011', 'A_23_P100022', 'A_23_P100056', 'A_23_P100074'], 'CONTROL_TYPE': ['FALSE', 'FALSE', 'FALSE', 'FALSE', 'FALSE'], 'REFSEQ': ['NM_207446', 'NM_005829', 'NM_014848', 'NM_194272', 'NM_020371'], 'GB_ACC': ['NM_207446', 'NM_005829', 'NM_014848', 'NM_194272', 'NM_020371'], 'GENE': [400451.0, 10239.0, 9899.0, 348093.0, 57099.0], 'GENE_SYMBOL': ['FAM174B', 'AP3S2', 'SV2B', 'RBPMS2', 'AVEN'], 'GENE_NAME': ['family with sequence similarity 174, member B', 'adaptor-related protein complex 3, sigma 2 subunit', 'synaptic vesicle glycoprotein 2B', 'RNA binding protein with multiple splicing 2', 'apoptosis, caspase activation inhibitor'], 'UNIGENE_ID': ['Hs.27373', 'Hs.632161', 'Hs.21754', 'Hs.436518', 'Hs.555966'], 'ENSEMBL_ID': ['ENST00000557398', nan, 'ENST00000557410', 'ENST00000300069', 'ENST00000306730'], 'TIGR_ID': [nan, nan, nan, nan, nan], 'ACCESSION_STRING': ['ref|NM_207446|ens|ENST00000557398|ens|ENST00000553393|ens|ENST00000327355', 'ref|NM_005829|ref|NM_001199058|ref|NR_023361|ref|NR_037582', 'ref|NM_014848|ref|NM_001167580|ens|ENST00000557410|ens|ENST00000330276', 'ref|NM_194272|ens|ENST00000300069|gb|AK127873|gb|AK124123', 'ref|NM_020371|ens|ENST00000306730|gb|AF283508|gb|BC010488'], 'CHROMOSOMAL_LOCATION': ['chr15:93160848-93160789', 'chr15:90378743-90378684', 'chr15:91838329-91838388', 'chr15:65032375-65032316', 'chr15:34158739-34158680'], 'CYTOBAND': ['hs|15q26.1', 'hs|15q26.1', 'hs|15q26.1', 'hs|15q22.31', 'hs|15q14'], 'DESCRIPTION': ['Homo sapiens family with sequence similarity 174, member B (FAM174B), mRNA [NM_207446]', 'Homo sapiens adaptor-related protein complex 3, sigma 2 subunit (AP3S2), transcript variant 1, mRNA [NM_005829]', 'Homo sapiens synaptic vesicle glycoprotein 2B (SV2B), transcript variant 1, mRNA [NM_014848]', 'Homo sapiens RNA binding protein with multiple splicing 2 (RBPMS2), mRNA [NM_194272]', 'Homo sapiens apoptosis, caspase activation inhibitor (AVEN), mRNA [NM_020371]'], 'GO_ID': ['GO:0016020(membrane)|GO:0016021(integral to membrane)', 'GO:0005794(Golgi apparatus)|GO:0006886(intracellular protein transport)|GO:0008565(protein transporter activity)|GO:0016020(membrane)|GO:0016192(vesicle-mediated transport)|GO:0030117(membrane coat)|GO:0030659(cytoplasmic vesicle membrane)|GO:0031410(cytoplasmic vesicle)', 'GO:0001669(acrosomal vesicle)|GO:0006836(neurotransmitter transport)|GO:0016020(membrane)|GO:0016021(integral to membrane)|GO:0022857(transmembrane transporter activity)|GO:0030054(cell junction)|GO:0030672(synaptic vesicle membrane)|GO:0031410(cytoplasmic vesicle)|GO:0045202(synapse)', 'GO:0000166(nucleotide binding)|GO:0003676(nucleic acid binding)', 'GO:0005515(protein binding)|GO:0005622(intracellular)|GO:0005624(membrane fraction)|GO:0006915(apoptosis)|GO:0006916(anti-apoptosis)|GO:0012505(endomembrane system)|GO:0016020(membrane)'], 'SEQUENCE': ['ATCTCATGGAAAAGCTGGATTCCTCTGCCTTACGCAGAAACACCCGGGCTCCATCTGCCA', 'TCAAGTATTGGCCTGACATAGAGTCCTTAAGACAAGCAAAGACAAGCAAGGCAAGCACGT', 'ATGTCGGCTGTGGAGGGTTAAAGGGATGAGGCTTTCCTTTGTTTAGCAAATCTGTTCACA', 'CCCTGTCAGATAAGTTTAATGTTTAGTTTGAGGCATGAAGAAGAAAAGGGTTTCCATTCT', 'GACCAGCCAGTTTACAAGCATGTCTCAAGCTAGTGTGTTCCATTATGCTCACAGCAGTAA']}\n" ] } ], "source": [ "# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.\n", "gene_annotation = get_gene_annotation(soft_file)\n", "\n", "# 2. Use the 'preview_df' function from the library to preview the data and print out the results.\n", "print(\"Gene annotation preview:\")\n", "print(preview_df(gene_annotation))\n" ] }, { "cell_type": "markdown", "id": "e3ba9946", "metadata": {}, "source": [ "### Step 6: Gene Identifier Mapping" ] }, { "cell_type": "code", "execution_count": 7, "id": "eeb183af", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:31.475896Z", "iopub.status.busy": "2025-03-25T08:07:31.475773Z", "iopub.status.idle": "2025-03-25T08:07:31.762587Z", "shell.execute_reply": "2025-03-25T08:07:31.761954Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Mapping information:\n", "Number of unique probes in mapping: 30936\n", "Number of unique genes mapped to: 18488\n", "\n", "First 10 gene symbols after mapping:\n", "Index(['A1BG', 'A1BG-AS1', 'A1CF', 'A2LD1', 'A2M', 'A2ML1', 'A4GALT', 'A4GNT',\n", " 'AAAS', 'AACS'],\n", " dtype='object', name='Gene')\n" ] } ], "source": [ "# 1. Identify the columns corresponding to gene identifiers and gene symbols in the annotation\n", "# From the preview, 'ID' contains the probe identifiers which match the gene expression data indices\n", "# 'GENE_SYMBOL' contains the human gene symbols we want to map to\n", "prob_col = 'ID'\n", "gene_col = 'GENE_SYMBOL'\n", "\n", "# 2. Get the gene mapping dataframe using the function from the library\n", "mapping_df = get_gene_mapping(gene_annotation, prob_col, gene_col)\n", "\n", "# 3. Convert probe-level measurements to gene expression data by applying the gene mapping\n", "gene_data = apply_gene_mapping(gene_data, mapping_df)\n", "\n", "# Print some information about the result\n", "print(\"\\nMapping information:\")\n", "print(f\"Number of unique probes in mapping: {len(mapping_df['ID'].unique())}\")\n", "print(f\"Number of unique genes mapped to: {len(gene_data.index)}\")\n", "print(\"\\nFirst 10 gene symbols after mapping:\")\n", "print(gene_data.index[:10])\n" ] }, { "cell_type": "markdown", "id": "9fbd0833", "metadata": {}, "source": [ "### Step 7: Data Normalization and Linking" ] }, { "cell_type": "code", "execution_count": 8, "id": "abc72a90", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T08:07:31.763949Z", "iopub.status.busy": "2025-03-25T08:07:31.763824Z", "iopub.status.idle": "2025-03-25T08:07:33.064896Z", "shell.execute_reply": "2025-03-25T08:07:33.064295Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Shape of gene data after normalization: (18247, 96)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Saved normalized gene data to ../../output/preprocess/Metabolic_Rate/gene_data/GSE40589.csv\n", "Sample characteristics dictionary:\n", "{0: ['tissue: subcutaneous adipose tissue']}\n", "No clinical data found for Metabolic_Rate in this dataset.\n", "Abnormality detected in the cohort: GSE40589. Preprocessing failed.\n", "Dataset validation completed. Gene data saved, but no clinical or linked data available for this trait.\n" ] } ], "source": [ "# 1. Normalize gene symbols in the gene expression data\n", "gene_data_normalized = normalize_gene_symbols_in_index(gene_data)\n", "print(f\"Shape of gene data after normalization: {gene_data_normalized.shape}\")\n", "os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)\n", "gene_data_normalized.to_csv(out_gene_data_file)\n", "print(f\"Saved normalized gene data to {out_gene_data_file}\")\n", "\n", "# 2. Re-examine the clinical data from the matrix file\n", "soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)\n", "background_info, clinical_data = get_background_and_clinical_data(matrix_file)\n", "\n", "# Print out the sample characteristics to verify available rows\n", "characteristics_dict = get_unique_values_by_row(clinical_data)\n", "print(\"Sample characteristics dictionary:\")\n", "print(characteristics_dict)\n", "\n", "# From the examination of the sample characteristics, we can see that:\n", "# - There is no metabolic rate data available\n", "# - The only feature is \"tissue: subcutaneous adipose tissue\" which is constant\n", "\n", "# Create an empty DataFrame for clinical data since no relevant trait data exists\n", "clinical_df = pd.DataFrame()\n", "\n", "# Save the gene data as it's the only usable component\n", "print(\"No clinical data found for Metabolic_Rate in this dataset.\")\n", "\n", "# Since we don't have trait data, we can't link the clinical and genetic data\n", "# We'll create an empty DataFrame for linked_data\n", "linked_data = pd.DataFrame()\n", "\n", "# 5. Validate the dataset and save cohort information\n", "note = \"Dataset contains gene expression data from subcutaneous adipose tissue but lacks metabolic rate measurements. The study examines GIP administration effects on gene expression under different conditions, but no direct metabolic rate measurements are available.\"\n", "\n", "# Create an empty DataFrame for final validation\n", "empty_df = pd.DataFrame()\n", "\n", "# Validate and save cohort info with is_trait_available=False\n", "is_usable = validate_and_save_cohort_info(\n", " is_final=True,\n", " cohort=cohort,\n", " info_path=json_path,\n", " is_gene_available=True,\n", " is_trait_available=False,\n", " is_biased=False, # Set to False since we can't evaluate bias without trait data\n", " df=empty_df,\n", " note=note\n", ")\n", "\n", "print(\"Dataset validation completed. Gene data saved, but no clinical or linked data available for this trait.\")" ] } ], "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 }