{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "16ddd6a8", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T06:04:49.635250Z", "iopub.status.busy": "2025-03-25T06:04:49.635064Z", "iopub.status.idle": "2025-03-25T06:04:49.801281Z", "shell.execute_reply": "2025-03-25T06:04:49.800844Z" } }, "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 = \"Ovarian_Cancer\"\n", "\n", "# Input paths\n", "tcga_root_dir = \"../../input/TCGA\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Ovarian_Cancer/TCGA.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Ovarian_Cancer/gene_data/TCGA.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Ovarian_Cancer/clinical_data/TCGA.csv\"\n", "json_path = \"../../output/preprocess/Ovarian_Cancer/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "3ad8459d", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "cd6b2049", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T06:04:49.802735Z", "iopub.status.busy": "2025-03-25T06:04:49.802584Z", "iopub.status.idle": "2025-03-25T06:04:50.569103Z", "shell.execute_reply": "2025-03-25T06:04:50.568699Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Clinical data columns:\n", "['_INTEGRATION', '_PANCAN_CNA_PANCAN_K8', '_PANCAN_Cluster_Cluster_PANCAN', '_PANCAN_DNAMethyl_PANCAN', '_PANCAN_RPPA_PANCAN_K8', '_PANCAN_UNC_RNAseq_PANCAN_K16', '_PANCAN_miRNA_PANCAN', '_PANCAN_mirna_OV', '_PANCAN_mutation_PANCAN', '_PATIENT', '_cohort', '_primary_disease', '_primary_site', 'additional_pharmaceutical_therapy', 'additional_radiation_therapy', 'age_at_initial_pathologic_diagnosis', 'anatomic_neoplasm_subdivision', 'bcr_followup_barcode', 'bcr_patient_barcode', 'bcr_sample_barcode', 'clinical_stage', 'days_to_birth', 'days_to_collection', 'days_to_death', 'days_to_initial_pathologic_diagnosis', 'days_to_last_followup', 'days_to_new_tumor_event_additional_surgery_procedure', 'days_to_new_tumor_event_after_initial_treatment', 'eastern_cancer_oncology_group', 'followup_case_report_form_submission_reason', 'followup_treatment_success', 'form_completion_date', 'gender', 'histological_type', 'history_of_neoadjuvant_treatment', 'icd_10', 'icd_o_3_histology', 'icd_o_3_site', 'informed_consent_verified', 'initial_pathologic_diagnosis_method', 'initial_weight', 'intermediate_dimension', 'is_ffpe', 'karnofsky_performance_score', 'longest_dimension', 'lost_follow_up', 'lymphatic_invasion', 'neoplasm_histologic_grade', 'new_neoplasm_event_type', 'new_tumor_event_additional_surgery_procedure', 'new_tumor_event_after_initial_treatment', 'oct_embedded', 'other_dx', 'pathology_report_file_name', 'patient_id', 'performance_status_scale_timing', 'person_neoplasm_cancer_status', 'postoperative_rx_tx', 'primary_therapy_outcome_success', 'progression_determined_by', 'radiation_therapy', 'residual_tumor', 'sample_type', 'sample_type_id', 'shortest_dimension', 'tissue_prospective_collection_indicator', 'tissue_retrospective_collection_indicator', 'tissue_source_site', 'tumor_residual_disease', 'tumor_tissue_site', 'venous_invasion', 'vial_number', 'vital_status', 'year_of_initial_pathologic_diagnosis', '_GENOMIC_ID_TCGA_OV_PDMRNAseq', '_GENOMIC_ID_data/public/TCGA/OV/miRNA_HiSeq_gene', '_GENOMIC_ID_TCGA_OV_mutation_bcm_solid_gene', '_GENOMIC_ID_TCGA_OV_exp_u133a', '_GENOMIC_ID_TCGA_OV_hMethyl450', '_GENOMIC_ID_TCGA_OV_miRNA_HiSeq', '_GENOMIC_ID_TCGA_OV_mutation_curated_bcm_solid_gene', '_GENOMIC_ID_TCGA_OV_hMethyl27', '_GENOMIC_ID_TCGA_OV_mutation_wustl_hiseq_gene', '_GENOMIC_ID_TCGA_OV_RPPA_RBN', '_GENOMIC_ID_TCGA_OV_mutation_wustl_gene', '_GENOMIC_ID_TCGA_OV_exp_HiSeqV2_percentile', '_GENOMIC_ID_TCGA_OV_gistic2thd', '_GENOMIC_ID_TCGA_OV_PDMarray', '_GENOMIC_ID_TCGA_OV_RPPA', '_GENOMIC_ID_TCGA_OV_exp_HiSeq', '_GENOMIC_ID_TCGA_OV_gistic2', '_GENOMIC_ID_TCGA_OV_exp_HiSeqV2_PANCAN', '_GENOMIC_ID_TCGA_OV_exp_HiSeq_exon', '_GENOMIC_ID_TCGA_OV_exp_HiSeqV2', '_GENOMIC_ID_TCGA_OV_mutation_broad_gene', '_GENOMIC_ID_TCGA_OV_PDMarrayCNV', '_GENOMIC_ID_TCGA_OV_PDMRNAseqCNV', '_GENOMIC_ID_TCGA_OV_exp_HiSeqV2_exon', '_GENOMIC_ID_TCGA_OV_mutation', '_GENOMIC_ID_TCGA_OV_G4502A_07_3', '_GENOMIC_ID_TCGA_OV_G4502A_07_2']\n" ] } ], "source": [ "# Step 1: Find the directory corresponding to Ovarian Cancer\n", "import os\n", "\n", "# List all directories in TCGA root directory\n", "tcga_dirs = os.listdir(tcga_root_dir)\n", "\n", "# Find the directory that matches our trait: Ovarian_Cancer\n", "ovarian_dirs = [dir_name for dir_name in tcga_dirs if \"ovarian\" in dir_name.lower()]\n", "\n", "if not ovarian_dirs:\n", " print(f\"No matching directory found for trait: {trait}\")\n", " # Record that this trait is not available and exit\n", " validate_and_save_cohort_info(\n", " is_final=False,\n", " cohort=\"TCGA\",\n", " info_path=json_path,\n", " is_gene_available=False,\n", " is_trait_available=False\n", " )\n", "else:\n", " # Select the most relevant directory\n", " selected_dir = ovarian_dirs[0] # Should be 'TCGA_Ovarian_Cancer_(OV)'\n", " cohort_dir = os.path.join(tcga_root_dir, selected_dir)\n", " \n", " # Step 2: Get file paths for clinical and genetic data\n", " clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)\n", " \n", " # Step 3: Load the files\n", " clinical_df = pd.read_csv(clinical_file_path, sep='\\t', index_col=0)\n", " genetic_df = pd.read_csv(genetic_file_path, sep='\\t', index_col=0)\n", " \n", " # Step 4: Print column names of clinical data\n", " print(\"Clinical data columns:\")\n", " print(clinical_df.columns.tolist())\n" ] }, { "cell_type": "markdown", "id": "bee63c2d", "metadata": {}, "source": [ "### Step 2: Find Candidate Demographic Features" ] }, { "cell_type": "code", "execution_count": 3, "id": "7a37502e", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T06:04:50.570405Z", "iopub.status.busy": "2025-03-25T06:04:50.570284Z", "iopub.status.idle": "2025-03-25T06:04:50.582278Z", "shell.execute_reply": "2025-03-25T06:04:50.581882Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Age columns preview:\n", "{'age_at_initial_pathologic_diagnosis': [nan, nan, nan, nan, nan], 'days_to_birth': [nan, nan, nan, nan, nan]}\n", "\n", "Gender columns preview:\n", "{'gender': [nan, nan, nan, nan, nan]}\n" ] } ], "source": [ "# Identifying columns related to age\n", "candidate_age_cols = ['age_at_initial_pathologic_diagnosis', 'days_to_birth']\n", "\n", "# Identifying columns related to gender\n", "candidate_gender_cols = ['gender']\n", "\n", "# The directory structure might require navigating to a specific cohort directory\n", "# Let's first check if we can identify the ovarian cancer (OV) cohort directory\n", "import os\n", "\n", "# Look for the OV cohort directory within the TCGA root directory\n", "possible_cohort_dirs = [os.path.join(tcga_root_dir, d) for d in os.listdir(tcga_root_dir) if 'OV' in d]\n", "\n", "if possible_cohort_dirs:\n", " cohort_dir = possible_cohort_dirs[0]\n", " try:\n", " clinical_file_path, _ = tcga_get_relevant_filepaths(cohort_dir)\n", " clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\\t')\n", " \n", " # Preview age-related columns\n", " age_preview = {}\n", " for col in candidate_age_cols:\n", " if col in clinical_df.columns:\n", " age_preview[col] = clinical_df[col].head(5).tolist()\n", " \n", " # Preview gender-related columns\n", " gender_preview = {}\n", " for col in candidate_gender_cols:\n", " if col in clinical_df.columns:\n", " gender_preview[col] = clinical_df[col].head(5).tolist()\n", " \n", " print(\"Age columns preview:\")\n", " print(age_preview)\n", " print(\"\\nGender columns preview:\")\n", " print(gender_preview)\n", " except (IndexError, FileNotFoundError) as e:\n", " print(f\"Could not access clinical data files: {e}\")\n", " print(\"Identified candidate columns without preview:\")\n", " print(f\"Age columns: {candidate_age_cols}\")\n", " print(f\"Gender columns: {candidate_gender_cols}\")\n", "else:\n", " print(\"Could not locate Ovarian Cancer cohort directory.\")\n", " print(\"Identified candidate columns without preview:\")\n", " print(f\"Age columns: {candidate_age_cols}\")\n", " print(f\"Gender columns: {candidate_gender_cols}\")\n" ] }, { "cell_type": "markdown", "id": "9cccb10d", "metadata": {}, "source": [ "### Step 3: Select Demographic Features" ] }, { "cell_type": "code", "execution_count": 4, "id": "f0fb8194", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T06:04:50.583362Z", "iopub.status.busy": "2025-03-25T06:04:50.583252Z", "iopub.status.idle": "2025-03-25T06:04:50.588218Z", "shell.execute_reply": "2025-03-25T06:04:50.587836Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Age columns inspection:\n", "Column 'age_at_initial_pathologic_diagnosis': 607/630 non-null values (96.35%)\n", "Sample values: [78.0, 70.0, 60.0, 55.0, 78.0]\n", "Column 'days_to_birth': 596/630 non-null values (94.60%)\n", "Sample values: [-28848.0, -25786.0, -21963.0, -20271.0, -28626.0]\n", "\n", "Gender column inspection:\n", "Column 'gender': 607/630 non-null values (96.35%)\n", "Sample values: ['FEMALE', 'FEMALE', 'FEMALE', 'FEMALE', 'FEMALE']\n", "\n", "Chosen demographic columns:\n", "age_col = age_at_initial_pathologic_diagnosis\n", "gender_col = gender\n" ] } ], "source": [ "# Examine age columns\n", "print(\"Age columns inspection:\")\n", "age_col = None\n", "for column in ['age_at_initial_pathologic_diagnosis', 'days_to_birth']:\n", " if column in clinical_df.columns:\n", " non_null_values = clinical_df[column].notna().sum()\n", " total_values = len(clinical_df[column])\n", " non_null_percentage = (non_null_values / total_values) * 100 if total_values > 0 else 0\n", " print(f\"Column '{column}': {non_null_values}/{total_values} non-null values ({non_null_percentage:.2f}%)\")\n", " \n", " # Check a few values\n", " sample_values = clinical_df[column].dropna().head(5).tolist()\n", " print(f\"Sample values: {sample_values}\")\n", " \n", " # Choose column with higher non-null percentage\n", " if non_null_percentage > 50: # Reasonable threshold for usability\n", " if age_col is None or non_null_percentage > (clinical_df[age_col].notna().sum() / len(clinical_df[age_col])) * 100:\n", " age_col = column\n", "\n", "# Examine gender column\n", "print(\"\\nGender column inspection:\")\n", "gender_col = None\n", "if 'gender' in clinical_df.columns:\n", " non_null_values = clinical_df['gender'].notna().sum()\n", " total_values = len(clinical_df['gender'])\n", " non_null_percentage = (non_null_values / total_values) * 100 if total_values > 0 else 0\n", " print(f\"Column 'gender': {non_null_values}/{total_values} non-null values ({non_null_percentage:.2f}%)\")\n", " \n", " # Check a few values\n", " sample_values = clinical_df['gender'].dropna().head(5).tolist()\n", " print(f\"Sample values: {sample_values}\")\n", " \n", " # Choose gender column if it has reasonable non-null percentage\n", " if non_null_percentage > 50: # Reasonable threshold for usability\n", " gender_col = 'gender'\n", "\n", "# Output chosen columns\n", "print(\"\\nChosen demographic columns:\")\n", "print(f\"age_col = {age_col}\")\n", "print(f\"gender_col = {gender_col}\")\n" ] }, { "cell_type": "markdown", "id": "617c9c10", "metadata": {}, "source": [ "### Step 4: Feature Engineering and Validation" ] }, { "cell_type": "code", "execution_count": 5, "id": "a626746a", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T06:04:50.589451Z", "iopub.status.busy": "2025-03-25T06:04:50.589188Z", "iopub.status.idle": "2025-03-25T06:05:00.725213Z", "shell.execute_reply": "2025-03-25T06:05:00.724580Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Saved clinical data to ../../output/preprocess/Ovarian_Cancer/clinical_data/TCGA.csv\n", "Clinical data shape: (630, 3)\n", "Original genetic data shape: (20530, 308)\n", "Sample column names (first 5): ['TCGA-61-1910-01', 'TCGA-61-1728-01', 'TCGA-09-1666-01', 'TCGA-24-1469-01', 'TCGA-04-1348-01']\n", "Sample row indices (first 5): ['ARHGEF10L', 'HIF3A', 'RNF17', 'RNF10', 'RNF11']\n", "Normalized gene data shape: (19848, 308)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Saved normalized gene data to ../../output/preprocess/Ovarian_Cancer/gene_data/TCGA.csv\n", "Clinical data index examples: ['TCGA-01-0628-11', 'TCGA-01-0629-11', 'TCGA-01-0630-11', 'TCGA-01-0631-11', 'TCGA-01-0633-11']\n", "Gene data column examples: ['TCGA-61-1910-01', 'TCGA-61-1728-01', 'TCGA-09-1666-01', 'TCGA-24-1469-01', 'TCGA-04-1348-01']\n", "Found 308 common samples between clinical and gene data\n", "Linked data shape: (308, 19851)\n", "Number of samples: 308\n", "Number of features (including clinical): 19851\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Cleaned data shape after handling missing values: (308, 19851)\n", "Quartiles for 'Ovarian_Cancer':\n", " 25%: 1.0\n", " 50% (Median): 1.0\n", " 75%: 1.0\n", "Min: 1\n", "Max: 1\n", "The distribution of the feature 'Ovarian_Cancer' in this dataset is severely biased.\n", "\n", "Quartiles for 'Age':\n", " 25%: 51.0\n", " 50% (Median): 58.0\n", " 75%: 67.0\n", "Min: 30.0\n", "Max: 87.0\n", "The distribution of the feature 'Age' in this dataset is fine.\n", "\n", "For the feature 'Gender', the least common label is '0.0' with 308 occurrences. This represents 100.00% of the dataset.\n", "The distribution of the feature 'Gender' in this dataset is severely biased.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Preview of cleaned linked data:\n", " Ovarian_Cancer Age A1BG A1BG-AS1 A1CF A2M \\\n", "TCGA-13-0899-01 1 60.0 -0.897074 -0.900583 -1.742862 -0.245477 \n", "TCGA-13-0920-01 1 65.0 -1.064674 -3.359783 -1.742862 -1.960177 \n", "TCGA-25-1314-01 1 42.0 1.276526 1.628517 -1.742862 -1.307177 \n", "\n", " A2ML1 A4GALT A4GNT AAA1 ... ZWILCH \\\n", "TCGA-13-0899-01 3.562506 0.181199 -1.1892 -0.359541 ... -0.175754 \n", "TCGA-13-0920-01 -2.981794 -2.446901 -1.1892 -0.359541 ... 0.748346 \n", "TCGA-25-1314-01 -1.851794 -2.102501 -1.1892 -0.359541 ... 0.080646 \n", "\n", " ZWINT ZXDA ZXDB ZXDC ZYG11A ZYG11B \\\n", "TCGA-13-0899-01 -0.127832 -0.366196 -0.543364 -0.346067 -1.341914 -1.23273 \n", "TCGA-13-0920-01 2.069668 -0.242796 -0.217864 0.245633 0.964886 0.46607 \n", "TCGA-25-1314-01 0.435468 0.471604 -0.141664 -0.006667 5.056986 0.37887 \n", "\n", " ZYX ZZEF1 ZZZ3 \n", "TCGA-13-0899-01 1.990845 -0.875273 -0.83607 \n", "TCGA-13-0920-01 -0.300055 -0.779573 0.22973 \n", "TCGA-25-1314-01 0.735745 -0.179873 0.15863 \n", "\n", "[3 rows x 19850 columns]\n", "Dataset is not usable due to severe bias or data quality issues. Linked data not saved.\n" ] } ], "source": [ "# Step 1: Extract and standardize clinical features\n", "# Selecting the trait, age, and gender from clinical data\n", "selected_clinical_df = tcga_select_clinical_features(\n", " clinical_df, \n", " trait=trait, \n", " age_col=age_col, \n", " gender_col=gender_col\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\"Saved clinical data to {out_clinical_data_file}\")\n", "print(f\"Clinical data shape: {selected_clinical_df.shape}\")\n", "\n", "# Step 2: Normalize gene symbols in gene expression data\n", "# First, inspect the structure of the genetic data\n", "print(f\"Original genetic data shape: {genetic_df.shape}\")\n", "print(f\"Sample column names (first 5): {list(genetic_df.columns[:5])}\")\n", "print(f\"Sample row indices (first 5): {list(genetic_df.index[:5])}\")\n", "\n", "# The genetic data likely has genes as rows and samples as columns already\n", "# No need to transpose, just normalize gene symbols\n", "normalized_gene_df = normalize_gene_symbols_in_index(genetic_df)\n", "print(f\"Normalized gene data shape: {normalized_gene_df.shape}\")\n", "\n", "# Save the normalized gene data\n", "os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)\n", "normalized_gene_df.to_csv(out_gene_data_file)\n", "print(f\"Saved normalized gene data to {out_gene_data_file}\")\n", "\n", "# Step 3: Link clinical and genetic data\n", "# Debug: Print sample indices to understand format\n", "print(\"Clinical data index examples:\", selected_clinical_df.index[:5].tolist())\n", "print(\"Gene data column examples:\", normalized_gene_df.columns[:5].tolist())\n", "\n", "# Extract sample IDs from both clinical and genetic data and standardize format\n", "clinical_sample_ids = selected_clinical_df.index\n", "gene_sample_ids = normalized_gene_df.columns\n", "\n", "# Find common samples using exact matching\n", "common_samples = list(set(clinical_sample_ids).intersection(set(gene_sample_ids)))\n", "print(f\"Found {len(common_samples)} common samples between clinical and gene data\")\n", "\n", "# If no exact matches, try to find pattern-based matches\n", "if not common_samples:\n", " # Extract TCGA barcodes up to the sample portion (first 12 characters) from clinical IDs\n", " clinical_barcodes = [sample_id[:12] for sample_id in clinical_sample_ids if sample_id.startswith('TCGA-')]\n", " # Check if the gene data columns contain these barcodes\n", " for col in gene_sample_ids:\n", " for barcode in clinical_barcodes:\n", " if barcode in col:\n", " print(f\"Found potential match: {barcode} in {col}\")\n", " \n", " # Alternative approach: prepare subsets for visual comparison\n", " print(\"Sample clinical IDs (first 10):\", clinical_sample_ids[:10].tolist())\n", " print(\"Sample gene expression column names (first 10):\", list(gene_sample_ids[:10]))\n", "\n", "# Create linked data by combining clinical and gene expression data\n", "if common_samples:\n", " # Filter clinical data to include only common samples\n", " clinical_subset = selected_clinical_df.loc[common_samples]\n", " # Extract gene expression data for common samples\n", " gene_subset = normalized_gene_df[common_samples]\n", " # Transpose gene subset to have samples as rows\n", " gene_subset_t = gene_subset.transpose()\n", " # Combine the dataframes\n", " linked_data = pd.concat([clinical_subset, gene_subset_t], axis=1)\n", "else:\n", " # If there are no common samples, create an empty DataFrame\n", " linked_data = pd.DataFrame()\n", " print(\"No common samples found between clinical and gene expression data.\")\n", "\n", "print(f\"Linked data shape: {linked_data.shape}\")\n", "print(f\"Number of samples: {linked_data.shape[0]}\")\n", "print(f\"Number of features (including clinical): {linked_data.shape[1]}\")\n", "\n", "# Step 4: Handle missing values systematically\n", "if not linked_data.empty:\n", " cleaned_data = handle_missing_values(linked_data, trait_col=trait)\n", " print(f\"Cleaned data shape after handling missing values: {cleaned_data.shape}\")\n", " \n", " # Step 5: Determine if trait and demographic features are severely biased\n", " is_trait_biased, cleaned_data = judge_and_remove_biased_features(cleaned_data, trait)\n", " \n", " # Preview results\n", " print(\"\\nPreview of cleaned linked data:\")\n", " print(cleaned_data.head(3))\n", "else:\n", " cleaned_data = pd.DataFrame()\n", " is_trait_biased = True # If we can't link data, consider it biased/unusable\n", " print(\"Cannot proceed with empty linked data\")\n", "\n", "# Step 6: Conduct final quality validation\n", "# Validate and save cohort information\n", "is_gene_available = normalized_gene_df.shape[0] > 0\n", "is_trait_available = selected_clinical_df.shape[0] > 0\n", "note = \"Ovarian cancer dataset with gene expression data from TCGA. \"\n", "\n", "if linked_data.empty:\n", " note += \"Failed to link clinical and genetic data due to no common sample IDs. This may be due to different sample ID formats.\"\n", " is_trait_biased = True # Consider it biased if we can't link data\n", "elif is_trait_biased:\n", " note += \"The trait distribution is severely biased, making the dataset unsuitable for analysis.\"\n", "else:\n", " note += \"The dataset appears to be balanced and suitable for analysis.\"\n", "\n", "is_usable = validate_and_save_cohort_info(\n", " is_final=True,\n", " cohort=\"TCGA\",\n", " info_path=json_path,\n", " is_gene_available=is_gene_available,\n", " is_trait_available=is_trait_available,\n", " is_biased=is_trait_biased,\n", " df=cleaned_data,\n", " note=note\n", ")\n", "\n", "# Step 7: Save linked data if usable\n", "if is_usable and not cleaned_data.empty:\n", " os.makedirs(os.path.dirname(out_data_file), exist_ok=True)\n", " cleaned_data.to_csv(out_data_file)\n", " print(f\"Dataset is usable. Saved linked data to {out_data_file}\")\n", "else:\n", " print(\"Dataset is not usable due to severe bias or data quality issues. Linked data not saved.\")" ] } ], "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 }