{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "78194e4e", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:41.737606Z", "iopub.status.busy": "2025-03-25T05:52:41.737491Z", "iopub.status.idle": "2025-03-25T05:52:41.898381Z", "shell.execute_reply": "2025-03-25T05:52:41.898024Z" } }, "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 = \"Mitochondrial_Disorders\"\n", "cohort = \"GSE65399\"\n", "\n", "# Input paths\n", "in_trait_dir = \"../../input/GEO/Mitochondrial_Disorders\"\n", "in_cohort_dir = \"../../input/GEO/Mitochondrial_Disorders/GSE65399\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Mitochondrial_Disorders/GSE65399.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Mitochondrial_Disorders/gene_data/GSE65399.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Mitochondrial_Disorders/clinical_data/GSE65399.csv\"\n", "json_path = \"../../output/preprocess/Mitochondrial_Disorders/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "f6a33286", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "d4d598ae", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:41.899864Z", "iopub.status.busy": "2025-03-25T05:52:41.899723Z", "iopub.status.idle": "2025-03-25T05:52:42.146735Z", "shell.execute_reply": "2025-03-25T05:52:42.146430Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Files in the directory:\n", "['GSE65399_family.soft.gz', 'GSE65399_series_matrix.txt.gz']\n", "SOFT file: ../../input/GEO/Mitochondrial_Disorders/GSE65399/GSE65399_family.soft.gz\n", "Matrix file: ../../input/GEO/Mitochondrial_Disorders/GSE65399/GSE65399_series_matrix.txt.gz\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Background Information:\n", "!Series_title\t\"Epigenetic therapy for Friedreich ataxia.\"\n", "!Series_summary\t\"We set out to investigate whether a histone deacetylase inhibitor (HDACi) would be effective in an in vitro model for the neurodegenerative disease Friedreich ataxia (FRDA) and to evaluate safety and surrogate markers of efficacy in a phase I clinical trial in patients. In the neuronal cell model, HDACi 109/RG2833 increases FXN mRNA levels and frataxin protein, with concomitant changes in the epigenetic state of the gene. Chromatin signatures indicate that histone H3 lysine 9 is a key residue for gene silencing through methylation and reactivation through acetylation, mediated by the HDACi. Drug treatment in FRDA patients demonstrated increased FXN mRNA and H3 lysine 9 acetylation in peripheral blood mononuclear cells. No safety issues were encountered.\"\n", "!Series_overall_design\t\"We used a human FRDA neuronal cell model, derived from patient induced pluripotent stem cells, to determine the efficacy of a 2-aminobenzamide HDACi (109) as a modulator of FXN gene expression and chromatin histone modifications. FRDA patients were dosed in 4 cohorts, ranging from 30mg/day to 240mg/day of the formulated drug product of HDACi 109, RG2833. Patients were monitored for adverse effects as well as for increases in FXN mRNA, frataxin protein, and chromatin modification in blood cells. Gene expression profiles were obtained using the Illumina HT12v4 Gene Expression BeadArray.\"\n", "Sample Characteristics Dictionary:\n", "{0: ['differentiation or tissue type: neural progenitors', 'differentiation or tissue type: brain fetal', 'differentiation or tissue type: undifferentiated', 'differentiation or tissue type: heart fetal', 'differentiation or tissue type: kidney fetal', 'differentiation or tissue type: liver fetal', 'differentiation or tissue type: lung fetal', 'differentiation or tissue type: pancreas fetal', 'differentiation or tissue type: small intestine fetal', 'differentiation or tissue type: stomach fetal', 'differentiation or tissue type: thymus fetal', 'differentiation or tissue type: adrenal fetal', 'differentiation or tissue type: spleen fetal'], 1: ['time point: d24', 'time point: 20wk', nan, 'time point: 18wk', 'time point: 17wk', 'time point: 10wk', 'time point: 15wk', 'time point: 14wk', 'time point: 19wk', 'time point: 8wk', 'time point: 21wk']}\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": "7b1ba5b6", "metadata": {}, "source": [ "### Step 2: Dataset Analysis and Clinical Feature Extraction" ] }, { "cell_type": "code", "execution_count": 3, "id": "73bf3586", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:42.148041Z", "iopub.status.busy": "2025-03-25T05:52:42.147920Z", "iopub.status.idle": "2025-03-25T05:52:42.154029Z", "shell.execute_reply": "2025-03-25T05:52:42.153738Z" } }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 1. Gene Expression Data Availability\n", "# Based on the series overall design and background information, it's clear this dataset contains gene expression data\n", "# from the Illumina HT12v4 Gene Expression BeadArray\n", "is_gene_available = True\n", "\n", "# 2. Variable Availability and Data Type Conversion\n", "# Looking at the sample characteristics dictionary:\n", "\n", "# 2.1 Data Availability\n", "# For trait: This is a study on Friedreich ataxia (FRDA), but there's no explicit information \n", "# about which samples have FRDA vs controls in the sample characteristics\n", "trait_row = None # No evident trait classification in sample characteristics\n", "\n", "# For age: No age information is available in sample characteristics\n", "age_row = None\n", "\n", "# For gender: No gender information is available in sample characteristics\n", "gender_row = None\n", "\n", "# 2.2 Data Type Conversion\n", "# Since we don't have trait, age, or gender data, we'll define placeholder conversion functions\n", "def convert_trait(value):\n", " \"\"\"Convert trait values to binary: 1 for FRDA, 0 for control.\"\"\"\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", " # This is a placeholder since we don't have trait data\n", " return None\n", "\n", "def convert_age(value):\n", " \"\"\"Convert age values to continuous numerical values.\"\"\"\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", " # This is a placeholder since we don't have age data\n", " return None\n", "\n", "def convert_gender(value):\n", " \"\"\"Convert gender values to binary: 0 for female, 1 for male.\"\"\"\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", " # This is a placeholder since we don't have gender data\n", " return None\n", "\n", "# 3. Save Metadata\n", "# We have gene expression data but no trait information for classification\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", "# Since trait_row is None, we skip this substep\n" ] }, { "cell_type": "markdown", "id": "8407421a", "metadata": {}, "source": [ "### Step 3: Gene Data Extraction" ] }, { "cell_type": "code", "execution_count": 4, "id": "79082cd3", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:42.155949Z", "iopub.status.busy": "2025-03-25T05:52:42.155844Z", "iopub.status.idle": "2025-03-25T05:52:42.589277Z", "shell.execute_reply": "2025-03-25T05:52:42.588884Z" } }, "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: 47323\n", "First 20 gene/probe identifiers:\n", "Index(['ILMN_1343291', 'ILMN_1343295', 'ILMN_1651199', 'ILMN_1651209',\n", " 'ILMN_1651210', 'ILMN_1651221', 'ILMN_1651228', 'ILMN_1651229',\n", " 'ILMN_1651230', 'ILMN_1651232', 'ILMN_1651235', 'ILMN_1651236',\n", " 'ILMN_1651237', 'ILMN_1651238', 'ILMN_1651249', 'ILMN_1651253',\n", " 'ILMN_1651254', 'ILMN_1651259', 'ILMN_1651260', 'ILMN_1651262'],\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": "7ec7f5a2", "metadata": {}, "source": [ "### Step 4: Gene Identifier Review" ] }, { "cell_type": "code", "execution_count": 5, "id": "af91c970", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:42.591060Z", "iopub.status.busy": "2025-03-25T05:52:42.590898Z", "iopub.status.idle": "2025-03-25T05:52:42.593066Z", "shell.execute_reply": "2025-03-25T05:52:42.592772Z" } }, "outputs": [], "source": [ "# The identifiers start with \"ILMN_\" which indicates they are Illumina BeadArray probe IDs\n", "# These are not human gene symbols but microarray probe identifiers that need to be mapped to gene symbols\n", "\n", "requires_gene_mapping = True\n" ] }, { "cell_type": "markdown", "id": "9935cf35", "metadata": {}, "source": [ "### Step 5: Gene Annotation" ] }, { "cell_type": "code", "execution_count": 6, "id": "2b652ab8", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:42.594750Z", "iopub.status.busy": "2025-03-25T05:52:42.594636Z", "iopub.status.idle": "2025-03-25T05:52:51.013445Z", "shell.execute_reply": "2025-03-25T05:52:51.012811Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gene annotation preview:\n", "{'ID': ['ILMN_1343048', 'ILMN_1343049', 'ILMN_1343050', 'ILMN_1343052', 'ILMN_1343059'], 'Species': [nan, nan, nan, nan, nan], 'Source': [nan, nan, nan, nan, nan], 'Search_Key': [nan, nan, nan, nan, nan], 'Transcript': [nan, nan, nan, nan, nan], 'ILMN_Gene': [nan, nan, nan, nan, nan], 'Source_Reference_ID': [nan, nan, nan, nan, nan], 'RefSeq_ID': [nan, nan, nan, nan, nan], 'Unigene_ID': [nan, nan, nan, nan, nan], 'Entrez_Gene_ID': [nan, nan, nan, nan, nan], 'GI': [nan, nan, nan, nan, nan], 'Accession': [nan, nan, nan, nan, nan], 'Symbol': ['phage_lambda_genome', 'phage_lambda_genome', 'phage_lambda_genome:low', 'phage_lambda_genome:low', 'thrB'], 'Protein_Product': [nan, nan, nan, nan, 'thrB'], 'Probe_Id': [nan, nan, nan, nan, nan], 'Array_Address_Id': [5090180.0, 6510136.0, 7560739.0, 1450438.0, 1240647.0], 'Probe_Type': [nan, nan, nan, nan, nan], 'Probe_Start': [nan, nan, nan, nan, nan], 'SEQUENCE': ['GAATAAAGAACAATCTGCTGATGATCCCTCCGTGGATCTGATTCGTGTAA', 'CCATGTGATACGAGGGCGCGTAGTTTGCATTATCGTTTTTATCGTTTCAA', 'CCGACAGATGTATGTAAGGCCAACGTGCTCAAATCTTCATACAGAAAGAT', 'TCTGTCACTGTCAGGAAAGTGGTAAAACTGCAACTCAATTACTGCAATGC', 'CTTGTGCCTGAGCTGTCAAAAGTAGAGCACGTCGCCGAGATGAAGGGCGC'], 'Chromosome': [nan, nan, nan, nan, nan], 'Probe_Chr_Orientation': [nan, nan, nan, nan, nan], 'Probe_Coordinates': [nan, nan, nan, nan, nan], 'Cytoband': [nan, nan, nan, nan, nan], 'Definition': [nan, nan, nan, nan, nan], 'Ontology_Component': [nan, nan, nan, nan, nan], 'Ontology_Process': [nan, nan, nan, nan, nan], 'Ontology_Function': [nan, nan, nan, nan, nan], 'Synonyms': [nan, nan, nan, nan, nan], 'Obsolete_Probe_Id': [nan, nan, nan, nan, nan], 'GB_ACC': [nan, nan, nan, nan, nan]}\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": "09459632", "metadata": {}, "source": [ "### Step 6: Gene Identifier Mapping" ] }, { "cell_type": "code", "execution_count": 7, "id": "5a677ee6", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:51.014810Z", "iopub.status.busy": "2025-03-25T05:52:51.014687Z", "iopub.status.idle": "2025-03-25T05:52:52.270550Z", "shell.execute_reply": "2025-03-25T05:52:52.270025Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using 'ID' column for probe identifiers and 'Symbol' column for gene symbols\n", "Gene mapping dataframe shape: (44837, 2)\n", "First few rows of gene mapping:\n", " ID Gene\n", "0 ILMN_1343048 phage_lambda_genome\n", "1 ILMN_1343049 phage_lambda_genome\n", "2 ILMN_1343050 phage_lambda_genome:low\n", "3 ILMN_1343052 phage_lambda_genome:low\n", "4 ILMN_1343059 thrB\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Converted gene expression dataframe shape: (21464, 75)\n", "First few gene symbols:\n", "Index(['A1BG', 'A1CF', 'A26C3', 'A2BP1', 'A2LD1', 'A2M', 'A2ML1', 'A3GALT2',\n", " 'A4GALT', 'A4GNT'],\n", " dtype='object', name='Gene')\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gene expression data saved to ../../output/preprocess/Mitochondrial_Disorders/gene_data/GSE65399.csv\n" ] } ], "source": [ "# 1. Identify the appropriate columns from the gene annotation\n", "# From the preview, we can see that 'ID' contains the probe identifiers (ILMN_*) \n", "# and 'Symbol' contains the gene symbols\n", "prob_col = 'ID'\n", "gene_col = 'Symbol'\n", "\n", "print(f\"Using '{prob_col}' column for probe identifiers and '{gene_col}' column for gene symbols\")\n", "\n", "# 2. Get the mapping dataframe with the selected columns\n", "gene_mapping = get_gene_mapping(gene_annotation, prob_col, gene_col)\n", "print(f\"Gene mapping dataframe shape: {gene_mapping.shape}\")\n", "print(\"First few rows of gene mapping:\")\n", "print(gene_mapping.head())\n", "\n", "# 3. Convert probe-level measurements to gene-level expression data\n", "gene_data = apply_gene_mapping(gene_data, gene_mapping)\n", "print(f\"Converted gene expression dataframe shape: {gene_data.shape}\")\n", "print(\"First few gene symbols:\")\n", "print(gene_data.index[:10])\n", "\n", "# Save the gene expression data to the specified output file\n", "# Create the directory if it doesn't exist\n", "os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)\n", "gene_data.to_csv(out_gene_data_file)\n", "print(f\"Gene expression data saved to {out_gene_data_file}\")\n" ] }, { "cell_type": "markdown", "id": "533a8ac0", "metadata": {}, "source": [ "### Step 7: Data Normalization and Linking" ] }, { "cell_type": "code", "execution_count": 8, "id": "eee00fa9", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T05:52:52.271893Z", "iopub.status.busy": "2025-03-25T05:52:52.271773Z", "iopub.status.idle": "2025-03-25T05:52:53.493666Z", "shell.execute_reply": "2025-03-25T05:52:53.493146Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Shape of gene data after normalization: (20259, 75)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Saved normalized gene data to ../../output/preprocess/Mitochondrial_Disorders/gene_data/GSE65399.csv\n", "Sample characteristics dictionary:\n", "{0: ['differentiation or tissue type: neural progenitors', 'differentiation or tissue type: brain fetal', 'differentiation or tissue type: undifferentiated', 'differentiation or tissue type: heart fetal', 'differentiation or tissue type: kidney fetal', 'differentiation or tissue type: liver fetal', 'differentiation or tissue type: lung fetal', 'differentiation or tissue type: pancreas fetal', 'differentiation or tissue type: small intestine fetal', 'differentiation or tissue type: stomach fetal', 'differentiation or tissue type: thymus fetal', 'differentiation or tissue type: adrenal fetal', 'differentiation or tissue type: spleen fetal'], 1: ['time point: d24', 'time point: 20wk', nan, 'time point: 18wk', 'time point: 17wk', 'time point: 10wk', 'time point: 15wk', 'time point: 14wk', 'time point: 19wk', 'time point: 8wk', 'time point: 21wk']}\n", "No trait information found that relates to Mitochondrial_Disorders in this dataset.\n", "Abnormality detected in the cohort: GSE65399. Preprocessing failed.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Dataset validation complete. Gene data was saved, but no linked data was created due to missing trait information.\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", "# Based on the sample characteristics, there's no clear trait information related to Mitochondrial_Disorders\n", "# The data only contains tissue types and time points, not disease state or case/control information\n", "print(\"No trait information found that relates to Mitochondrial_Disorders in this dataset.\")\n", "\n", "# Since no trait information is available, we'll skip the clinical data processing\n", "# and only save the gene expression data\n", "# Create a minimal DataFrame with proper structure for validation\n", "empty_df = pd.DataFrame({'placeholder': [0]})\n", "\n", "# 5. Validate the dataset and save cohort information\n", "note = \"Dataset contains gene expression data from Friedreich ataxia study but lacks clear trait information for \" + \\\n", " \"classification of samples regarding Mitochondrial_Disorders. The sample characteristics only contain \" + \\\n", " \"tissue types and time points.\"\n", "\n", "# Final validation with appropriate parameters\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=True, # Indicating dataset is biased (no variation in trait)\n", " df=empty_df,\n", " note=note\n", ")\n", "\n", "print(\"Dataset validation complete. Gene data was saved, but no linked data was created due to missing trait information.\")" ] } ], "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 }