{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "e27392b4", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:14.352718Z", "iopub.status.busy": "2025-03-25T07:27:14.352615Z", "iopub.status.idle": "2025-03-25T07:27:14.510327Z", "shell.execute_reply": "2025-03-25T07:27:14.510016Z" } }, "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 = \"Large_B-cell_Lymphoma\"\n", "cohort = \"GSE248835\"\n", "\n", "# Input paths\n", "in_trait_dir = \"../../input/GEO/Large_B-cell_Lymphoma\"\n", "in_cohort_dir = \"../../input/GEO/Large_B-cell_Lymphoma/GSE248835\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Large_B-cell_Lymphoma/GSE248835.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Large_B-cell_Lymphoma/gene_data/GSE248835.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Large_B-cell_Lymphoma/clinical_data/GSE248835.csv\"\n", "json_path = \"../../output/preprocess/Large_B-cell_Lymphoma/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "31b9f82f", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "38ab8751", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:14.511743Z", "iopub.status.busy": "2025-03-25T07:27:14.511608Z", "iopub.status.idle": "2025-03-25T07:27:14.543042Z", "shell.execute_reply": "2025-03-25T07:27:14.542774Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Background Information:\n", "!Series_title\t\"Impact of Tumor Microenvironment on Efficacy of CD19 CAR T-Cell Therapy or Chemotherapy and Transplant in Large B-Cell Lymphoma\"\n", "!Series_summary\t\"The phase 3 ZUMA-7 trial in second-line large B-cell lymphoma demonstrated superiority of anti-CD19 CAR T-cell therapy (axicabtagene ciloleucel; axi-cel) over standard of care (SOC; salvage chemotherapy followed by hematopoietic transplantation). Here, we present a prespecified exploratory analysis examining the association between pretreatment tumor characteristics and the efficacy of axi-cel versus SOC. B-cell gene expression signature (GES) and CD19 expression significantly associated with improved event-free survival (EFS) for axi-cel (P=.0002 for B-cell GES; P=.0165 for CD19 expression) but not SOC (P=.9374 for B-cell GES; P=.5526 for CD19 expression). Axi-cel showed superior EFS over SOC irrespective of B-cell GES and CD19 expression (P=8.56e–9 for B-cell GES high; P=.0019 for B-cell GES low; P=3.85e–9 for CD19 gene high; P=.0017 for CD19 gene low). Low CD19 expression in malignant cells correlated with a tumor GES consisting of immune suppressive stromal and myeloid genes, highlighting the inter-relation between malignant cell features and immune contexture substantially impacting axi-cel outcomes. Tumor burden, lactate dehydrogenase, and cell-of-origin impacted SOC more than axi-cel outcomes. T-cell activation and B-cell GES, which are associated with improved axi-cel outcome, decreased with increasing lines of therapy. These data highlight differences in resistance mechanisms to axi-cel and SOC and support earlier intervention with axi-cel.\"\n", "!Series_overall_design\t\"256 pretreatment tumor biopsies were analyzed, 134 from the Axicabtagene Ciloleucel arm and 122 from the Standard of Care Chemotherapy arm\"\n", "Sample Characteristics Dictionary:\n", "{0: ['visit: Screening'], 1: ['treatment arm: Axicabtagene Ciloleucel', 'treatment arm: Standard of Care Chemotherapy'], 2: ['baseline tumor burden (spd): 1033.5', 'baseline tumor burden (spd): 2851.5', 'baseline tumor burden (spd): 1494.9', 'baseline tumor burden (spd): null', 'baseline tumor burden (spd): 12712.9', 'baseline tumor burden (spd): 2654.8', 'baseline tumor burden (spd): 6714', 'baseline tumor burden (spd): 1487.1', 'baseline tumor burden (spd): 5443.9', 'baseline tumor burden (spd): 1026.8', 'baseline tumor burden (spd): 8888.1', 'baseline tumor burden (spd): 1491', 'baseline tumor burden (spd): 938.1', 'baseline tumor burden (spd): 2071.7', 'baseline tumor burden (spd): 1244.9', 'baseline tumor burden (spd): 181', 'baseline tumor burden (spd): 714.3', 'baseline tumor burden (spd): 1358.3', 'baseline tumor burden (spd): 7219.2', 'baseline tumor burden (spd): 508.4', 'baseline tumor burden (spd): 13791.8', 'baseline tumor burden (spd): 1330.3', 'baseline tumor burden (spd): 1825.1', 'baseline tumor burden (spd): 1105.8', 'baseline tumor burden (spd): 12322.7', 'baseline tumor burden (spd): 4883.7', 'baseline tumor burden (spd): 1549.9', 'baseline tumor burden (spd): 9403.8', 'baseline tumor burden (spd): 692.7', 'baseline tumor burden (spd): 323.6'], 3: ['cell of origin: GCB', 'cell of origin: Unclassified', 'cell of origin: ABC', 'cell of origin: null'], 4: ['ongoing_2grps: Missing', 'ongoing_2grps: Others', 'ongoing_2grps: Ongoing'], 5: ['ongoing.response: Missing', 'ongoing.response: Relapsed', 'ongoing.response: Nonresponders', 'ongoing.response: Ongoing Response'], 6: ['duration.of.response.months: 1.675564682', 'duration.of.response.months: 1.18275154', 'duration.of.response.months: 1.412731006', 'duration.of.response.months: NA', 'duration.of.response.months: 0.032854209', 'duration.of.response.months: 16.22997947', 'duration.of.response.months: 1.905544148', 'duration.of.response.months: 26.87474333', 'duration.of.response.months: 28.28747433', 'duration.of.response.months: 27.86036961', 'duration.of.response.months: 4.862422998', 'duration.of.response.months: 13.99589322', 'duration.of.response.months: 23.81930185', 'duration.of.response.months: 22.275154', 'duration.of.response.months: 6.209445585', 'duration.of.response.months: 2.168377823', 'duration.of.response.months: 5.749486653', 'duration.of.response.months: 1.642710472', 'duration.of.response.months: 31.93429158', 'duration.of.response.months: 0.657084189', 'duration.of.response.months: 20.23819302', 'duration.of.response.months: 1.445585216', 'duration.of.response.months: 3.449691992', 'duration.of.response.months: 0.919917864', 'duration.of.response.months: 22.40657084', 'duration.of.response.months: 21.88090349', 'duration.of.response.months: 21.94661191', 'duration.of.response.months: 28.09034908', 'duration.of.response.months: 21.65092402', 'duration.of.response.months: 1.872689938'], 7: ['duration.of.response.event: 0', 'duration.of.response.event: 1', 'duration.of.response.event: NA'], 8: ['event.free.survival.months: 3.449691992', 'event.free.survival.months: 3.252566735', 'event.free.survival.months: 1.577002053', 'event.free.survival.months: 1.511293634', 'event.free.survival.months: 2.694045175', 'event.free.survival.months: 17.83983573', 'event.free.survival.months: 3.646817248', 'event.free.survival.months: 28.64887064', 'event.free.survival.months: 29.99589322', 'event.free.survival.months: 29.70020534', 'event.free.survival.months: 6.472279261', 'event.free.survival.months: 3.416837782', 'event.free.survival.months: 15.83572895', 'event.free.survival.months: 25.75770021', 'event.free.survival.months: 24.11498973', 'event.free.survival.months: 8.476386037', 'event.free.survival.months: 1.642710472', 'event.free.survival.months: 3.679671458', 'event.free.survival.months: 1.445585216', 'event.free.survival.months: 7.260780287', 'event.free.survival.months: 3.811088296', 'event.free.survival.months: 33.34702259', 'event.free.survival.months: 2.825462012', 'event.free.survival.months: 23.95071869', 'event.free.survival.months: 1.708418891', 'event.free.survival.months: 7.983572895', 'event.free.survival.months: 3.154004107', 'event.free.survival.months: 4.960985626', 'event.free.survival.months: 1.478439425', 'event.free.survival.months: 2.004106776'], 9: ['event.free.survival.event: 1', 'event.free.survival.event: 0'], 10: ['histologically.proven.dlbcl.group: DLBCL+Others', 'histologically.proven.dlbcl.group: HGBL'], 11: ['grade3_ne: N', 'grade3_ne: Y'], 12: ['grade3_crs: N', 'grade3_crs: Y']}\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": "134caac0", "metadata": {}, "source": [ "### Step 2: Dataset Analysis and Clinical Feature Extraction" ] }, { "cell_type": "code", "execution_count": 3, "id": "1382ac12", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:14.544108Z", "iopub.status.busy": "2025-03-25T07:27:14.543990Z", "iopub.status.idle": "2025-03-25T07:27:14.561519Z", "shell.execute_reply": "2025-03-25T07:27:14.561240Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Files in the cohort directory (../../input/GEO/Large_B-cell_Lymphoma/GSE248835):\n", " - GSE248835_family.soft.gz\n", " - GSE248835_series_matrix.txt.gz\n", "Found clinical_data variable in memory\n", "Clinical Data Preview:\n", "{'GSM7920866': [1.0], 'GSM7920867': [1.0], 'GSM7920868': [1.0], 'GSM7920869': [0.0], 'GSM7920870': [0.0], 'GSM7920871': [0.0], 'GSM7920872': [1.0], 'GSM7920873': [1.0], 'GSM7920874': [1.0], 'GSM7920875': [1.0], 'GSM7920876': [1.0], 'GSM7920877': [0.0], 'GSM7920878': [1.0], 'GSM7920879': [0.0], 'GSM7920880': [1.0], 'GSM7920881': [1.0], 'GSM7920882': [1.0], 'GSM7920883': [1.0], 'GSM7920884': [1.0], 'GSM7920885': [0.0], 'GSM7920886': [0.0], 'GSM7920887': [0.0], 'GSM7920888': [0.0], 'GSM7920889': [0.0], 'GSM7920890': [1.0], 'GSM7920891': [1.0], 'GSM7920892': [0.0], 'GSM7920893': [1.0], 'GSM7920894': [1.0], 'GSM7920895': [1.0], 'GSM7920896': [0.0], 'GSM7920897': [0.0], 'GSM7920898': [0.0], 'GSM7920899': [0.0], 'GSM7920900': [0.0], 'GSM7920901': [1.0], 'GSM7920902': [0.0], 'GSM7920903': [0.0], 'GSM7920904': [1.0], 'GSM7920905': [1.0], 'GSM7920906': [0.0], 'GSM7920907': [0.0], 'GSM7920908': [1.0], 'GSM7920909': [0.0], 'GSM7920910': [1.0], 'GSM7920911': [1.0], 'GSM7920912': [1.0], 'GSM7920913': [1.0], 'GSM7920914': [1.0], 'GSM7920915': [0.0], 'GSM7920916': [1.0], 'GSM7920917': [1.0], 'GSM7920918': [0.0], 'GSM7920919': [1.0], 'GSM7920920': [1.0], 'GSM7920921': [1.0], 'GSM7920922': [0.0], 'GSM7920923': [0.0], 'GSM7920924': [0.0], 'GSM7920925': [1.0], 'GSM7920926': [1.0], 'GSM7920927': [1.0], 'GSM7920928': [1.0], 'GSM7920929': [1.0], 'GSM7920930': [0.0], 'GSM7920931': [0.0], 'GSM7920932': [0.0], 'GSM7920933': [0.0], 'GSM7920934': [0.0], 'GSM7920935': [1.0], 'GSM7920936': [1.0], 'GSM7920937': [1.0], 'GSM7920938': [0.0], 'GSM7920939': [0.0], 'GSM7920940': [0.0], 'GSM7920941': [0.0], 'GSM7920942': [1.0], 'GSM7920943': [0.0], 'GSM7920944': [0.0], 'GSM7920945': [1.0], 'GSM7920946': [1.0], 'GSM7920947': [0.0], 'GSM7920948': [0.0], 'GSM7920949': [1.0], 'GSM7920950': [1.0], 'GSM7920951': [1.0], 'GSM7920952': [0.0], 'GSM7920953': [0.0], 'GSM7920954': [1.0], 'GSM7920955': [0.0], 'GSM7920956': [1.0], 'GSM7920957': [1.0], 'GSM7920958': [1.0], 'GSM7920959': [1.0], 'GSM7920960': [0.0], 'GSM7920961': [0.0], 'GSM7920962': [1.0], 'GSM7920963': [1.0], 'GSM7920964': [0.0], 'GSM7920965': [0.0], 'GSM7920966': [1.0], 'GSM7920967': [0.0], 'GSM7920968': [0.0], 'GSM7920969': [1.0], 'GSM7920970': [1.0], 'GSM7920971': [0.0], 'GSM7920972': [0.0], 'GSM7920973': [1.0], 'GSM7920974': [1.0], 'GSM7920975': [0.0], 'GSM7920976': [1.0], 'GSM7920977': [0.0], 'GSM7920978': [1.0], 'GSM7920979': [0.0], 'GSM7920980': [1.0], 'GSM7920981': [1.0], 'GSM7920982': [0.0], 'GSM7920983': [0.0], 'GSM7920984': [1.0], 'GSM7920985': [1.0], 'GSM7920986': [1.0], 'GSM7920987': [1.0], 'GSM7920988': [0.0], 'GSM7920989': [1.0], 'GSM7920990': [0.0], 'GSM7920991': [1.0], 'GSM7920992': [0.0], 'GSM7920993': [1.0], 'GSM7920994': [1.0], 'GSM7920995': [0.0], 'GSM7920996': [1.0], 'GSM7920997': [0.0], 'GSM7920998': [1.0], 'GSM7920999': [1.0], 'GSM7921000': [1.0], 'GSM7921001': [1.0], 'GSM7921002': [0.0], 'GSM7921003': [1.0], 'GSM7921004': [1.0], 'GSM7921005': [0.0], 'GSM7921006': [1.0], 'GSM7921007': [1.0], 'GSM7921008': [1.0], 'GSM7921009': [0.0], 'GSM7921010': [0.0], 'GSM7921011': [0.0], 'GSM7921012': [0.0], 'GSM7921013': [0.0], 'GSM7921014': [1.0], 'GSM7921015': [1.0], 'GSM7921016': [1.0], 'GSM7921017': [1.0], 'GSM7921018': [1.0], 'GSM7921019': [1.0], 'GSM7921020': [0.0], 'GSM7921021': [1.0], 'GSM7921022': [1.0], 'GSM7921023': [1.0], 'GSM7921024': [0.0], 'GSM7921025': [1.0], 'GSM7921026': [1.0], 'GSM7921027': [0.0], 'GSM7921028': [0.0], 'GSM7921029': [1.0], 'GSM7921030': [0.0], 'GSM7921031': [0.0], 'GSM7921032': [1.0], 'GSM7921033': [1.0], 'GSM7921034': [1.0], 'GSM7921035': [0.0], 'GSM7921036': [0.0], 'GSM7921037': [1.0], 'GSM7921038': [1.0], 'GSM7921039': [0.0], 'GSM7921040': [0.0], 'GSM7921041': [1.0], 'GSM7921042': [0.0], 'GSM7921043': [1.0], 'GSM7921044': [1.0], 'GSM7921045': [1.0], 'GSM7921046': [0.0], 'GSM7921047': [0.0], 'GSM7921048': [0.0], 'GSM7921049': [0.0], 'GSM7921050': [0.0], 'GSM7921051': [0.0], 'GSM7921052': [0.0], 'GSM7921053': [0.0], 'GSM7921054': [1.0], 'GSM7921055': [0.0], 'GSM7921056': [0.0], 'GSM7921057': [0.0], 'GSM7921058': [1.0], 'GSM7921059': [0.0], 'GSM7921060': [0.0], 'GSM7921061': [0.0], 'GSM7921062': [0.0], 'GSM7921063': [1.0], 'GSM7921064': [0.0], 'GSM7921065': [0.0]}\n", "Clinical data saved to ../../output/preprocess/Large_B-cell_Lymphoma/clinical_data/GSE248835.csv\n" ] } ], "source": [ "import os\n", "import pandas as pd\n", "import numpy as np\n", "import json\n", "from glob import glob\n", "\n", "# 1. Gene Expression Data Availability\n", "# This dataset includes gene expression data from the phase 3 ZUMA-7 trial in large B-cell lymphoma\n", "# The background information suggests RNA sequencing for gene expression profiling\n", "is_gene_available = True # Gene expression data is available\n", "\n", "# 2. Variable Availability and Data Type Conversion\n", "# 2.1 Data Availability\n", "# Looking at the Sample Characteristics Dictionary:\n", "\n", "# For trait (Large B-cell Lymphoma):\n", "# Row 1 shows treatment arm information which can be used to classify patients\n", "trait_row = 1 # 'treatment arm' contains treatment information\n", "\n", "# Age information is not available in the sample characteristics dictionary\n", "age_row = None # Age data is not available\n", "\n", "# Gender information is not available in the sample characteristics dictionary\n", "gender_row = None # Gender data is not available\n", "\n", "# 2.2 Data Type Conversion Functions\n", "def convert_trait(value):\n", " \"\"\"\n", " Convert treatment arm information to binary:\n", " Axicabtagene Ciloleucel = 1 (experimental treatment)\n", " Standard of Care Chemotherapy = 0 (control group)\n", " \"\"\"\n", " if value is None or pd.isna(value):\n", " return None\n", " \n", " # Extract value after colon if present\n", " if \":\" in value:\n", " value = value.split(\":\", 1)[1].strip()\n", " \n", " if \"Axicabtagene Ciloleucel\" in value:\n", " return 1\n", " elif \"Standard of Care Chemotherapy\" in value:\n", " return 0\n", " else:\n", " return None\n", "\n", "def convert_age(value):\n", " \"\"\"\n", " Since age data is not available, this function is defined but won't be used.\n", " \"\"\"\n", " return None\n", "\n", "def convert_gender(value):\n", " \"\"\"\n", " Since gender data is not available, this function is defined but won't be used.\n", " \"\"\"\n", " return None\n", "\n", "# 3. Save Metadata\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", "# Only proceed if trait_row is not None\n", "if trait_row is not None:\n", " # List files in the cohort directory to help diagnose\n", " print(f\"Files in the cohort directory ({in_cohort_dir}):\")\n", " if os.path.exists(in_cohort_dir):\n", " files = os.listdir(in_cohort_dir)\n", " for file in files:\n", " print(f\" - {file}\")\n", " else:\n", " print(f\" Directory not found\")\n", " \n", " # Try to find clinical data from possible locations\n", " # First check if a variable containing clinical data is already available\n", " # Try accessing the clinical_data that might have been generated in a previous step\n", " try:\n", " # Assuming clinical_data might have been created in a previous step and is in memory\n", " if 'clinical_data' in locals() or 'clinical_data' in globals():\n", " print(\"Found clinical_data variable in memory\")\n", " # Extract clinical features\n", " selected_clinical_df = geo_select_clinical_features(\n", " clinical_df=clinical_data,\n", " trait=trait,\n", " trait_row=trait_row,\n", " convert_trait=convert_trait,\n", " age_row=age_row,\n", " convert_age=convert_age,\n", " gender_row=gender_row,\n", " convert_gender=convert_gender\n", " )\n", " \n", " # Preview the data\n", " preview = preview_df(selected_clinical_df)\n", " print(\"Clinical Data Preview:\")\n", " print(preview)\n", " \n", " # Create directory if it doesn't exist\n", " os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)\n", " \n", " # Save the clinical data\n", " selected_clinical_df.to_csv(out_clinical_data_file, index=False)\n", " print(f\"Clinical data saved to {out_clinical_data_file}\")\n", " else:\n", " print(\"Clinical data variable not found in memory\")\n", " # Let's search for other possible file names or locations\n", " clinical_files = glob(os.path.join(in_cohort_dir, \"*clinical*.csv\")) + \\\n", " glob(os.path.join(in_cohort_dir, \"*sample*.csv\")) + \\\n", " glob(os.path.join(in_cohort_dir, \"*char*.csv\"))\n", " \n", " if clinical_files:\n", " print(f\"Found potential clinical data files: {clinical_files}\")\n", " clinical_data = pd.read_csv(clinical_files[0])\n", " \n", " # Extract clinical features\n", " selected_clinical_df = geo_select_clinical_features(\n", " clinical_df=clinical_data,\n", " trait=trait,\n", " trait_row=trait_row,\n", " convert_trait=convert_trait,\n", " age_row=age_row,\n", " convert_age=convert_age,\n", " gender_row=gender_row,\n", " convert_gender=convert_gender\n", " )\n", " \n", " # Preview the data\n", " preview = preview_df(selected_clinical_df)\n", " print(\"Clinical Data Preview:\")\n", " print(preview)\n", " \n", " # Create directory if it doesn't exist\n", " os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)\n", " \n", " # Save the clinical data\n", " selected_clinical_df.to_csv(out_clinical_data_file, index=False)\n", " print(f\"Clinical data saved to {out_clinical_data_file}\")\n", " else:\n", " print(\"No clinical data files found in the cohort directory\")\n", " \n", " # If no clinical file is found, let's try checking in in_trait_dir instead\n", " print(f\"Checking for clinical data in trait directory: {in_trait_dir}\")\n", " clinical_files = glob(os.path.join(in_trait_dir, \"*clinical*.csv\")) + \\\n", " glob(os.path.join(in_trait_dir, \"*sample*.csv\")) + \\\n", " glob(os.path.join(in_trait_dir, \"*char*.csv\"))\n", " \n", " if clinical_files:\n", " print(f\"Found potential clinical data files in trait directory: {clinical_files}\")\n", " else:\n", " print(\"No clinical data files found in the trait directory either\")\n", " print(\"Unable to locate clinical data. Skipping clinical feature extraction.\")\n", " except Exception as e:\n", " print(f\"Error during clinical data processing: {e}\")\n", " print(\"Skipping clinical feature extraction due to error\")\n" ] }, { "cell_type": "markdown", "id": "c0bf8f1d", "metadata": {}, "source": [ "### Step 3: Gene Data Extraction" ] }, { "cell_type": "code", "execution_count": 4, "id": "5fe149e3", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:14.562559Z", "iopub.status.busy": "2025-03-25T07:27:14.562457Z", "iopub.status.idle": "2025-03-25T07:27:14.609960Z", "shell.execute_reply": "2025-03-25T07:27:14.609699Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Examining matrix file structure...\n", "Line 0: !Series_title\t\"Impact of Tumor Microenvironment on Efficacy of CD19 CAR T-Cell Therapy or Chemotherapy and Transplant in Large B-Cell Lymphoma\"\n", "Line 1: !Series_geo_accession\t\"GSE248835\"\n", "Line 2: !Series_status\t\"Public on Feb 26 2024\"\n", "Line 3: !Series_submission_date\t\"Nov 28 2023\"\n", "Line 4: !Series_last_update_date\t\"Jul 25 2024\"\n", "Line 5: !Series_pubmed_id\t\"38233586\"\n", "Line 6: !Series_summary\t\"The phase 3 ZUMA-7 trial in second-line large B-cell lymphoma demonstrated superiority of anti-CD19 CAR T-cell therapy (axicabtagene ciloleucel; axi-cel) over standard of care (SOC; salvage chemotherapy followed by hematopoietic transplantation). Here, we present a prespecified exploratory analysis examining the association between pretreatment tumor characteristics and the efficacy of axi-cel versus SOC. B-cell gene expression signature (GES) and CD19 expression significantly associated with improved event-free survival (EFS) for axi-cel (P=.0002 for B-cell GES; P=.0165 for CD19 expression) but not SOC (P=.9374 for B-cell GES; P=.5526 for CD19 expression). Axi-cel showed superior EFS over SOC irrespective of B-cell GES and CD19 expression (P=8.56e–9 for B-cell GES high; P=.0019 for B-cell GES low; P=3.85e–9 for CD19 gene high; P=.0017 for CD19 gene low). Low CD19 expression in malignant cells correlated with a tumor GES consisting of immune suppressive stromal and myeloid genes, highlighting the inter-relation between malignant cell features and immune contexture substantially impacting axi-cel outcomes. Tumor burden, lactate dehydrogenase, and cell-of-origin impacted SOC more than axi-cel outcomes. T-cell activation and B-cell GES, which are associated with improved axi-cel outcome, decreased with increasing lines of therapy. These data highlight differences in resistance mechanisms to axi-cel and SOC and support earlier intervention with axi-cel.\"\n", "Line 7: !Series_overall_design\t\"256 pretreatment tumor biopsies were analyzed, 134 from the Axicabtagene Ciloleucel arm and 122 from the Standard of Care Chemotherapy arm\"\n", "Line 8: !Series_type\t\"Expression profiling by array\"\n", "Line 9: !Series_contributor\t\"Gayatri,,Tiwari\"\n", "Found table marker at line 67\n", "First few lines after marker:\n", "\"ID_REF\"\t\"GSM7920866\"\t\"GSM7920867\"\t\"GSM7920868\"\t\"GSM7920869\"\t\"GSM7920870\"\t\"GSM7920871\"\t\"GSM7920872\"\t\"GSM7920873\"\t\"GSM7920874\"\t\"GSM7920875\"\t\"GSM7920876\"\t\"GSM7920877\"\t\"GSM7920878\"\t\"GSM7920879\"\t\"GSM7920880\"\t\"GSM7920881\"\t\"GSM7920882\"\t\"GSM7920883\"\t\"GSM7920884\"\t\"GSM7920885\"\t\"GSM7920886\"\t\"GSM7920887\"\t\"GSM7920888\"\t\"GSM7920889\"\t\"GSM7920890\"\t\"GSM7920891\"\t\"GSM7920892\"\t\"GSM7920893\"\t\"GSM7920894\"\t\"GSM7920895\"\t\"GSM7920896\"\t\"GSM7920897\"\t\"GSM7920898\"\t\"GSM7920899\"\t\"GSM7920900\"\t\"GSM7920901\"\t\"GSM7920902\"\t\"GSM7920903\"\t\"GSM7920904\"\t\"GSM7920905\"\t\"GSM7920906\"\t\"GSM7920907\"\t\"GSM7920908\"\t\"GSM7920909\"\t\"GSM7920910\"\t\"GSM7920911\"\t\"GSM7920912\"\t\"GSM7920913\"\t\"GSM7920914\"\t\"GSM7920915\"\t\"GSM7920916\"\t\"GSM7920917\"\t\"GSM7920918\"\t\"GSM7920919\"\t\"GSM7920920\"\t\"GSM7920921\"\t\"GSM7920922\"\t\"GSM7920923\"\t\"GSM7920924\"\t\"GSM7920925\"\t\"GSM7920926\"\t\"GSM7920927\"\t\"GSM7920928\"\t\"GSM7920929\"\t\"GSM7920930\"\t\"GSM7920931\"\t\"GSM7920932\"\t\"GSM7920933\"\t\"GSM7920934\"\t\"GSM7920935\"\t\"GSM7920936\"\t\"GSM7920937\"\t\"GSM7920938\"\t\"GSM7920939\"\t\"GSM7920940\"\t\"GSM7920941\"\t\"GSM7920942\"\t\"GSM7920943\"\t\"GSM7920944\"\t\"GSM7920945\"\t\"GSM7920946\"\t\"GSM7920947\"\t\"GSM7920948\"\t\"GSM7920949\"\t\"GSM7920950\"\t\"GSM7920951\"\t\"GSM7920952\"\t\"GSM7920953\"\t\"GSM7920954\"\t\"GSM7920955\"\t\"GSM7920956\"\t\"GSM7920957\"\t\"GSM7920958\"\t\"GSM7920959\"\t\"GSM7920960\"\t\"GSM7920961\"\t\"GSM7920962\"\t\"GSM7920963\"\t\"GSM7920964\"\t\"GSM7920965\"\t\"GSM7920966\"\t\"GSM7920967\"\t\"GSM7920968\"\t\"GSM7920969\"\t\"GSM7920970\"\t\"GSM7920971\"\t\"GSM7920972\"\t\"GSM7920973\"\t\"GSM7920974\"\t\"GSM7920975\"\t\"GSM7920976\"\t\"GSM7920977\"\t\"GSM7920978\"\t\"GSM7920979\"\t\"GSM7920980\"\t\"GSM7920981\"\t\"GSM7920982\"\t\"GSM7920983\"\t\"GSM7920984\"\t\"GSM7920985\"\t\"GSM7920986\"\t\"GSM7920987\"\t\"GSM7920988\"\t\"GSM7920989\"\t\"GSM7920990\"\t\"GSM7920991\"\t\"GSM7920992\"\t\"GSM7920993\"\t\"GSM7920994\"\t\"GSM7920995\"\t\"GSM7920996\"\t\"GSM7920997\"\t\"GSM7920998\"\t\"GSM7920999\"\t\"GSM7921000\"\t\"GSM7921001\"\t\"GSM7921002\"\t\"GSM7921003\"\t\"GSM7921004\"\t\"GSM7921005\"\t\"GSM7921006\"\t\"GSM7921007\"\t\"GSM7921008\"\t\"GSM7921009\"\t\"GSM7921010\"\t\"GSM7921011\"\t\"GSM7921012\"\t\"GSM7921013\"\t\"GSM7921014\"\t\"GSM7921015\"\t\"GSM7921016\"\t\"GSM7921017\"\t\"GSM7921018\"\t\"GSM7921019\"\t\"GSM7921020\"\t\"GSM7921021\"\t\"GSM7921022\"\t\"GSM7921023\"\t\"GSM7921024\"\t\"GSM7921025\"\t\"GSM7921026\"\t\"GSM7921027\"\t\"GSM7921028\"\t\"GSM7921029\"\t\"GSM7921030\"\t\"GSM7921031\"\t\"GSM7921032\"\t\"GSM7921033\"\t\"GSM7921034\"\t\"GSM7921035\"\t\"GSM7921036\"\t\"GSM7921037\"\t\"GSM7921038\"\t\"GSM7921039\"\t\"GSM7921040\"\t\"GSM7921041\"\t\"GSM7921042\"\t\"GSM7921043\"\t\"GSM7921044\"\t\"GSM7921045\"\t\"GSM7921046\"\t\"GSM7921047\"\t\"GSM7921048\"\t\"GSM7921049\"\t\"GSM7921050\"\t\"GSM7921051\"\t\"GSM7921052\"\t\"GSM7921053\"\t\"GSM7921054\"\t\"GSM7921055\"\t\"GSM7921056\"\t\"GSM7921057\"\t\"GSM7921058\"\t\"GSM7921059\"\t\"GSM7921060\"\t\"GSM7921061\"\t\"GSM7921062\"\t\"GSM7921063\"\t\"GSM7921064\"\t\"GSM7921065\"\t\"GSM7921066\"\t\"GSM7921067\"\t\"GSM7921068\"\t\"GSM7921069\"\t\"GSM7921070\"\t\"GSM7921071\"\t\"GSM7921072\"\t\"GSM7921073\"\t\"GSM7921074\"\t\"GSM7921075\"\t\"GSM7921076\"\t\"GSM7921077\"\t\"GSM7921078\"\t\"GSM7921079\"\t\"GSM7921080\"\t\"GSM7921081\"\t\"GSM7921082\"\t\"GSM7921083\"\t\"GSM7921084\"\t\"GSM7921085\"\t\"GSM7921086\"\t\"GSM7921087\"\t\"GSM7921088\"\t\"GSM7921089\"\t\"GSM7921090\"\t\"GSM7921091\"\t\"GSM7921092\"\t\"GSM7921093\"\t\"GSM7921094\"\t\"GSM7921095\"\t\"GSM7921096\"\t\"GSM7921097\"\t\"GSM7921098\"\t\"GSM7921099\"\t\"GSM7921100\"\t\"GSM7921101\"\t\"GSM7921102\"\t\"GSM7921103\"\t\"GSM7921104\"\t\"GSM7921105\"\t\"GSM7921106\"\t\"GSM7921107\"\t\"GSM7921108\"\t\"GSM7921109\"\t\"GSM7921110\"\t\"GSM7921111\"\t\"GSM7921112\"\t\"GSM7921113\"\t\"GSM7921114\"\t\"GSM7921115\"\t\"GSM7921116\"\t\"GSM7921117\"\t\"GSM7921118\"\t\"GSM7921119\"\t\"GSM7921120\"\t\"GSM7921121\"\n", "1\t428.4550363\t1478.583496\t320.9044532\t205.7858536\t131.1432733\t109.2129406\t163.823669\t161.5682601\t345.3702488\t101.6171432\t58.89200964\t62.42274954\t134.0846243\t646.7211581\t131.7811307\t55.13895422\t305.2822713\t186.2375275\t1746.196258\t27.45505697\t158.0240137\t139.9725386\t318.0258001\t696.9928276\t71.80438275\t40.98431556\t557.5664719\t205.7858536\t335.2282683\t75.84593734\t642.6992595\t361.7878128\t204.2227814\t611.8354969\t85.0358921\t275.326564\t204.5060906\t288.0149721\t254.7608888\t73.05950126\t811.2484464\t82.08234258\t89.5734954\t593.8686231\t326.9667224\t221.3215312\t66.11932081\t284.2467414\t119.5110329\t238.3602739\t26.61190715\t131.6898186\t69.69580898\t61.39290364\t97.74831987\t690.7404976\t167.4979931\t149.0858991\t158.3529573\t81.8550772\t255.1143073\t275.7085123\t158.7926141\t384.276249\t343.936877\t181.2704561\t347.7724888\t90.32165398\t615.6642554\t127.8226773\t16.8071127\t648.5167379\t90.00916479\t356.0657848\t752.2143402\t59.42507855\t448.5111373\t1136.199139\t132.2386416\t417.3170342\t143.4098194\t538.2005295\t457.6180031\t218.4258811\t459.5251459\t347.5315148\t200.9927984\t584.47601\t154.664684\t100.775421\t153.1710673\t2076.589015\t187.532912\t314.3003351\t220.4029922\t739.2917481\t324.4832056\t71.01244621\t95.47161771\t356.3126763\t204.081274\t131.2342064\t56.92537559\t1652.002323\t47.17661495\t265.2115875\t687.3971214\t206.0713312\t67.88401545\t363.0438491\t214.0790784\t49.28237915\t561.4446534\t1488.867858\t344.1753585\t639.145241\t2149.819768\t323.8091628\t383.2122846\t305.2822713\t486.0631659\t85.39028286\t352.8717192\t294.4747247\t466.2629548\t87.12410346\t509.1687264\t502.8554728\t102.7503858\t402.2643285\t350.6772429\t408.4455628\t179.3955135\t258.3172183\t187.532912\t438.6723608\t508.1110398\t190.6787153\t246.9371353\t22.53350763\t180.8939064\t235.0786975\t327.8745245\t62.33627319\t54.37983994\t302.9634616\t504.9511447\t69.02274763\t129.7868134\t239.3536506\t596.7570934\t195.6321947\t52.52746296\t293.6593982\t438.6723608\t360.2863041\t206.6434751\t622.9618476\t114.6426458\t195.2258116\t75.11348341\t1858.59923\t163.0307168\t186.1084822\t339.9078805\t1120.55675\t127.6456002\t34.41582049\t122.6157079\t383.2122846\t243.5374787\t755.349226\t664.4422487\t267.0562799\t380.8291232\t583.2618891\t279.5572597\t456.3509739\t465.9398779\t83.05528108\t370.4153308\t94.35322991\t121.600049\t157.0412771\t261.0170068\t326.0614337\t727.5991261\t151.376768\t219.9451533\t801.7451994\t423.4359646\t380.0380341\t279.9450771\t843.3572017\t253.5277752\t298.7924741\t172.8048621\t361.7878128\t230.5602508\t230.2408479\t1573.760186\t333.8369882\t196.1753549\t797.8645296\t514.4902761\t454.1421082\t110.2779084\t163.3700824\t41.72962353\t214.2275181\t1618.004607\t367.6017947\t590.1754096\t228.4920247\t361.5371275\t100.3571781\t299.8298064\t376.1071701\t995.3085317\t232.1639242\t882.2232675\t154.8792434\t485.0534761\t40.44809915\t168.546166\t690.7404976\t516.9926644\t388.8311526\t437.1546698\t344.8917957\t435.34037\t463.0422413\t65.79928491\t153.9160639\t112.8294602\t65.52620163\t400.8725997\t390.1810766\t545.3354001\t437.1546698\t402.822372\t524.5730934\t167.8466578\t189.3616012\t330.8423246\t377.9364879\t207.9366135\t291.2269383\t1105.129714\t58.20212812\t121.7687394\t378.4607824\t2368.897401\t366.8381825\t312.9959111\t488.4272899\n", "2\t34.27298634\t136.9969534\t77.01139366\t28.26608165\t58.85120295\t48.43573738\t46.59166557\t56.29754086\t71.06168535\t29.83636757\t26.51983694\t15.35886818\t33.05966041\t58.72895247\t38.34588868\t32.80855161\t44.53908454\t56.57136199\t116.4042562\t13.38921988\t64.98343046\t37.8704327\t55.10074805\t88.76998202\t45.4119474\t11.83510007\t91.26564591\t36.63117314\t54.11662639\t28.48242346\t103.7523353\t79.94855204\t42.48848507\t130.3277056\t13.90951296\t94.6151956\t47.83517596\t50.17858906\t67.97818794\t26.81558831\t85.21290325\t14.46004363\t19.02731384\t83.28587875\t70.27794008\t57.16261455\t42.40022455\t50.42264871\t27.62686587\t37.63492001\t14.98035596\t90.88687095\t41.67181407\t44.97339841\t49.35074641\t38.69298163\t43.08160222\t108.0833136\t29.02049053\t18.1387106\t64.31128451\t40.98431556\t49.35074641\t81.62844107\t89.63560454\t96.26904009\t42.57692931\t48.16789592\t92.98976317\t68.73628618\t24.30194704\t115.6001933\t22.22328217\t81.17704956\t134.6434277\t23.67020015\t107.1137591\t102.8929268\t51.30402108\t85.98421925\t33.98909397\t106.3738703\t88.03467636\t66.71780869\t111.1989997\t92.47554547\t73.05950126\t105.7856407\t33.28960853\t42.54742746\t51.44646341\t149.396237\t26.22734744\t73.82307872\t54.37983994\t84.27308301\t61.77708959\t41.29799969\t20.62039409\t99.31914935\t42.78401585\t62.07756226\t18.03840659\t70.8158306\t13.70851128\t70.08335813\t79.39630705\t51.69668977\t20.00099684\t101.5467319\t98.29185726\t11.2511456\t104.7640552\t124.7589928\t77.38596325\t85.44949141\t187.9232814\t78.19475851\t82.71058116\t33.98909397\t77.81627412\t30.67518203\t47.63664817\t68.83164099\t75.68838402\t33.28960853\t110.2014961\t76.69177737\t62.90051831\t94.68080059\t90.50966799\t52.27321543\t74.02804377\t46.81827906\t47.53769346\t89.3254889\t69.40655417\t52.89282036\t71.75462899\t75.37425853\t39.15161732\t92.98976317\t90.94989076\t58.93284462\t29.52775976\t75.635939\t91.58249728\t34.53530357\t45.98208565\t43.35119928\t90.07157602\t45.12953474\t21.6455717\t48.5702161\t96.73727541\t43.98683826\t66.30289687\t88.76998202\t69.07060714\t30.12731087\t32.85406546\t158.9027189\t59.87990386\t41.64293937\t73.82307872\t96.46943421\t40.95591724\t31.55944654\t50.14381996\t64.53455711\t65.07357909\t129.1586091\t86.16320443\t64.0443768\t83.51711665\t85.92464018\t60.38004806\t44.7867477\t73.26234628\t18.50701094\t80.00398737\t22.72171774\t82.65327042\t48.5702161\t46.98082035\t66.34887047\t93.24794329\t28.18781997\t34.48746064\t79.01200684\t94.41865325\t74.69811852\t60.42191483\t95.93597451\t49.07784511\t48.6375954\t83.28587875\t64.93840298\t36.17697815\t69.26237725\t169.6008982\t77.65462786\t68.83164099\t82.71058116\t68.64106348\t70.61975936\t31.21137477\t54.19169999\t25.49248308\t45.28621313\t100.5660821\t72.50456866\t97.34264021\t31.27634453\t44.41576701\t57.04387174\t71.01244621\t82.42442429\t79.89315513\t47.24206098\t108.3834\t73.16085347\t84.97697014\t18.63573738\t49.90110993\t97.95179327\t88.279099\t52.20079957\t62.42274954\t65.89056534\t88.89312869\t84.27308301\t34.53530357\t48.23471711\t15.4121903\t29.10106406\t75.11348341\t64.57930457\t101.6876032\t84.33151691\t80.00398737\t80.5604591\t52.30946102\t48.36863771\t43.02191981\t29.73314158\t43.77392972\t68.83164099\t140.848462\t38.98912844\t42.04901207\t66.57921706\t96.46943421\t71.40731663\t97.68058937\t79.17647864\n", "3\t1.830198336\t1.296120633\t1.562547449\t1.741825381\t2.42670712\t2.897884309\t2.344044567\t1.615297612\t1.605586064\t2.940374673\t3.429504147\t2.433444717\t1.500871018\t1.441429224\t1.844461915\t1.638527629\t1.854332556\t1.252838107\t1.866195333\t1.463071221\t1.362069199\t2.205338326\t1.235418637\t1.931604862\t1.161508732\t2.391639594\t1.517608853\t1.911890635\t2.100889088\t1.293697215\t1.22858698\t1.819573085\t2.084931522\t1.754305494\t2.331082396\t1.952469484\t1.708819482\t1.383574184\t1.395130425\t6.302831088\t1.435347442\t1.63727879\t1.858192544\t1.355852275\t1.692199895\t2.011121161\t3.434261746\t3.758090997\t5.852284883\t2.505328877\t3.474968741\t1.790422411\t1.434651176\t1.458716981\t1.711427289\t1.307490079\t2.885857374\t2.575763259\t1.627999211\t1.440230775\t1.993771394\t2.127265346\t2.29739671\t1.321888049\t1.761860867\t1.472839271\t1.811267966\t1.504725159\t1.261639732\t1.810765846\t1.253793712\t1.582274602\t2.690734417\t1.841396105\t1.988940337\t1.759054278\t1.754913595\t1.583701019\t1.23370717\t1.273147878\t1.996398881\t1.64832417\t1.25092908\t1.781632771\t1.509425969\t2.438510188\t2.352182501\t1.495782075\t3.328794939\t1.810640337\t1.313667351\t1.741221815\t1.46977977\t1.741583929\t1.507230433\t1.197146739\t1.779904702\t3.23104311\t1.553045395\t1.260852926\t1.934686757\t1.490813719\t1.865160782\t1.632858754\t3.029332632\t1.358392125\t1.503786755\t1.652556961\t4.011105744\t1.405710979\t1.365472255\t2.375119332\t1.344714591\t1.778794686\t1.704560729\t1.395420564\t1.766262781\t1.566885762\t1.394357015\t1.209910222\t1.507752889\t1.643760375\t1.535916728\t1.241685666\t1.741342511\t1.881391381\t1.262077059\t1.371448074\t1.895002826\t1.589970502\t1.332005464\t1.345460466\t1.467336746\t1.419516875\t1.146709536\t1.195156877\t2.469125214\t1.922921676\t1.39735637\t2.496661098\t1.907654626\t1.817178322\t1.495263766\t1.231998073\t1.539433983\t2.357078816\t1.345646999\t2.023706402\t1.42968766\t1.340433827\t1.4080514\t1.812147012\t1.244097885\t1.744241738\t1.307218223\t1.498272459\t2.677710514\t1.335981472\t2.81864151\t1.987562187\t2.318191904\t1.505351087\t2.586497864\t2.203810232\t2.127265346\t1.779904702\t1.475189201\t2.018103268\t2.308570835\t1.738448103\t1.353786279\t2.722628233\t1.261377409\t1.603139534\t1.177641159\t1.579863593\t1.53900722\t1.310575076\t2.121375483\t2.517514347\t2.015307521\t2.179504224\t1.632745577\t2.38998241\t2.278366754\t1.429786762\t1.783486135\t1.691379033\t1.547564994\t1.380317353\t1.825637081\t1.304231528\t1.26523029\t1.730633219\t1.430084109\t1.474269217\t1.678415609\t1.991561457\t1.48668603\t1.738448103\t1.925188886\t1.41843496\t1.294235361\t2.223758315\t1.41460572\t1.404834325\t1.357450885\t2.26891097\t2.173469725\t1.863480859\t2.136130816\t1.565365984\t1.305950306\t1.675741946\t1.652900636\t1.532407509\t1.976160329\t1.511310402\t1.588978936\t1.287078458\t1.706688777\t3.412904392\t1.677834015\t3.391679859\t1.897763218\t2.022304162\t1.690910149\t1.879566553\t1.60358408\t1.687280696\t1.528058737\t1.331267048\t1.444029285\t2.233025924\t2.617156143\t2.952628811\t1.752603931\t2.966989868\t1.784970214\t1.427113422\t1.899210742\t1.321796426\t1.640686958\t2.076278541\t3.088700532\t2.295804828\t1.752118073\t1.326661214\t1.69595748\t1.438534678\t1.520557107\t2.373473595\t2.168954818\t1.728714949\t1.653015211\t2.81864151\n", "4\t18.45576968\t19.61655776\t28.10977498\t19.05370959\t21.36237285\t21.60060776\t21.4662756\t22.2078835\t20.4212603\t16.99454698\t19.50808151\t24.89872565\t14.04514876\t16.07782113\t20.49215778\t33.94200772\t20.6633176\t26.55662674\t18.59702572\t15.39083927\t32.62712586\t17.39981425\t18.41743186\t21.09749783\t36.42860893\t18.54553523\t21.81124172\t27.49314416\t34.10709555\t16.87715707\t21.36237285\t23.39291917\t18.4941873\t26.87140777\t20.74943287\t22.26954227\t24.65827547\t21.27371373\t24.65827547\t15.39083927\t26.90868529\t24.67537321\t19.49456422\t25.84834488\t32.17793857\t22.69024057\t25.17639825\t17.69169045\t22.4866992\t32.37930243\t17.00633079\t38.29276682\t20.29426239\t23.11888637\t25.83043438\t24.96785537\t23.24744079\t23.98399363\t26.66730263\t25.10669113\t23.57196297\t18.10103141\t13.93846707\t24.33566005\t22.17711817\t30.76034971\t20.11221399\t31.64706932\t17.95109569\t25.28132198\t18.44298155\t27.91560658\t22.5022912\t32.62712586\t33.24349131\t19.97328878\t29.24260641\t22.627417\t24.79538979\t28.68053439\t33.45152321\t28.10977498\t33.28960853\t24.03391883\t21.33277883\t30.06472797\t31.14653997\t32.15564225\t19.13311675\t22.2078835\t21.11212657\t23.44161399\t23.21523533\t20.49215778\t28.78010599\t17.32760073\t23.53930793\t23.49041018\t24.20108796\t23.23133248\t23.18307447\t31.29803115\t28.8400148\t27.58859344\t21.69062923\t32.24492033\t23.18307447\t27.78048728\t26.72281342\t24.11735855\t27.76123799\t13.12276658\t16.07782113\t21.08287923\t25.74106787\t27.53128418\t19.82157916\t24.26828073\t36.96274511\t20.70633047\t17.93865725\t37.27147477\t21.40684088\t22.92738641\t18.80442125\t27.39802511\t20.54905294\t18.00093576\t20.18203854\t30.42109124\t22.5022912\t19.63015964\t27.0583132\t23.16701076\t23.63740902\t20.6633176\t31.01727414\t18.20168365\t20.22404958\t27.34111171\t20.5633014\t45.09826416\t22.45554762\t15.72512958\t13.05924874\t22.78480313\t20.86481176\t23.55562979\t20.89375659\t17.19598677\t24.47098045\t13.64215827\t24.7438828\t21.20011227\t24.70960426\t36.27742121\t18.26487531\t24.5900029\t31.91140004\t17.52083953\t16.37019952\t25.51015925\t29.91920633\t25.49248308\t20.21003619\t22.47111801\t37.01402188\t11.47959628\t15.4121903\t21.54080111\t24.47098045\t22.86390624\t26.8341819\t24.18431885\t23.23133248\t24.7438828\t27.15225285\t18.12614216\t50.52760875\t22.92738641\t33.22045666\t11.6237204\t43.77392972\t18.20168365\t17.75311155\t20.77821764\t19.15965927\t25.05453748\t27.56947711\t21.6455717\t37.60884251\t26.8341819\t30.65392698\t28.76016405\t24.06726002\t23.39291917\t25.83043438\t29.91920633\t30.80302218\t14.40003088\t24.08394796\t30.69645182\t28.78010599\t47.9347499\t23.63740902\t20.59182796\t13.29673379\t21.30322581\t19.4002051\t15.54091993\t26.89004007\t21.82636536\t27.7227794\t23.50669813\t30.08557448\t19.21285484\t23.58830748\t21.99341913\t21.40684088\t31.45025915\t19.98713801\t29.69195125\t26.59346757\t17.70395765\t16.13363928\t29.42560148\t34.36814309\t25.66979732\t20.02874334\t18.16387363\t21.30322581\t31.27634453\t31.49388871\t32.6497491\t31.18974819\t16.37019952\t20.96629446\t17.92622743\t23.08685899\t27.45505697\t22.91149986\t35.90219138\t23.42537114\t24.79538979\t23.76884673\t24.8642326\t21.82636536\t35.82761244\t23.93417213\t18.34099497\t33.63753309\t31.88928841\t22.87975978\t59.21948339\t19.72563721\t32.96812652\n", "Total lines examined: 68\n", "\n", "Attempting to extract gene data from matrix file...\n", "Successfully extracted gene data with 817 rows\n", "First 20 gene IDs:\n", "Index(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13',\n", " '14', '15', '16', '17', '18', '19', '20'],\n", " dtype='object', name='ID')\n", "\n", "Gene expression data available: True\n" ] } ], "source": [ "# 1. Get the file paths for the SOFT file and matrix file\n", "soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)\n", "\n", "# Add diagnostic code to check file content and structure\n", "print(\"Examining matrix file structure...\")\n", "with gzip.open(matrix_file, 'rt') as file:\n", " table_marker_found = False\n", " lines_read = 0\n", " for i, line in enumerate(file):\n", " lines_read += 1\n", " if '!series_matrix_table_begin' in line:\n", " table_marker_found = True\n", " print(f\"Found table marker at line {i}\")\n", " # Read a few lines after the marker to check data structure\n", " next_lines = [next(file, \"\").strip() for _ in range(5)]\n", " print(\"First few lines after marker:\")\n", " for next_line in next_lines:\n", " print(next_line)\n", " break\n", " if i < 10: # Print first few lines to see file structure\n", " print(f\"Line {i}: {line.strip()}\")\n", " if i > 100: # Don't read the entire file\n", " break\n", " \n", " if not table_marker_found:\n", " print(\"Table marker '!series_matrix_table_begin' not found in first 100 lines\")\n", " print(f\"Total lines examined: {lines_read}\")\n", "\n", "# 2. Try extracting gene expression data from the matrix file again with better diagnostics\n", "try:\n", " print(\"\\nAttempting to extract gene data from matrix file...\")\n", " gene_data = get_genetic_data(matrix_file)\n", " if gene_data.empty:\n", " print(\"Extracted gene expression data is empty\")\n", " is_gene_available = False\n", " else:\n", " print(f\"Successfully extracted gene data with {len(gene_data.index)} rows\")\n", " print(\"First 20 gene IDs:\")\n", " print(gene_data.index[:20])\n", " is_gene_available = True\n", "except Exception as e:\n", " print(f\"Error extracting gene data: {str(e)}\")\n", " print(\"This dataset appears to have an empty or malformed gene expression matrix\")\n", " is_gene_available = False\n", "\n", "print(f\"\\nGene expression data available: {is_gene_available}\")\n", "\n", "# If data extraction failed, try an alternative approach using pandas directly\n", "if not is_gene_available:\n", " print(\"\\nTrying alternative approach to read gene expression data...\")\n", " try:\n", " with gzip.open(matrix_file, 'rt') as file:\n", " # Skip lines until we find the marker\n", " for line in file:\n", " if '!series_matrix_table_begin' in line:\n", " break\n", " \n", " # Try to read the data directly with pandas\n", " gene_data = pd.read_csv(file, sep='\\t', index_col=0)\n", " \n", " if not gene_data.empty:\n", " print(f\"Successfully extracted gene data with alternative method: {gene_data.shape}\")\n", " print(\"First 20 gene IDs:\")\n", " print(gene_data.index[:20])\n", " is_gene_available = True\n", " else:\n", " print(\"Alternative extraction method also produced empty data\")\n", " except Exception as e:\n", " print(f\"Alternative extraction failed: {str(e)}\")\n" ] }, { "cell_type": "markdown", "id": "54bfcb42", "metadata": {}, "source": [ "### Step 4: Gene Identifier Review" ] }, { "cell_type": "code", "execution_count": 5, "id": "704aca56", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:14.611020Z", "iopub.status.busy": "2025-03-25T07:27:14.610909Z", "iopub.status.idle": "2025-03-25T07:27:14.612585Z", "shell.execute_reply": "2025-03-25T07:27:14.612319Z" } }, "outputs": [], "source": [ "# Examining the gene identifiers in the gene expression data\n", "# Based on the output, the gene identifiers appear to be numbers (1, 2, 3, 4, 5, etc.)\n", "# These are not standard human gene symbols, which would typically be names like BRCA1, TP53, CD19, etc.\n", "# These numeric identifiers likely represent probe IDs from a microarray platform\n", "# that need to be mapped to standard gene symbols\n", "\n", "requires_gene_mapping = True\n" ] }, { "cell_type": "markdown", "id": "c1ba17b7", "metadata": {}, "source": [ "### Step 5: Gene Annotation" ] }, { "cell_type": "code", "execution_count": 6, "id": "c38c441f", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:14.613588Z", "iopub.status.busy": "2025-03-25T07:27:14.613489Z", "iopub.status.idle": "2025-03-25T07:27:14.825869Z", "shell.execute_reply": "2025-03-25T07:27:14.825497Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Extracting gene annotation data from SOFT file...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Successfully extracted gene annotation data with 210225 rows\n", "\n", "Gene annotation preview (first few rows):\n", "{'ID': ['1', '2', '3', '4', '5'], 'Gene_Signature_Name': ['TIS.IO360', 'APM.IO360', 'APM Loss.IO360', 'Apoptosis.IO360', 'ARG1.IO360'], 'ORF': [nan, nan, nan, nan, nan], 'GB_ACC': [nan, nan, nan, nan, nan], 'NS Probe ID': [nan, nan, nan, nan, nan], 'Analyte Type': ['IO360 Signature', 'IO360 Signature', 'IO360 Signature', 'IO360 Signature', 'IO360 Signature'], 'SPOT_ID': ['TIS.IO360', 'APM.IO360', 'APM Loss.IO360', 'Apoptosis.IO360', 'ARG1.IO360']}\n", "\n", "Column names in gene annotation data:\n", "['ID', 'Gene_Signature_Name', 'ORF', 'GB_ACC', 'NS Probe ID', 'Analyte Type', 'SPOT_ID']\n", "\n", "The dataset contains GenBank accessions (GB_ACC) that could be used for gene mapping.\n", "Number of rows with GenBank accessions: 768 out of 210225\n", "\n", "The dataset contains genomic regions (SPOT_ID) that could be used for location-based gene mapping.\n", "Example SPOT_ID format: TIS.IO360\n" ] } ], "source": [ "# 1. Extract gene annotation data from the SOFT file\n", "print(\"Extracting gene annotation data from SOFT file...\")\n", "try:\n", " # Use the library function to extract gene annotation\n", " gene_annotation = get_gene_annotation(soft_file)\n", " print(f\"Successfully extracted gene annotation data with {len(gene_annotation.index)} rows\")\n", " \n", " # Preview the annotation DataFrame\n", " print(\"\\nGene annotation preview (first few rows):\")\n", " print(preview_df(gene_annotation))\n", " \n", " # Show column names to help identify which columns we need for mapping\n", " print(\"\\nColumn names in gene annotation data:\")\n", " print(gene_annotation.columns.tolist())\n", " \n", " # Check for relevant mapping columns\n", " if 'GB_ACC' in gene_annotation.columns:\n", " print(\"\\nThe dataset contains GenBank accessions (GB_ACC) that could be used for gene mapping.\")\n", " # Count non-null values in GB_ACC column\n", " non_null_count = gene_annotation['GB_ACC'].count()\n", " print(f\"Number of rows with GenBank accessions: {non_null_count} out of {len(gene_annotation)}\")\n", " \n", " if 'SPOT_ID' in gene_annotation.columns:\n", " print(\"\\nThe dataset contains genomic regions (SPOT_ID) that could be used for location-based gene mapping.\")\n", " print(\"Example SPOT_ID format:\", gene_annotation['SPOT_ID'].iloc[0])\n", " \n", "except Exception as e:\n", " print(f\"Error processing gene annotation data: {e}\")\n", " is_gene_available = False\n" ] }, { "cell_type": "markdown", "id": "30206598", "metadata": {}, "source": [ "### Step 6: Gene Identifier Mapping" ] }, { "cell_type": "code", "execution_count": 7, "id": "5925b32a", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:14.827294Z", "iopub.status.busy": "2025-03-25T07:27:14.827048Z", "iopub.status.idle": "2025-03-25T07:27:15.726519Z", "shell.execute_reply": "2025-03-25T07:27:15.726149Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Analyzing gene annotation data to determine mapping columns...\n", "Sample Gene_Signature_Name values:\n", "['TIS.IO360' 'APM.IO360' 'APM Loss.IO360' 'Apoptosis.IO360' 'ARG1.IO360'\n", " 'B Cells.IO360' 'B7-H3.IO360' 'CD45.IO360' 'CD8 T Cells.IO360'\n", " 'CTLA4.IO360']\n", "\n", "Sample SPOT_ID values:\n", "['TIS.IO360' 'APM.IO360' 'APM Loss.IO360' 'Apoptosis.IO360' 'ARG1.IO360'\n", " 'B Cells.IO360' 'B7-H3.IO360' 'CD45.IO360' 'CD8 T Cells.IO360'\n", " 'CTLA4.IO360']\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Number of rows with potential human gene symbols in Gene_Signature_Name: 1072\n", "Number of rows with potential human gene symbols in SPOT_ID: 48\n", "\n", "Creating gene mapping dataframe...\n", "Created mapping dataframe with 210225 rows\n", "Mapping preview:\n", "{'ID': ['1', '2', '3', '4', '5'], 'Gene': ['TIS.IO360', 'APM.IO360', 'APM Loss.IO360', 'Apoptosis.IO360', 'ARG1.IO360']}\n", "\n", "Converting probe-level measurements to gene expression data...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Successfully created gene expression data with 789 rows (genes)\n", "\n", "Gene expression data preview (first few genes):\n", "Shape: (5, 256)\n", "{'GSM7920866': [782.1839951, 3.83423527, 13.03639992, 8.435317594, 19.9380234], 'GSM7920867': [1621.002775, 5.25940108, 10.51880216, 69.75626698, 1246.754867], 'GSM7920868': [1909.47077, 3.5541568545, 21.32494113, 231.0201955, 9.773931349], 'GSM7920869': [1977.105386, 4.057492396, 35.41084273, 265.5813205, 18.44314725], 'GSM7920870': [992.555453, 1.771717389, 8.661729459, 266.1513234, 17.71717389], 'GSM7920871': [911.3641002, 9.550222605, 27.28635031, 603.0283417, 27.28635031], 'GSM7920872': [667.4939404, 3.024897011, 14.11618605, 112.9294884, 7.394192693], 'GSM7920873': [1006.014499, 5.051118825, 13.4696502, 142.2731803, 17.67891589], 'GSM7920874': [755.1144365, 5.53013236, 11.56300402, 445.9297638, 28.6561404], 'GSM7920875': [886.8469287, 2.3261558785, 5.815389696, 211.098646, 9.304623514], 'GSM7920876': [1070.110026, 2.624656686, 5.999215282, 217.471554, 11.24852865], 'GSM7920877': [384.5091436, 1.194127775, 8.358894426, 124.1892886, 2.38825555], 'GSM7920878': [1059.378847, 7.851724635, 12.07957636, 199.31301, 9.663661089], 'GSM7920879': [2358.547831, 25.98473556, 9.094657447, 120.8290204, 7.795420669], 'GSM7920880': [2354.086772, 1.4768423915, 16.24526631, 261.4011033, 7.384211958], 'GSM7920881': [161.8571826, 2.345756269, 30.49483149, 7.037268807, 959.414314], 'GSM7920882': [432.7854058, 1.065973906, 17.05558249, 104.4654428, 21.31947812], 'GSM7920883': [1683.005303, 16.33985731, 8.169928655, 159.3136088, 32.67971462], 'GSM7920884': [1303.252811, 6.499161, 8.209466528, 312.6438503, 134.0879533], 'GSM7920885': [582.5615383, 3.4794631125, 6.958926225, 149.1198477, 9.941323179], 'GSM7920886': [350.4569405, 5.776762755, 15.40470068, 284.9869626, 11.55352551], 'GSM7920887': [2017.038978, 1.6515057135, 12.6615438, 743.1775711, 7.707026663], 'GSM7920888': [712.7552753, 1.2425998525, 12.42599852, 284.3068462, 8.946718936], 'GSM7920889': [568.4034303, 2.7637119785, 17.5035092, 19.34598385, 105.0210552], 'GSM7920890': [1520.203149, 8.761977805, 105.1437337, 70.09582245, 8.761977807], 'GSM7920891': [1869.962934, 1.636217567, 11.2197776, 30.38689767, 7.947342468], 'GSM7920892': [1619.567162, 7.097704695, 28.39081878, 89.90425947, 24.51934349], 'GSM7920893': [1065.473612, 3.9520534585, 5.796345073, 103.2803304, 33.72418951], 'GSM7920894': [2247.431975, 5.82236263, 15.52630035, 1397.367031, 34.93417578], 'GSM7920895': [1079.830731, 1.4029849255, 11.69154105, 96.80595987, 7.950247912], 'GSM7920896': [2400.252613, 5.05848812, 22.76319654, 2262.408812, 41.73252699], 'GSM7920897': [628.0476397, 2.8594884255, 8.83841877, 141.4147003, 57.7096755], 'GSM7920898': [1055.736948, 3.9768045245, 7.116387044, 397.6804524, 6.697776041], 'GSM7920899': [2139.141397, 6.99828156, 9.331042082, 177.2897996, 27.99312625], 'GSM7920900': [634.3367292, 1.364165009, 10.23123757, 28.64746519, 6.138742541], 'GSM7920901': [1378.933954, 3.5087377955, 10.02496513, 180.4493723, 13.03245467], 'GSM7920902': [3345.395582, 4.003142725, 14.16496657, 133.6433802, 80.67872262], 'GSM7920903': [3446.155387, 2.756924309, 16.54154586, 560.8371738, 18.90462383], 'GSM7920904': [2203.720789, 4.096135296, 18.20504576, 1108.687287, 16.38454118], 'GSM7920905': [1629.393999, 5.737302815, 37.29246829, 252.4413238, 11.47460563], 'GSM7920906': [727.0009692, 3.8397938515, 19.19896926, 273.9052947, 103.674434], 'GSM7920907': [334.2732747, 3.7985599395, 22.79135964, 41.78415933, 41.78415933], 'GSM7920908': [1255.984286, 5.168659615, 21.96680335, 41.3492769, 15.50597884], 'GSM7920909': [1650.89873, 4.602877499, 13.29720166, 975.8100297, 10.22861666], 'GSM7920910': [1163.354877, 1.4889354225, 16.87460146, 118.1222102, 10.91885977], 'GSM7920911': [875.7398222, 3.8186329455, 15.27453178, 136.1979084, 16.54740943], 'GSM7920912': [565.2998279, 2.27943479, 9.117739159, 259.855566, 4.55886958], 'GSM7920913': [899.1672045, 36.16215931, 5.864133942, 107.5091223, 50.82249417], 'GSM7920914': [755.2106866, 14.412417685, 23.05986829, 121.0643085, 40.35476952], 'GSM7920915': [1102.749552, 1.6913336695, 15.22200302, 59.19667843, 13.53066936], 'GSM7920916': [842.4349636, 2.359761803, 7.079285408, 108.5490429, 23.59761803], 'GSM7920917': [672.5183328, 2.49080864, 2.49080864, 361.1672528, 7.47242592], 'GSM7920918': [1125.112406, 1.7973041625, 12.58112914, 95.25712061, 16.17573746], 'GSM7920919': [683.0575722, 2.1753425865, 17.40274069, 52.20822208, 30.45479621], 'GSM7920920': [564.2733356, 5.205473575, 6.246568291, 449.7529169, 4.164378861], 'GSM7920921': [1442.510706, 0.8795796985, 12.31411578, 31.66486915, 40.46066613], 'GSM7920922': [930.9264034, 1.8217737835, 7.287095134, 236.8305919, 10.9306427], 'GSM7920923': [1385.047665, 0.403098855, 18.54254732, 49.17806029, 19.34874503], 'GSM7920924': [883.619798, 3.3112090935, 8.514537669, 49.19510653, 30.27391171], 'GSM7920925': [646.6041056, 3.848833962, 13.47091887, 564.8163839, 6.735459433], 'GSM7920926': [791.0179685, 4.520102677, 9.7935558, 55.74793302, 3.766752231], 'GSM7920927': [869.9017171, 1.314050932, 9.198356525, 99.86787085, 3.942152797], 'GSM7920928': [1430.767953, 12.477627495, 24.95525499, 141.4131116, 24.95525499], 'GSM7920929': [900.3450847, 5.07366595, 15.68224021, 68.26386913, 10.1473319], 'GSM7920930': [684.8234959, 1.638333722, 19.66000467, 437.4351038, 16.38333722], 'GSM7920931': [1036.23772, 5.20069119, 29.90397434, 405.6539129, 14.30190077], 'GSM7920932': [856.5128304, 3.1993542225, 10.96921448, 188.3048485, 10.96921448], 'GSM7920933': [682.6421709, 4.729622431, 13.66335369, 161.8581899, 9.984758466], 'GSM7920934': [1045.242676, 2.4588685695, 14.75321142, 141.273176, 20.11801557], 'GSM7920935': [446.1072029, 2.6370869135, 9.229804198, 66.36668733, 13.62494905], 'GSM7920936': [772.3671647, 1.5365394525, 5.121798174, 80.58295795, 5.121798174], 'GSM7920937': [1524.289921, 3.8363001365, 61.38080219, 319.6916781, 56.26573534], 'GSM7920938': [603.1724974, 5.26022527, 38.5749853, 87.67042113, 10.52045054], 'GSM7920939': [557.0813654, 38.1562579, 129.7312769, 488.4001011, 22.89375474], 'GSM7920940': [3864.873543, 22.29734736, 34.68476256, 1868.022212, 79.27945728], 'GSM7920941': [786.1215666, 8.08767044, 54.99615898, 210.2794314, 22.64547723], 'GSM7920942': [706.7051947, 8.908048675, 71.26438938, 172.2222743, 71.26438938], 'GSM7920943': [813.7283435, 2.966202953, 11.86481181, 127.546727, 302.5527012], 'GSM7920944': [1735.727103, 30.19797532, 60.39595064, 2927.890651, 39.38866346], 'GSM7920945': [852.1251879, 4.1516452515, 13.49284707, 1079.427765, 16.60658101], 'GSM7920946': [619.1013452, 4.7477097025, 13.29358717, 225.9909818, 24.68809045], 'GSM7920947': [4761.409345, 4.767766367, 30.19585366, 2169.333697, 32.57973684], 'GSM7920948': [708.1495689, 4.539420313, 13.61826094, 16.64454115, 40.85478282], 'GSM7920949': [984.7251665, 4.053479006, 9.187885746, 336.7089894, 10.80927735], 'GSM7920950': [1902.245945, 3.1567307425, 9.470192228, 128.1632681, 31.56730743], 'GSM7920951': [3241.612289, 11.35415863, 62.44787247, 760.7286282, 96.51034836], 'GSM7920952': [647.6916629, 2.5333441835, 8.444480611, 68.40029295, 32.93347438], 'GSM7920953': [974.9914928, 3.0660109835, 7.358426361, 163.1117843, 24.52808787], 'GSM7920954': [637.7321288, 497.6668417, 10.10491049, 203.2209777, 5.052455246], 'GSM7920955': [870.3738625, 3.4610932165, 5.100558424, 492.5682135, 49.18395623], 'GSM7920956': [1410.077887, 2.982398238, 26.2451045, 638.233223, 16.70143013], 'GSM7920957': [803.9671821, 6.20824079, 29.48914375, 395.7753503, 217.2884276], 'GSM7920958': [4767.508923, 16.274006405, 37.19772892, 1275.572121, 128.6421458], 'GSM7920959': [985.1052045, 12.43122103, 60.22235967, 138.6771768, 34.80741889], 'GSM7920960': [2320.526278, 6.340235735, 82.42306453, 2155.680149, 31.70117867], 'GSM7920961': [1737.14414, 3.838013905, 13.58066459, 77.35074177, 17.71391033], 'GSM7920962': [991.2367349, 7.509369205, 24.02998145, 36.04497218, 93.11617813], 'GSM7920963': [425.5608074, 5.78994296, 14.47485739, 749.797613, 14.47485739], 'GSM7920964': [1088.312136, 5.36775406, 20.12907773, 218.735978, 24.15489328], 'GSM7920965': [2080.419805, 10.11423241, 28.00864359, 1068.996564, 133.8190749], 'GSM7920966': [340.2781231, 4.759134589, 9.518269178, 41.64242766, 7.138701884], 'GSM7920967': [1361.959571, 4.838222278, 18.54651873, 270.9404476, 8.870074176], 'GSM7920968': [1190.224102, 4.5329535995, 15.5415552, 497.3297663, 23.3123328], 'GSM7920969': [439.9285205, 41.415864895, 23.92916639, 76.38926192, 22.08846128], 'GSM7920970': [1209.28559, 3.314408429, 7.575790695, 314.8688008, 21.78039825], 'GSM7920971': [415.9935374, 16.06479108, 33.8206128, 275.6379943, 52.42194984], 'GSM7920972': [846.0966894, 49.125914715, 12.72325849, 323.029396, 33.9286893], 'GSM7920973': [1155.715406, 5.92674567, 15.24020315, 668.8755829, 16.93355906], 'GSM7920974': [488.2513382, 2.1197597895, 16.95807832, 132.8382802, 4.946106176], 'GSM7920975': [2752.770843, 3.521067847, 23.23904779, 892.2385924, 13.38005782], 'GSM7920976': [1083.25824, 9.46242348, 12.86889594, 265.7048514, 9.840920421], 'GSM7920977': [969.5993214, 1.6941164615, 5.647054871, 80.75288466, 10.72940426], 'GSM7920978': [337.6856469, 5.858899235, 12.78305288, 17.04407051, 60.71950118], 'GSM7920979': [763.4578769, 5.2202248, 12.3980339, 367.3733202, 48.28707939], 'GSM7920980': [14036.13736, 3.276409282, 27.30341068, 273.0341068, 50.23827565], 'GSM7920981': [3040.87558, 4.2859416215, 12.85782486, 921.4774486, 11.42917766], 'GSM7920982': [915.1282964, 11.92608553, 10.33594079, 412.6425593, 137.5475198], 'GSM7920983': [3044.326313, 4.101023322, 60.83184594, 1465.432334, 22.55562827], 'GSM7920984': [1294.399173, 4.024873051, 19.31939065, 281.7411136, 38.63878129], 'GSM7920985': [1664.999549, 4.377737641, 17.51095056, 507.8175664, 46.69586817], 'GSM7920986': [2376.723923, 3.9385301525, 5.01267474, 210.5323391, 13.60583144], 'GSM7920987': [953.0014456, 9.724504545, 126.4185591, 58.34702728, 116.6940546], 'GSM7920988': [1773.124377, 3.9895298485, 7.979059697, 68.26528852, 127.6649552], 'GSM7920989': [1038.397132, 2.4261615235, 21.0267332, 237.7638293, 21.0267332], 'GSM7920990': [1560.690901, 4.6488665125, 17.26721847, 336.0466365, 53.79402679], 'GSM7920991': [1588.57449, 6.800404495, 27.20161799, 195.8516495, 100.6459866], 'GSM7920992': [5332.384031, 2.0076747105, 11.24297838, 297.1358571, 21.68288687], 'GSM7920993': [1463.653229, 4.8465338715, 14.16679132, 44.73723573, 12.67555012], 'GSM7920994': [557.6234556, 7.32546737, 19.97854738, 234.8589236, 28.85790176], 'GSM7920995': [1593.458585, 10.56670149, 33.81344478, 460.7081851, 97.21365373], 'GSM7920996': [1886.551516, 3.5284629355, 11.76154312, 532.7979033, 5.880771559], 'GSM7920997': [1305.311912, 3.4864100205, 7.670102045, 179.8987571, 13.94564008], 'GSM7920998': [2825.827656, 3.7181942835, 9.08891936, 876.6675856, 20.65663491], 'GSM7920999': [703.6324617, 0.979989501, 1.959979002, 391.9958004, 22.53975852], 'GSM7921000': [1556.025862, 2.2186680545, 12.57245231, 41.41513702, 17.74934444], 'GSM7921001': [1712.451407, 3.0711108455, 11.05599904, 103.1893244, 15.9697764], 'GSM7921002': [851.8895597, 42.287363055, 9.449690069, 20.31683365, 74.18006704], 'GSM7921003': [934.1955926, 1.726338212, 7.398592338, 145.5056493, 10.35802927], 'GSM7921004': [1118.147467, 3.1369473815, 15.3361872, 158.9386673, 7.668093599], 'GSM7921005': [1099.07007, 3.3431789195, 127.0407989, 70.2067573, 21.73066298], 'GSM7921006': [816.1862139, 1.297593345, 7.136763397, 68.44804894, 9.40755175], 'GSM7921007': [298.6356886, 2.1331120615, 14.93178443, 87.45759453, 10.66556031], 'GSM7921008': [989.6545812, 4.314389522, 13.27504468, 1051.383539, 3.318761171], 'GSM7921009': [2727.525241, 5.76034898, 14.40087245, 561.6340254, 15.36093061], 'GSM7921010': [802.5173916, 2.020436535, 7.273571525, 68.69484218, 4.04087307], 'GSM7921011': [1377.642225, 6.01966016, 22.78871346, 27.94842217, 25.79854354], 'GSM7921012': [1966.398894, 3.237758882, 18.34730033, 283.3039022, 16.18879441], 'GSM7921013': [720.9247893, 3.3100311725, 9.930093517, 137.6972968, 6.620062345], 'GSM7921014': [892.9852231, 4.0892282685, 15.84575954, 179.9260438, 7.156149469], 'GSM7921015': [1931.453238, 8.047721825, 8.521117226, 329.4831994, 25.56335168], 'GSM7921016': [2750.165328, 2.752918246, 15.14105035, 814.8638008, 34.41147807], 'GSM7921017': [1408.068462, 1.6976367955, 7.76062535, 135.8109436, 5.820469013], 'GSM7921018': [827.9251138, 1.5339047965, 9.586904977, 8.819952579, 11.88776217], 'GSM7921019': [2252.513324, 4.095478771, 15.56281933, 11.46734056, 56.51760704], 'GSM7921020': [2194.44044, 5.667947755, 8.501921634, 670.7071511, 36.84166041], 'GSM7921021': [1784.661093, 7.196214085, 34.18201689, 802.3778703, 10.79432112], 'GSM7921022': [994.6685269, 1.6447598625, 2.87832976, 143.916488, 11.10212907], 'GSM7921023': [3644.350795, 5.436379, 27.67611127, 1408.516377, 14.82648818], 'GSM7921024': [3472.934679, 17.82007532, 102.9604352, 59.40025107, 15.84006695], 'GSM7921025': [693.2136762, 1.8505437165, 6.291848636, 126.9472989, 13.6940235], 'GSM7921026': [358.3994916, 3.1886075765, 3.826329092, 62.4967085, 10.20354424], 'GSM7921027': [1479.27028, 2.3304770065, 6.99143102, 405.5029992, 83.31455299], 'GSM7921028': [699.3124058, 51.80091895, 155.4027568, 297.8552839, 77.70137842], 'GSM7921029': [2171.199379, 16.30219682, 5.064760178, 26.27344342, 21.52523075], 'GSM7921030': [883.1386774, 1.926147606, 5.296905917, 17.33532846, 11.07534874], 'GSM7921031': [2718.148186, 5.277957645, 36.9457035, 237.5080939, 126.6709834], 'GSM7921032': [604.2061855, 15.900162775, 95.40097665, 59.05774745, 249.8597008], 'GSM7921033': [1069.332665, 1.4698730795, 8.084301937, 23.51796927, 9.554175017], 'GSM7921034': [760.5952337, 2.254728954, 4.133669749, 188.6456558, 4.885246066], 'GSM7921035': [901.857972, 0.949324181, 6.01238648, 171.194794, 12.02477296], 'GSM7921036': [2951.955817, 4.8787914525, 9.18360744, 1071.038218, 13.2014357], 'GSM7921037': [2022.428769, 1.1144905045, 17.0888544, 146.3697529, 15.60286706], 'GSM7921038': [688.5484761, 1.052826416, 8.949024536, 34.21685852, 20.0037019], 'GSM7921039': [1707.028443, 4.2169674975, 15.18108299, 388.8044033, 15.18108299], 'GSM7921040': [2595.648821, 1.57248515, 10.48323433, 1332.943246, 3.1449703], 'GSM7921041': [1968.208394, 27.814519705, 15.23176079, 396.0257805, 38.41052721], 'GSM7921042': [1069.944954, 7.18996791, 5.829703711, 260.0047855, 139.5242421], 'GSM7921043': [1782.75509, 3.6198072885, 12.66932551, 229.8577628, 16.2891328], 'GSM7921044': [451.7149521, 20.532497825, 164.2599826, 61.59749347, 195.0587293], 'GSM7921045': [1569.532179, 6.130985075, 47.0042189, 32.69858706, 22.48027861], 'GSM7921046': [3472.111714, 1.5376934075, 70.73389674, 525.8911453, 92.26160445], 'GSM7921047': [893.0264895, 0.5530717315, 7.743004244, 372.4016327, 16.22343746], 'GSM7921048': [1781.130006, 10.21680692, 136.2240923, 47.67843229, 27.24481845], 'GSM7921049': [1442.810741, 19.417925965, 5.884219989, 142.9865457, 10.59159598], 'GSM7921050': [674.6249892, 1.6559278085, 9.273195728, 101.3427819, 13.24742247], 'GSM7921051': [1640.7273, 2.4635545045, 18.61352292, 73.90663514, 14.23387047], 'GSM7921052': [1052.19818, 1.4104533245, 12.69407992, 26.0933865, 7.757493285], 'GSM7921053': [1362.683445, 345.97625925, 165.271187, 110.6095104, 53.37551955], 'GSM7921054': [814.6097859, 2.776593397, 11.96071002, 239.2142004, 15.80522395], 'GSM7921055': [1378.517556, 1.6852292865, 27.80628323, 291.5446665, 26.12105394], 'GSM7921056': [9579.961326, 16.146002235, 139.9320194, 3358.368465, 32.29200447], 'GSM7921057': [1049.048347, 5.011377455, 23.38642812, 256.1370699, 11.13639435], 'GSM7921058': [839.7400644, 2.1568666035, 37.3856878, 159.6081287, 23.00657711], 'GSM7921059': [1614.369428, 4.242758024, 36.06344321, 190.9241111, 55.15585431], 'GSM7921060': [1947.433991, 34.046048785, 21.24473444, 107.8578826, 65.91315045], 'GSM7921061': [1420.05587, 1.5978125125, 8.38851569, 315.5679712, 7.190156306], 'GSM7921062': [1384.819929, 2.698139169, 19.56150898, 82.96777945, 23.60871773], 'GSM7921063': [785.2749089, 1.461947969, 11.27788433, 32.58055473, 67.66730598], 'GSM7921064': [1549.20602, 4.81119882, 25.98047363, 308.8789642, 14.43359646], 'GSM7921065': [1283.867007, 0.559337935, 9.695190872, 48.10306241, 5.220487393]}\n", "\n", "Sample genes in the resulting dataset:\n", "['A2M', 'A6', 'ACVR1C', 'ADAM12', 'ADGRE1', 'ADM', 'ADORA2A', 'AKT1', 'ALDOA', 'ALDOC', 'ANGPT1', 'ANGPT2', 'ANGPTL4', 'ANLN', 'APC', 'APH1B', 'API5', 'APLNR', 'APM', 'APOE']\n", "\n", "Gene expression data saved to ../../output/preprocess/Large_B-cell_Lymphoma/gene_data/GSE248835.csv\n" ] } ], "source": [ "# 1. Analyze gene annotation data and determine mapping columns\n", "print(\"\\nAnalyzing gene annotation data to determine mapping columns...\")\n", "\n", "# Based on our observation, 'ID' column in gene_annotation matches the numeric indices in gene_data\n", "# For gene symbols, we need to check which column contains valid gene symbols\n", "# Looking at the preview, 'Gene_Signature_Name' appears to contain gene signature names\n", "\n", "# Let's check both 'Gene_Signature_Name' and 'SPOT_ID' to see which one has proper gene symbols\n", "# Display some unique values from both columns\n", "print(\"Sample Gene_Signature_Name values:\")\n", "print(gene_annotation['Gene_Signature_Name'].dropna().unique()[:10])\n", "\n", "print(\"\\nSample SPOT_ID values:\")\n", "print(gene_annotation['SPOT_ID'].dropna().unique()[:10])\n", "\n", "# Check if we have actual human gene symbols by looking at the data patterns\n", "gene_symbols_count = gene_annotation['Gene_Signature_Name'].apply(lambda x: \n", " bool(extract_human_gene_symbols(str(x)) if pd.notna(x) else False)).sum()\n", "print(f\"\\nNumber of rows with potential human gene symbols in Gene_Signature_Name: {gene_symbols_count}\")\n", "\n", "spot_id_symbols_count = gene_annotation['SPOT_ID'].apply(lambda x: \n", " bool(extract_human_gene_symbols(str(x)) if pd.notna(x) else False)).sum()\n", "print(f\"Number of rows with potential human gene symbols in SPOT_ID: {spot_id_symbols_count}\")\n", "\n", "# Based on the analysis, determine which columns to use for mapping\n", "# We need to determine the appropriate column for gene symbols\n", "# For this dataset, we'll use Gene_Signature_Name as it may contain the signature or gene names\n", "\n", "# 2. Create the gene mapping dataframe\n", "print(\"\\nCreating gene mapping dataframe...\")\n", "mapping_df = get_gene_mapping(gene_annotation, 'ID', 'Gene_Signature_Name')\n", "print(f\"Created mapping dataframe with {len(mapping_df)} rows\")\n", "print(\"Mapping preview:\")\n", "print(preview_df(mapping_df))\n", "\n", "# 3. Apply gene mapping to convert probe-level data to gene expression data\n", "print(\"\\nConverting probe-level measurements to gene expression data...\")\n", "# Fix: Use the gene_data variable we extracted earlier (in step 3) \n", "# rather than the undefined genetic_data\n", "gene_expression_data = apply_gene_mapping(gene_data, mapping_df)\n", "print(f\"Successfully created gene expression data with {len(gene_expression_data)} rows (genes)\")\n", "\n", "# Preview the gene expression data\n", "print(\"\\nGene expression data preview (first few genes):\")\n", "gene_preview = gene_expression_data.head(5)\n", "print(f\"Shape: {gene_preview.shape}\")\n", "print(preview_df(gene_preview))\n", "\n", "# Check for actual genes in the resulting gene expression data\n", "sample_genes = gene_expression_data.index.tolist()[:20]\n", "print(\"\\nSample genes in the resulting dataset:\")\n", "print(sample_genes)\n", "\n", "# Save gene data to file\n", "os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)\n", "gene_expression_data.to_csv(out_gene_data_file)\n", "print(f\"\\nGene expression data saved to {out_gene_data_file}\")\n" ] }, { "cell_type": "markdown", "id": "8b993d32", "metadata": {}, "source": [ "### Step 7: Data Normalization and Linking" ] }, { "cell_type": "code", "execution_count": null, "id": "98f7085d", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "id": "1197dfa6", "metadata": {}, "source": [ "### Step 8: Data Normalization and Linking" ] }, { "cell_type": "code", "execution_count": 8, "id": "4d396a4f", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T07:27:15.727921Z", "iopub.status.busy": "2025-03-25T07:27:15.727813Z", "iopub.status.idle": "2025-03-25T07:27:15.895236Z", "shell.execute_reply": "2025-03-25T07:27:15.894888Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Saving normalized gene data...\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Normalized gene data saved to ../../output/preprocess/Large_B-cell_Lymphoma/gene_data/GSE248835.csv\n", "\n", "Extracting clinical data...\n", "Clinical data saved to ../../output/preprocess/Large_B-cell_Lymphoma/clinical_data/GSE248835.csv\n", "Clinical data shape: (3, 256)\n", "Trait information available: False\n", "\n", "Linking clinical and genetic data...\n", "Cannot link data: clinical data is not available\n", "\n", "Skipping missing value handling and bias evaluation as linked data is not available\n", "\n", "Performing final validation...\n", "Abnormality detected in the cohort: GSE248835. Preprocessing failed.\n", "\n", "Dataset usability for Large_B-cell_Lymphoma association studies: False\n", "Reason: Dataset does not contain required trait information\n" ] } ], "source": [ "# 1. Save the normalized gene expression data from the previous step\n", "print(\"\\nSaving normalized gene data...\")\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\"Normalized gene data saved to {out_gene_data_file}\")\n", "\n", "# 2. Extract clinical data from the matrix file\n", "print(\"\\nExtracting clinical data...\")\n", "try:\n", " # Get the file paths again to make sure we have them\n", " soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)\n", " \n", " # Extract background information and clinical data\n", " background_info, clinical_data = get_background_and_clinical_data(\n", " matrix_file, \n", " prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],\n", " prefixes_b=['!Sample_geo_accession', '!Sample_characteristics_ch1']\n", " )\n", " \n", " # Process clinical data using trait information from Step 2\n", " trait_row = 1 # Based on analysis in step 2 - group (OW/OB vs NW/MONW)\n", " gender_row = 0 # Gender data\n", " age_row = 2 # Age data\n", " \n", " # Define conversion functions based on Step 2\n", " def convert_trait(value):\n", " \"\"\"Convert trait value (binary: 1 for OW/OB, 0 for NW/MONW)\"\"\"\n", " if pd.isna(value):\n", " return None\n", " \n", " # Extract value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip()\n", " \n", " if 'OW/OB' in value:\n", " return 1 # Overweight/Obese is associated with higher LDL cholesterol\n", " elif 'NW' in value or 'MONW' in value:\n", " return 0 # Normal weight (includes metabolically obese normal weight)\n", " else:\n", " return None\n", "\n", " def convert_gender(value):\n", " \"\"\"Convert gender value to binary (0: female, 1: male)\"\"\"\n", " if pd.isna(value):\n", " return None\n", " \n", " # Extract value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip()\n", " \n", " # Convert gender\n", " if value.lower() == 'woman':\n", " return 0\n", " elif value.lower() == 'man':\n", " return 1\n", " else:\n", " return None\n", " \n", " def convert_age(value):\n", " \"\"\"Convert age value to float\"\"\"\n", " if pd.isna(value):\n", " return None\n", " \n", " # Extract value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip()\n", " \n", " try:\n", " return float(value) # Convert to float for continuous variable\n", " except:\n", " return None\n", " \n", " # Extract clinical features\n", " selected_clinical_df = geo_select_clinical_features(\n", " clinical_df=clinical_data,\n", " trait=trait,\n", " trait_row=trait_row,\n", " convert_trait=convert_trait,\n", " age_row=age_row,\n", " convert_age=convert_age,\n", " gender_row=gender_row,\n", " convert_gender=convert_gender\n", " )\n", " \n", " # Save the clinical data\n", " os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)\n", " selected_clinical_df.to_csv(out_clinical_data_file)\n", " print(f\"Clinical data saved to {out_clinical_data_file}\")\n", " print(f\"Clinical data shape: {selected_clinical_df.shape}\")\n", " \n", " # Check if we have valid trait information\n", " is_trait_available = trait_row is not None and not selected_clinical_df.loc[trait].isnull().all()\n", " print(f\"Trait information available: {is_trait_available}\")\n", " \n", "except Exception as e:\n", " print(f\"Error extracting clinical data: {e}\")\n", " is_trait_available = False\n", " selected_clinical_df = pd.DataFrame()\n", "\n", "# 3. Link clinical and genetic data\n", "print(\"\\nLinking clinical and genetic data...\")\n", "try:\n", " if is_trait_available and not selected_clinical_df.empty:\n", " # Link clinical and genetic data\n", " linked_data = geo_link_clinical_genetic_data(selected_clinical_df, gene_data)\n", " print(f\"Created linked data with {linked_data.shape[0]} samples and {linked_data.shape[1]} features\")\n", " else:\n", " print(\"Cannot link data: clinical data is not available\")\n", " linked_data = pd.DataFrame()\n", " is_trait_available = False\n", "except Exception as e:\n", " print(f\"Error linking clinical and genetic data: {e}\")\n", " is_trait_available = False\n", " linked_data = pd.DataFrame()\n", "\n", "# 4. Handle missing values in the linked data\n", "if is_trait_available and not linked_data.empty:\n", " print(\"\\nHandling missing values...\")\n", " try:\n", " # Rename the first column to the trait name for consistency\n", " if linked_data.columns[0] != trait:\n", " linked_data = linked_data.rename(columns={linked_data.columns[0]: trait})\n", " \n", " linked_data = handle_missing_values(linked_data, trait)\n", " print(f\"After handling missing values: {linked_data.shape[0]} samples and {linked_data.shape[1]} features\")\n", " except Exception as e:\n", " print(f\"Error handling missing values: {e}\")\n", " \n", " # 5. Determine whether the trait and demographic features are biased\n", " print(\"\\nEvaluating feature bias...\")\n", " try:\n", " is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)\n", " print(f\"Trait bias determination: {is_biased}\")\n", " print(f\"Final linked data shape: {linked_data.shape[0]} samples and {linked_data.shape[1]} features\")\n", " except Exception as e:\n", " print(f\"Error evaluating feature bias: {e}\")\n", " is_biased = True\n", "else:\n", " print(\"\\nSkipping missing value handling and bias evaluation as linked data is not available\")\n", " is_biased = True\n", "\n", "# 6. Validate and save cohort information\n", "print(\"\\nPerforming final validation...\")\n", "note = \"\"\n", "if not is_trait_available:\n", " note = \"Dataset does not contain required trait information\"\n", "elif is_biased:\n", " note = \"Dataset has severe bias in the trait distribution\"\n", "\n", "is_usable = validate_and_save_cohort_info(\n", " is_final=True,\n", " cohort=cohort,\n", " info_path=json_path,\n", " is_gene_available=is_gene_available,\n", " is_trait_available=is_trait_available,\n", " is_biased=is_biased,\n", " df=linked_data,\n", " note=note\n", ")\n", "\n", "# 7. Save the linked data if usable\n", "print(f\"\\nDataset usability for {trait} association studies: {is_usable}\")\n", "if is_usable:\n", " os.makedirs(os.path.dirname(out_data_file), exist_ok=True)\n", " linked_data.to_csv(out_data_file)\n", " print(f\"Final linked data saved to {out_data_file}\")\n", "else:\n", " if note:\n", " print(f\"Reason: {note}\")\n", " else:\n", " print(\"Dataset does not meet quality criteria for the specified 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 }