{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "fe6d2bac", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:30.744214Z", "iopub.status.busy": "2025-03-25T04:08:30.744047Z", "iopub.status.idle": "2025-03-25T04:08:30.911267Z", "shell.execute_reply": "2025-03-25T04:08:30.910909Z" } }, "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 = \"Telomere_Length\"\n", "cohort = \"GSE80435\"\n", "\n", "# Input paths\n", "in_trait_dir = \"../../input/GEO/Telomere_Length\"\n", "in_cohort_dir = \"../../input/GEO/Telomere_Length/GSE80435\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Telomere_Length/GSE80435.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Telomere_Length/gene_data/GSE80435.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Telomere_Length/clinical_data/GSE80435.csv\"\n", "json_path = \"../../output/preprocess/Telomere_Length/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "348740ad", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "555ae9d1", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:30.912697Z", "iopub.status.busy": "2025-03-25T04:08:30.912553Z", "iopub.status.idle": "2025-03-25T04:08:30.994955Z", "shell.execute_reply": "2025-03-25T04:08:30.994650Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Files in the cohort directory:\n", "['GSE80435-GPL10558_series_matrix.txt.gz', 'GSE80435-GPL6884_series_matrix.txt.gz', 'GSE80435_family.soft.gz']\n", "Identified SOFT files: ['GSE80435_family.soft.gz']\n", "Identified matrix files: ['GSE80435-GPL10558_series_matrix.txt.gz', 'GSE80435-GPL6884_series_matrix.txt.gz']\n", "\n", "Background Information:\n", "!Series_title\t\"Whole genome landscapes of major melanoma subtypes\"\n", "!Series_summary\t\"Cutaneous, acral and mucosal subtypes of melanoma were evaluated by whole-genome sequencing, revealing genes affected by novel recurrent mutations to the promoter (TERT, DPH3, OXNAD1, RPL13A, RALY, RPL18A, AP2A1), 5’-UTR (HNRNPUL1, CCDC77, PES1), and 3’-UTR (DYNAP, CHIT1, FUT9, CCDC141, CDH9, PTPRT) regions. TERT promoter mutations had the highest frequency of any mutation, but neither they nor ATRX mutations, associated with the alternative telomere lengthening mechanism, were correlated with greater telomere length. Genomic landscapes largely reflected ultraviolet radiation mutagenesis in cutaneous melanoma and provided novel insights into melanoma pathogenesis. In contrast, acral and mucosal melanomas exhibited predominantly structural changes, and mutation signatures of unknown aetiology not previously identified in melanoma. The majority of melanomas had potentially actionable mutations, most of which were in components of the mitogen-activated protein kinase and phosphoinositol kinase pathways.\"\n", "!Series_overall_design\t\"Expression arrays from 65 of the 183 tumours analysed were used to determine gene expression levels of genes with recurrent promoter and 3' and 5' UTR mutations. A total of 32 samples is available at GSE54467; the remaining 33 samples are submitted here. The 27 primary melanoma samples (AJCC stage II) were assayed using the HumanHT-12 v4 Expression BeadChip (Illumina® Inc., San Diego, CA, USA; Catalog IDs: BD-103-0204, BD-103-0604). The remaining 6 metastatic (AJCC stage IV) samples were assayed using the HumanWG-6 v3 Expression BeadChip ((Illumina® Inc., San Diego, CA, USA; Catalog IDs: BD-101-0203, BD-101-0603). NEQC normalisation (default parameters) was separately applied to each of the AJCC stage II and IV datasets (http://nar.oxfordjournals.org/content/38/22/e204). Probes for which there were no samples with a detection p-value of less than 0.01 were removed.\"\n", "\n", "Sample Characteristics Dictionary:\n", "{0: ['region: Shoulder', 'region: Great toe (Query Toenail)', 'region: Cheek', 'region: Forearm', 'region: Vulva', 'region: Foot - Sole', 'region: Shoulder (Query Thorax)', 'region: Thorax', 'region: Chin', 'region: Thigh', 'region: Forearm (Query Upper Arm)', 'region: Abdomen', 'region: Shin', 'region: Upper Arm', 'region: Ear', 'region: Lower Lip', 'region: Thorax (Query Upper Arm Lateral)', 'region: Scalp', 'region: Little Finger']}\n" ] } ], "source": [ "# 1. Let's first list the directory contents to understand what files are available\n", "import os\n", "\n", "print(\"Files in the cohort directory:\")\n", "files = os.listdir(in_cohort_dir)\n", "print(files)\n", "\n", "# Adapt file identification to handle different naming patterns\n", "soft_files = [f for f in files if 'soft' in f.lower() or '.soft' in f.lower() or '_soft' in f.lower()]\n", "matrix_files = [f for f in files if 'matrix' in f.lower() or '.matrix' in f.lower() or '_matrix' in f.lower()]\n", "\n", "# If no files with these patterns are found, look for alternative file types\n", "if not soft_files:\n", " soft_files = [f for f in files if f.endswith('.txt') or f.endswith('.gz')]\n", "if not matrix_files:\n", " matrix_files = [f for f in files if f.endswith('.txt') or f.endswith('.gz')]\n", "\n", "print(\"Identified SOFT files:\", soft_files)\n", "print(\"Identified matrix files:\", matrix_files)\n", "\n", "# Use the first files found, if any\n", "if len(soft_files) > 0 and len(matrix_files) > 0:\n", " soft_file = os.path.join(in_cohort_dir, soft_files[0])\n", " matrix_file = os.path.join(in_cohort_dir, matrix_files[0])\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(\"\\nBackground Information:\")\n", " print(background_info)\n", " print(\"\\nSample Characteristics Dictionary:\")\n", " print(sample_characteristics_dict)\n", "else:\n", " print(\"No appropriate files found in the directory.\")\n" ] }, { "cell_type": "markdown", "id": "c07cba73", "metadata": {}, "source": [ "### Step 2: Dataset Analysis and Clinical Feature Extraction" ] }, { "cell_type": "code", "execution_count": 3, "id": "6f8b298b", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:30.996240Z", "iopub.status.busy": "2025-03-25T04:08:30.996132Z", "iopub.status.idle": "2025-03-25T04:08:31.002518Z", "shell.execute_reply": "2025-03-25T04:08:31.002250Z" } }, "outputs": [ { "data": { "text/plain": [ "False" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 1. Gene Expression Data Availability\n", "# Based on background information, this dataset contains gene expression data\n", "is_gene_available = True\n", "\n", "# 2. Variable Availability and Data Type Conversion\n", "# 2.1 Data Availability\n", "# From the sample characteristics dictionary, the only entry with index 0 contains\n", "# 'region' values which don't have telomere length, age, or gender information\n", "trait_row = None # Telomere length data is not available\n", "age_row = None # Age data is not available\n", "gender_row = None # Gender data is not available\n", "\n", "# 2.2 Data Type Conversion Functions\n", "# Although these won't be used since the data is not available, we define them as required\n", "def convert_trait(value):\n", " \"\"\"Convert telomere length values to float.\"\"\"\n", " if not value or 'NA' in value or 'na' in value.lower():\n", " return None\n", " # Extract value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip()\n", " try:\n", " return float(value)\n", " except:\n", " return None\n", "\n", "def convert_age(value):\n", " \"\"\"Convert age values to float.\"\"\"\n", " if not value or 'NA' in value or 'na' in value.lower():\n", " return None\n", " # Extract value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip()\n", " try:\n", " return float(value)\n", " except:\n", " return None\n", "\n", "def convert_gender(value):\n", " \"\"\"Convert gender values to binary (0 for female, 1 for male).\"\"\"\n", " if not value:\n", " return None\n", " # Extract value after colon if present\n", " if ':' in value:\n", " value = value.split(':', 1)[1].strip().lower()\n", " \n", " if 'female' in value or 'f' == value:\n", " return 0\n", " elif 'male' in value or 'm' == value:\n", " return 1\n", " return None\n", "\n", "# 3. Save Metadata\n", "# is_trait_available is False because trait_row is None\n", "is_trait_available = trait_row is not None\n", "validate_and_save_cohort_info(\n", " is_final=False,\n", " cohort=cohort,\n", " info_path=json_path,\n", " is_gene_available=is_gene_available,\n", " is_trait_available=is_trait_available\n", ")\n", "\n", "# 4. Clinical Feature Extraction\n", "# We skip this substep because trait_row is None (clinical data is not available)\n" ] }, { "cell_type": "markdown", "id": "3de8ed4d", "metadata": {}, "source": [ "### Step 3: Gene Data Extraction" ] }, { "cell_type": "code", "execution_count": 4, "id": "3003fa99", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:31.003737Z", "iopub.status.busy": "2025-03-25T04:08:31.003637Z", "iopub.status.idle": "2025-03-25T04:08:31.100390Z", "shell.execute_reply": "2025-03-25T04:08:31.100017Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "First 20 gene/probe identifiers:\n", "Index(['ILMN_1343291', 'ILMN_1343295', 'ILMN_1651210', 'ILMN_1651228',\n", " 'ILMN_1651229', 'ILMN_1651232', 'ILMN_1651237', 'ILMN_1651253',\n", " 'ILMN_1651254', 'ILMN_1651259', 'ILMN_1651262', 'ILMN_1651268',\n", " 'ILMN_1651278', 'ILMN_1651279', 'ILMN_1651282', 'ILMN_1651285',\n", " 'ILMN_1651288', 'ILMN_1651296', 'ILMN_1651315', 'ILMN_1651316'],\n", " dtype='object', name='ID')\n", "\n", "Gene expression data shape: (28118, 27)\n" ] } ], "source": [ "# Use the helper function to get the proper file paths\n", "soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)\n", "\n", "# Extract gene expression data\n", "try:\n", " gene_data = get_genetic_data(matrix_file_path)\n", " \n", " # Print the first 20 row IDs (gene or probe identifiers)\n", " print(\"First 20 gene/probe identifiers:\")\n", " print(gene_data.index[:20])\n", " \n", " # Print shape to understand the dataset dimensions\n", " print(f\"\\nGene expression data shape: {gene_data.shape}\")\n", " \n", "except Exception as e:\n", " print(f\"Error extracting gene data: {e}\")\n" ] }, { "cell_type": "markdown", "id": "67c94cc4", "metadata": {}, "source": [ "### Step 4: Gene Identifier Review" ] }, { "cell_type": "code", "execution_count": 5, "id": "d9bdf232", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:31.101679Z", "iopub.status.busy": "2025-03-25T04:08:31.101569Z", "iopub.status.idle": "2025-03-25T04:08:31.103377Z", "shell.execute_reply": "2025-03-25T04:08:31.103104Z" } }, "outputs": [], "source": [ "# The identifiers starting with \"ILMN_\" are Illumina probe IDs, not human gene symbols.\n", "# These are specific probes used on Illumina microarray platforms and need to be mapped to gene symbols.\n", "\n", "requires_gene_mapping = True\n" ] }, { "cell_type": "markdown", "id": "1773023b", "metadata": {}, "source": [ "### Step 5: Gene Annotation" ] }, { "cell_type": "code", "execution_count": 6, "id": "2cd7e32d", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:31.104426Z", "iopub.status.busy": "2025-03-25T04:08:31.104327Z", "iopub.status.idle": "2025-03-25T04:08:33.765746Z", "shell.execute_reply": "2025-03-25T04:08:33.765427Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gene annotation preview:\n", "{'ID': ['ILMN_1825594', 'ILMN_1810803', 'ILMN_1722532', 'ILMN_1884413', 'ILMN_1906034'], 'Species': ['Homo sapiens', 'Homo sapiens', 'Homo sapiens', 'Homo sapiens', 'Homo sapiens'], 'Source': ['Unigene', 'RefSeq', 'RefSeq', 'Unigene', 'Unigene'], 'Search_Key': ['ILMN_89282', 'ILMN_35826', 'ILMN_25544', 'ILMN_132331', 'ILMN_105017'], 'Transcript': ['ILMN_89282', 'ILMN_35826', 'ILMN_25544', 'ILMN_132331', 'ILMN_105017'], 'ILMN_Gene': ['HS.388528', 'LOC441782', 'JMJD1A', 'HS.580150', 'HS.540210'], 'Source_Reference_ID': ['Hs.388528', 'XM_497527.2', 'NM_018433.3', 'Hs.580150', 'Hs.540210'], 'RefSeq_ID': [nan, 'XM_497527.2', 'NM_018433.3', nan, nan], 'Unigene_ID': ['Hs.388528', nan, nan, 'Hs.580150', 'Hs.540210'], 'Entrez_Gene_ID': [nan, 441782.0, 55818.0, nan, nan], 'GI': [23525203.0, 89042416.0, 46358420.0, 7376124.0, 5437312.0], 'Accession': ['BU678343', 'XM_497527.2', 'NM_018433.3', 'AW629334', 'AI818233'], 'Symbol': [nan, 'LOC441782', 'JMJD1A', nan, nan], 'Protein_Product': [nan, 'XP_497527.2', 'NP_060903.2', nan, nan], 'Array_Address_Id': [1740241.0, 1850750.0, 1240504.0, 4050487.0, 2190598.0], 'Probe_Type': ['S', 'S', 'S', 'S', 'S'], 'Probe_Start': [349.0, 902.0, 4359.0, 117.0, 304.0], 'SEQUENCE': ['CTCTCTAAAGGGACAACAGAGTGGACAGTCAAGGAACTCCACATATTCAT', 'GGGGTCAAGCCCAGGTGAAATGTGGATTGGAAAAGTGCTTCCCTTGCCCC', 'CCAGGCTGTAAAAGCAAAACCTCGTATCAGCTCTGGAACAATACCTGCAG', 'CCAGACAGGAAGCATCAAGCCCTTCAGGAAAGAATATGCGAGAGTGCTGC', 'TGTGCAGAAAGCTGATGGAAGGGAGAAAGAATGGAAGTGGGTCACACAGC'], 'Chromosome': [nan, nan, '2', nan, nan], 'Probe_Chr_Orientation': [nan, nan, '+', nan, nan], 'Probe_Coordinates': [nan, nan, '86572991-86573040', nan, nan], 'Cytoband': [nan, nan, '2p11.2e', nan, nan], 'Definition': ['UI-CF-EC0-abi-c-12-0-UI.s1 UI-CF-EC0 Homo sapiens cDNA clone UI-CF-EC0-abi-c-12-0-UI 3, mRNA sequence', 'PREDICTED: Homo sapiens similar to spectrin domain with coiled-coils 1 (LOC441782), mRNA.', 'Homo sapiens jumonji domain containing 1A (JMJD1A), mRNA.', 'hi56g05.x1 Soares_NFL_T_GBC_S1 Homo sapiens cDNA clone IMAGE:2976344 3, mRNA sequence', 'wk77d04.x1 NCI_CGAP_Pan1 Homo sapiens cDNA clone IMAGE:2421415 3, mRNA sequence'], 'Ontology_Component': [nan, nan, 'nucleus [goid 5634] [evidence IEA]', nan, nan], 'Ontology_Process': [nan, nan, 'chromatin modification [goid 16568] [evidence IEA]; transcription [goid 6350] [evidence IEA]; regulation of transcription, DNA-dependent [goid 6355] [evidence IEA]', nan, nan], 'Ontology_Function': [nan, nan, 'oxidoreductase activity [goid 16491] [evidence IEA]; oxidoreductase activity, acting on single donors with incorporation of molecular oxygen, incorporation of two atoms of oxygen [goid 16702] [evidence IEA]; zinc ion binding [goid 8270] [evidence IEA]; metal ion binding [goid 46872] [evidence IEA]; iron ion binding [goid 5506] [evidence IEA]', nan, nan], 'Synonyms': [nan, nan, 'JHMD2A; JMJD1; TSGA; KIAA0742; DKFZp686A24246; DKFZp686P07111', nan, nan], 'GB_ACC': ['BU678343', 'XM_497527.2', 'NM_018433.3', 'AW629334', 'AI818233']}\n" ] } ], "source": [ "# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.\n", "try:\n", " # Use the correct variable name from previous steps\n", " gene_annotation = get_gene_annotation(soft_file_path)\n", " \n", " # 2. Preview the gene annotation dataframe\n", " print(\"Gene annotation preview:\")\n", " print(preview_df(gene_annotation))\n", " \n", "except UnicodeDecodeError as e:\n", " print(f\"Unicode decoding error: {e}\")\n", " print(\"Trying alternative approach...\")\n", " \n", " # Read the file with Latin-1 encoding which is more permissive\n", " import gzip\n", " import pandas as pd\n", " \n", " # Manually read the file line by line with error handling\n", " data_lines = []\n", " with gzip.open(soft_file_path, 'rb') as f:\n", " for line in f:\n", " # Skip lines starting with prefixes we want to filter out\n", " line_str = line.decode('latin-1')\n", " if not line_str.startswith('^') and not line_str.startswith('!') and not line_str.startswith('#'):\n", " data_lines.append(line_str)\n", " \n", " # Create dataframe from collected lines\n", " if data_lines:\n", " gene_data_str = '\\n'.join(data_lines)\n", " gene_annotation = pd.read_csv(pd.io.common.StringIO(gene_data_str), sep='\\t', low_memory=False)\n", " print(\"Gene annotation preview (alternative method):\")\n", " print(preview_df(gene_annotation))\n", " else:\n", " print(\"No valid gene annotation data found after filtering.\")\n", " gene_annotation = pd.DataFrame()\n", " \n", "except Exception as e:\n", " print(f\"Error extracting gene annotation data: {e}\")\n", " gene_annotation = pd.DataFrame()\n" ] }, { "cell_type": "markdown", "id": "6e2bb33f", "metadata": {}, "source": [ "### Step 6: Gene Identifier Mapping" ] }, { "cell_type": "code", "execution_count": 7, "id": "adefbc02", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:33.767103Z", "iopub.status.busy": "2025-03-25T04:08:33.766990Z", "iopub.status.idle": "2025-03-25T04:08:33.890693Z", "shell.execute_reply": "2025-03-25T04:08:33.890317Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Creating gene mapping dataframe...\n", "Total number of probes in mapping: 36750\n", "Number of probes with gene symbols: 36750\n", "Converting probe-level measurements to gene-level expression...\n", "Gene expression data shape after mapping: (14757, 27)\n", "First 10 gene symbols after mapping:\n", "Index(['A1BG', 'A2M', 'A4GALT', 'A4GNT', 'AAAS', 'AACS', 'AACSL', 'AADACL1',\n", " 'AADAT', 'AAMP'],\n", " dtype='object', name='Gene')\n" ] } ], "source": [ "# 1. Identify the relevant columns for mapping\n", "# From the gene expression data, we can see the identifiers are in the format \"ILMN_XXXXXXX\"\n", "# From the gene annotation preview, we can see these identifiers are in the \"ID\" column\n", "# The gene symbols are in the \"Symbol\" column\n", "\n", "# 2. Extract the mapping between probe IDs and gene symbols\n", "print(\"Creating gene mapping dataframe...\")\n", "prob_col = \"ID\" # The column containing probe identifiers\n", "gene_col = \"Symbol\" # The column containing gene symbols\n", "\n", "# Get the mapping dataframe using the function from the library\n", "gene_mapping = get_gene_mapping(gene_annotation, prob_col, gene_col)\n", "\n", "# Print some statistics about the mapping\n", "print(f\"Total number of probes in mapping: {len(gene_mapping)}\")\n", "print(f\"Number of probes with gene symbols: {gene_mapping['Gene'].notna().sum()}\")\n", "\n", "# 3. Apply the gene mapping to convert probe-level measurements to gene-level expression\n", "print(\"Converting probe-level measurements to gene-level expression...\")\n", "gene_data = apply_gene_mapping(gene_data, gene_mapping)\n", "\n", "# Print shape and preview of the gene expression data after mapping\n", "print(f\"Gene expression data shape after mapping: {gene_data.shape}\")\n", "print(\"First 10 gene symbols after mapping:\")\n", "print(gene_data.index[:10])\n" ] }, { "cell_type": "markdown", "id": "0c8ceb7a", "metadata": {}, "source": [ "### Step 7: Data Normalization and Linking" ] }, { "cell_type": "code", "execution_count": 8, "id": "bf6a395c", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:08:33.891984Z", "iopub.status.busy": "2025-03-25T04:08:33.891869Z", "iopub.status.idle": "2025-03-25T04:08:34.222973Z", "shell.execute_reply": "2025-03-25T04:08:34.222598Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gene data shape before normalization: (14757, 27)\n", "Gene data shape after normalization: (13877, 27)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Normalized gene data saved to ../../output/preprocess/Telomere_Length/gene_data/GSE80435.csv\n", "Clinical features shape: (27, 0)\n", "Abnormality detected in the cohort: GSE80435. Preprocessing failed.\n", "Data quality check result: Not usable\n", "No linked data saved due to missing trait information.\n" ] } ], "source": [ "# 1. Normalize gene symbols in the obtained gene expression data\n", "# The gene_data already has proper gene symbols from step 6\n", "# Now normalize these symbols using the NCBI Gene database information\n", "gene_data_normalized = normalize_gene_symbols_in_index(gene_data)\n", "print(f\"Gene data shape before normalization: {gene_data.shape}\")\n", "print(f\"Gene data shape after normalization: {gene_data_normalized.shape}\")\n", "\n", "# Save the normalized gene expression data\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\"Normalized gene data saved to {out_gene_data_file}\")\n", "\n", "# 2. Since we determined in Step 2 that trait data is not available (trait_row = None),\n", "# we cannot properly link clinical and genetic data for this cohort\n", "\n", "# Create an empty DataFrame with the correct sample IDs for proper evaluation\n", "clinical_features = pd.DataFrame(index=gene_data_normalized.columns)\n", "print(f\"Clinical features shape: {clinical_features.shape}\")\n", "\n", "# Create a dummy dataframe with the necessary structure for validation\n", "dummy_df = pd.DataFrame(index=gene_data_normalized.columns)\n", "dummy_df['dummy_trait'] = 0 # Add a dummy column to satisfy the validation requirements\n", "\n", "# 3-6. Since trait data is not available, we cannot create a properly linked dataset\n", "# Validate and save this information using is_final=True\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, # Setting this to False as determined in Step 2\n", " is_biased=False, # Setting to False since we can't determine bias without trait data\n", " df=dummy_df, # Using dummy dataframe with necessary structure\n", " note=\"Dataset contains gene expression data but lacks telomere length measurements necessary for the trait analysis.\"\n", ")\n", "\n", "print(f\"Data quality check result: {'Usable' if is_usable else 'Not usable'}\")\n", "\n", "# We don't save linked_data since the dataset is not usable for our analysis\n", "print(\"No linked data saved 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 }