{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "749e110d", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:30:35.672906Z", "iopub.status.busy": "2025-03-25T04:30:35.672487Z", "iopub.status.idle": "2025-03-25T04:30:35.837964Z", "shell.execute_reply": "2025-03-25T04:30:35.837629Z" } }, "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 = \"Underweight\"\n", "\n", "# Input paths\n", "tcga_root_dir = \"../../input/TCGA\"\n", "\n", "# Output paths\n", "out_data_file = \"../../output/preprocess/Underweight/TCGA.csv\"\n", "out_gene_data_file = \"../../output/preprocess/Underweight/gene_data/TCGA.csv\"\n", "out_clinical_data_file = \"../../output/preprocess/Underweight/clinical_data/TCGA.csv\"\n", "json_path = \"../../output/preprocess/Underweight/cohort_info.json\"\n" ] }, { "cell_type": "markdown", "id": "7e05be4b", "metadata": {}, "source": [ "### Step 1: Initial Data Loading" ] }, { "cell_type": "code", "execution_count": 2, "id": "24c90d75", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:30:35.839405Z", "iopub.status.busy": "2025-03-25T04:30:35.839262Z", "iopub.status.idle": "2025-03-25T04:30:36.290382Z", "shell.execute_reply": "2025-03-25T04:30:36.290004Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Available TCGA directories: ['TCGA_Liver_Cancer_(LIHC)', 'TCGA_Lower_Grade_Glioma_(LGG)', 'TCGA_lower_grade_glioma_and_glioblastoma_(GBMLGG)', 'TCGA_Lung_Adenocarcinoma_(LUAD)', 'TCGA_Lung_Cancer_(LUNG)', 'TCGA_Lung_Squamous_Cell_Carcinoma_(LUSC)', 'TCGA_Melanoma_(SKCM)', 'TCGA_Mesothelioma_(MESO)', 'TCGA_Ocular_melanomas_(UVM)', 'TCGA_Ovarian_Cancer_(OV)', 'TCGA_Pancreatic_Cancer_(PAAD)', 'TCGA_Pheochromocytoma_Paraganglioma_(PCPG)', 'TCGA_Prostate_Cancer_(PRAD)', 'TCGA_Rectal_Cancer_(READ)', 'TCGA_Sarcoma_(SARC)', 'TCGA_Stomach_Cancer_(STAD)', 'TCGA_Testicular_Cancer_(TGCT)', 'TCGA_Thymoma_(THYM)', 'TCGA_Thyroid_Cancer_(THCA)', 'TCGA_Uterine_Carcinosarcoma_(UCS)', '.DS_Store', 'CrawlData.ipynb', 'TCGA_Acute_Myeloid_Leukemia_(LAML)', 'TCGA_Adrenocortical_Cancer_(ACC)', 'TCGA_Bile_Duct_Cancer_(CHOL)', 'TCGA_Bladder_Cancer_(BLCA)', 'TCGA_Breast_Cancer_(BRCA)', 'TCGA_Cervical_Cancer_(CESC)', 'TCGA_Colon_and_Rectal_Cancer_(COADREAD)', 'TCGA_Colon_Cancer_(COAD)', 'TCGA_Endometrioid_Cancer_(UCEC)', 'TCGA_Esophageal_Cancer_(ESCA)', 'TCGA_Glioblastoma_(GBM)', 'TCGA_Head_and_Neck_Cancer_(HNSC)', 'TCGA_Kidney_Chromophobe_(KICH)', 'TCGA_Kidney_Clear_Cell_Carcinoma_(KIRC)', 'TCGA_Kidney_Papillary_Cell_Carcinoma_(KIRP)', 'TCGA_Large_Bcell_Lymphoma_(DLBC)']\n", "Potential relevant directories for Underweight: ['TCGA_Liver_Cancer_(LIHC)', 'TCGA_Lung_Adenocarcinoma_(LUAD)', 'TCGA_Lung_Cancer_(LUNG)', 'TCGA_Lung_Squamous_Cell_Carcinoma_(LUSC)', 'TCGA_Pancreatic_Cancer_(PAAD)', 'TCGA_Stomach_Cancer_(STAD)']\n", "Selected directory for Underweight: TCGA_Pancreatic_Cancer_(PAAD)\n", "Clinical data file: ../../input/TCGA/TCGA_Pancreatic_Cancer_(PAAD)/TCGA.PAAD.sampleMap_PAAD_clinicalMatrix\n", "Genetic data file: ../../input/TCGA/TCGA_Pancreatic_Cancer_(PAAD)/TCGA.PAAD.sampleMap_HiSeqV2_PANCAN.gz\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "Clinical data columns:\n", "['CDE_ID_3226963', '_INTEGRATION', '_PATIENT', '_cohort', '_primary_disease', '_primary_site', 'additional_pharmaceutical_therapy', 'additional_radiation_therapy', 'adenocarcinoma_invasion', 'age_at_initial_pathologic_diagnosis', 'alcohol_history_documented', 'alcoholic_exposure_category', 'amount_of_alcohol_consumption_per_day', 'anatomic_neoplasm_subdivision', 'anatomic_neoplasm_subdivision_other', 'bcr_followup_barcode', 'bcr_patient_barcode', 'bcr_sample_barcode', 'days_to_birth', 'days_to_collection', 'days_to_death', 'days_to_diabetes_onset', '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', 'days_to_pancreatitis_onset', 'family_history_of_cancer', 'followup_case_report_form_submission_reason', 'followup_treatment_success', 'form_completion_date', 'frequency_of_alcohol_consumption', 'gender', 'histologic_grading_tier_category', 'histological_type', 'histological_type_other', 'history_of_chronic_pancreatitis', 'history_of_diabetes', 'history_of_neoadjuvant_treatment', 'icd_10', 'icd_o_3_histology', 'icd_o_3_site', 'informed_consent_verified', 'init_pathology_dx_method_other', 'initial_pathologic_diagnosis_method', 'initial_weight', 'intermediate_dimension', 'is_ffpe', 'longest_dimension', 'lost_follow_up', 'lymph_node_examined_count', 'maximum_tumor_dimension', 'neoplasm_histologic_grade', 'new_neoplasm_event_occurrence_anatomic_site', 'new_neoplasm_event_type', 'new_neoplasm_occurrence_anatomic_site_text', 'new_tumor_event_additional_surgery_procedure', 'new_tumor_event_after_initial_treatment', 'number_of_lymphnodes_positive_by_he', 'number_of_lymphnodes_positive_by_ihc', 'number_pack_years_smoked', 'oct_embedded', 'other_dx', 'pathologic_M', 'pathologic_N', 'pathologic_T', 'pathologic_stage', 'pathology_report_file_name', 'patient_death_reason', 'patient_id', 'person_neoplasm_cancer_status', 'primary_lymph_node_presentation_assessment', 'primary_therapy_outcome_success', 'progression_determined_by', 'radiation_therapy', 'relative_cancer_type', 'residual_disease_post_new_tumor_event_margin_status', 'residual_tumor', 'sample_type', 'sample_type_id', 'shortest_dimension', 'source_of_patient_death_reason', 'stopped_smoking_year', 'surgery_performed_type', 'system_version', 'targeted_molecular_therapy', 'tissue_prospective_collection_indicator', 'tissue_retrospective_collection_indicator', 'tissue_source_site', 'tobacco_smoking_history', 'tumor_tissue_site', 'tumor_type', 'vial_number', 'vital_status', 'year_of_initial_pathologic_diagnosis', 'year_of_tobacco_smoking_onset', '_GENOMIC_ID_TCGA_PAAD_mutation_bcgsc_gene', '_GENOMIC_ID_TCGA_PAAD_exp_HiSeqV2_PANCAN', '_GENOMIC_ID_TCGA_PAAD_gistic2', '_GENOMIC_ID_TCGA_PAAD_mutation_ucsc_maf_gene', '_GENOMIC_ID_TCGA_PAAD_exp_HiSeqV2', '_GENOMIC_ID_TCGA_PAAD_mutation_curated_broad_gene', '_GENOMIC_ID_TCGA_PAAD_exp_HiSeqV2_exon', '_GENOMIC_ID_TCGA_PAAD_mutation_bcm_gene', '_GENOMIC_ID_TCGA_PAAD_RPPA', '_GENOMIC_ID_TCGA_PAAD_hMethyl450', '_GENOMIC_ID_TCGA_PAAD_mutation', '_GENOMIC_ID_TCGA_PAAD_PDMRNAseq', '_GENOMIC_ID_TCGA_PAAD_PDMRNAseqCNV', '_GENOMIC_ID_TCGA_PAAD_mutation_broad_gene', '_GENOMIC_ID_TCGA_PAAD_gistic2thd', '_GENOMIC_ID_data/public/TCGA/PAAD/miRNA_HiSeq_gene', '_GENOMIC_ID_TCGA_PAAD_miRNA_HiSeq', '_GENOMIC_ID_TCGA_PAAD_exp_HiSeqV2_percentile']\n", "\n", "Weight-related columns found:\n", "['followup_case_report_form_submission_reason', 'initial_weight']\n" ] } ], "source": [ "# Step 1: Review subdirectories to find one related to Underweight\n", "import os\n", "\n", "# List all directories in TCGA root directory\n", "tcga_dirs = os.listdir(tcga_root_dir)\n", "print(f\"Available TCGA directories: {tcga_dirs}\")\n", "\n", "# For the \"Underweight\" trait, we need to find cancer types that commonly report BMI or weight data\n", "# Potential relevant directories might include:\n", "# - Stomach/GI cancers (weight loss is common)\n", "# - Pancreatic cancer (often associated with weight loss)\n", "# - Lung cancer (may have cachexia/weight loss data)\n", "\n", "# Initialize variables to track potential matches\n", "relevant_dirs = []\n", "for dir_name in tcga_dirs:\n", " dir_lower = dir_name.lower()\n", " if any(term in dir_lower for term in [\"stomach\", \"pancreatic\", \"lung\", \"liver\"]):\n", " relevant_dirs.append(dir_name)\n", "\n", "print(f\"Potential relevant directories for {trait}: {relevant_dirs}\")\n", "\n", "# If we found potentially relevant directories, choose one with priority to stomach/pancreatic\n", "selected_dir = None\n", "if relevant_dirs:\n", " # Prioritize pancreatic cancer as it's often associated with significant weight loss\n", " for dir_name in relevant_dirs:\n", " if \"pancreatic\" in dir_name.lower():\n", " selected_dir = dir_name\n", " break\n", " # If no pancreatic cancer, try stomach cancer\n", " if not selected_dir:\n", " for dir_name in relevant_dirs:\n", " if \"stomach\" in dir_name.lower():\n", " selected_dir = dir_name\n", " break\n", " # If still no match, take the first relevant directory\n", " if not selected_dir and relevant_dirs:\n", " selected_dir = relevant_dirs[0]\n", "\n", "if selected_dir:\n", " print(f\"Selected directory for {trait}: {selected_dir}\")\n", " \n", " # Get the full path to the directory\n", " cohort_dir = os.path.join(tcga_root_dir, selected_dir)\n", " \n", " # Step 2: Find clinical and genetic data files\n", " clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)\n", " \n", " print(f\"Clinical data file: {clinical_file_path}\")\n", " print(f\"Genetic data file: {genetic_file_path}\")\n", " \n", " # Step 3: Load the data files\n", " clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\\t')\n", " genetic_df = pd.read_csv(genetic_file_path, index_col=0, sep='\\t')\n", " \n", " # Step 4: Print column names of clinical data\n", " print(\"\\nClinical data columns:\")\n", " print(clinical_df.columns.tolist())\n", " \n", " # Check for weight-related columns\n", " weight_related_cols = [col for col in clinical_df.columns if any(term in col.lower() for term in [\"weight\", \"bmi\", \"body\", \"mass\"])]\n", " print(\"\\nWeight-related columns found:\")\n", " print(weight_related_cols)\n", " \n", " # Check if both datasets are available and if weight data exists\n", " is_gene_available = not genetic_df.empty\n", " is_trait_available = not clinical_df.empty and len(weight_related_cols) > 0\n", " \n", " # Initial validation\n", " validate_and_save_cohort_info(\n", " is_final=False,\n", " cohort=\"TCGA\",\n", " info_path=json_path,\n", " is_gene_available=is_gene_available,\n", " is_trait_available=is_trait_available\n", " )\n", "else:\n", " print(f\"No directory specifically relevant to the trait: {trait}\")\n", " \n", " # Since the trait is not directly represented, we should record this fact\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", " print(f\"Task marked as completed. {trait} is not directly represented in the TCGA dataset.\")\n" ] }, { "cell_type": "markdown", "id": "0112c00f", "metadata": {}, "source": [ "### Step 2: Find Candidate Demographic Features" ] }, { "cell_type": "code", "execution_count": 3, "id": "af87305c", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:30:36.291684Z", "iopub.status.busy": "2025-03-25T04:30:36.291562Z", "iopub.status.idle": "2025-03-25T04:30:36.299510Z", "shell.execute_reply": "2025-03-25T04:30:36.299231Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Age columns preview:\n", "{'age_at_initial_pathologic_diagnosis': [65, 48, 75, 71, 70], 'days_to_birth': [-23962, -17794, -27600, -26028, -25920]}\n", "\n", "Gender columns preview:\n", "{'gender': ['MALE', 'MALE', 'MALE', 'MALE', 'FEMALE']}\n" ] } ], "source": [ "# Identify candidate age and gender columns\n", "candidate_age_cols = [\"age_at_initial_pathologic_diagnosis\", \"days_to_birth\"]\n", "candidate_gender_cols = [\"gender\"]\n", "\n", "# Load the clinical data file path\n", "clinical_file_path, _ = tcga_get_relevant_filepaths(os.path.join(tcga_root_dir, \"TCGA_Pancreatic_Cancer_(PAAD)\"))\n", "\n", "# Load the clinical data\n", "clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\\t')\n", "\n", "# Preview age 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 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" ] }, { "cell_type": "markdown", "id": "746dfc5c", "metadata": {}, "source": [ "### Step 3: Select Demographic Features" ] }, { "cell_type": "code", "execution_count": 4, "id": "1add4be4", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:30:36.300520Z", "iopub.status.busy": "2025-03-25T04:30:36.300415Z", "iopub.status.idle": "2025-03-25T04:30:36.303005Z", "shell.execute_reply": "2025-03-25T04:30:36.302726Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Chosen age column: age_at_initial_pathologic_diagnosis\n", "Chosen gender column: gender\n" ] } ], "source": [ "# Inspect age columns\n", "age_cols = {'age_at_initial_pathologic_diagnosis': [65, 48, 75, 71, 70], \n", " 'days_to_birth': [-23962, -17794, -27600, -26028, -25920]}\n", "\n", "# Inspect gender columns\n", "gender_cols = {'gender': ['MALE', 'MALE', 'MALE', 'MALE', 'FEMALE']}\n", "\n", "# Select the appropriate columns\n", "# For age, choose age_at_initial_pathologic_diagnosis as it directly gives the age in years\n", "# days_to_birth would need conversion (dividing by 365.25 and taking absolute value)\n", "age_col = 'age_at_initial_pathologic_diagnosis' if age_cols else None\n", "\n", "# For gender, we have only one option which appears to have valid values\n", "gender_col = 'gender' if gender_cols and len(gender_cols) > 0 else None\n", "\n", "# Print the chosen columns\n", "print(f\"Chosen age column: {age_col}\")\n", "print(f\"Chosen gender column: {gender_col}\")\n" ] }, { "cell_type": "markdown", "id": "bb3ad4d8", "metadata": {}, "source": [ "### Step 4: Feature Engineering and Validation" ] }, { "cell_type": "code", "execution_count": 5, "id": "91c11731", "metadata": { "execution": { "iopub.execute_input": "2025-03-25T04:30:36.303977Z", "iopub.status.busy": "2025-03-25T04:30:36.303877Z", "iopub.status.idle": "2025-03-25T04:30:57.573852Z", "shell.execute_reply": "2025-03-25T04:30:57.573320Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Weight-related columns found: ['followup_case_report_form_submission_reason', 'initial_weight']\n", "Created underweight feature with 9 underweight patients out of 196 total\n", "Clinical features columns: ['Underweight', 'Age', 'Gender']\n", "Saved clinical data with 196 samples\n", "After normalization: 19848 genes remaining\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Saved normalized gene expression data\n", "Linked data shape: (183, 19851) (samples x features)\n", "First few columns in linked_data: ['Underweight', 'Age', 'Gender', 'A1BG', 'A1BG-AS1']\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "After handling missing values, data shape: (183, 19851)\n", "For the feature 'Underweight', the least common label is '1' with 9 occurrences. This represents 4.92% of the dataset.\n", "The distribution of the feature 'Underweight' in this dataset is fine.\n", "\n", "Quartiles for 'Age':\n", " 25%: 57.0\n", " 50% (Median): 65.0\n", " 75%: 73.0\n", "Min: 35\n", "Max: 88\n", "The distribution of the feature 'Age' in this dataset is fine.\n", "\n", "For the feature 'Gender', the least common label is '0' with 82 occurrences. This represents 44.81% of the dataset.\n", "The distribution of the feature 'Gender' in this dataset is fine.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Saved usable linked data to ../../output/preprocess/Underweight/TCGA.csv\n" ] } ], "source": [ "# Step 1: Extract and standardize clinical features\n", "# Use the Pancreatic Cancer directory identified in Step 1\n", "selected_dir = \"TCGA_Pancreatic_Cancer_(PAAD)\"\n", "cohort_dir = os.path.join(tcga_root_dir, selected_dir)\n", "\n", "# Get the file paths for clinical and genetic data\n", "clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)\n", "\n", "# Load the data\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", "# Check for the presence of weight-related columns\n", "weight_related_cols = [col for col in clinical_df.columns if any(term in col.lower() for term in [\"weight\", \"bmi\", \"body\", \"mass\"])]\n", "print(f\"Weight-related columns found: {weight_related_cols}\")\n", "\n", "# Create a function to convert weight data to an underweight binary classification\n", "def create_underweight_feature(df):\n", " \"\"\"Create a binary underweight feature from initial_weight column\"\"\"\n", " # Check if initial_weight column exists\n", " if 'initial_weight' not in df.columns:\n", " print(\"No initial_weight column found\")\n", " # Use sample IDs as fallback (less accurate, but following the dataset structure)\n", " return df.index.to_series().apply(tcga_convert_trait)\n", " \n", " # Extract initial weight values and convert to numeric\n", " weights = pd.to_numeric(df['initial_weight'], errors='coerce')\n", " \n", " # Define underweight threshold (generally BMI < 18.5, but without height data, \n", " # we'll use a reasonable threshold of 50kg for adults)\n", " underweight_threshold = 50 # kg\n", " \n", " # Create binary classification (1 = underweight, 0 = not underweight)\n", " underweight = (weights < underweight_threshold).astype(int)\n", " \n", " print(f\"Created underweight feature with {underweight.sum()} underweight patients out of {len(underweight)} total\")\n", " return underweight\n", "\n", "# Create the underweight trait\n", "underweight_feature = create_underweight_feature(clinical_df)\n", "\n", "# Create a DataFrame with the clinical features\n", "feature_list = []\n", "# Explicitly name the trait column correctly\n", "feature_list.append(underweight_feature.rename(trait))\n", "\n", "if age_col:\n", " age_data = clinical_df[age_col].apply(tcga_convert_age).rename(\"Age\")\n", " feature_list.append(age_data)\n", "if gender_col:\n", " gender_data = clinical_df[gender_col].apply(tcga_convert_gender).rename(\"Gender\")\n", " feature_list.append(gender_data)\n", "\n", "clinical_features = pd.concat(feature_list, axis=1)\n", "\n", "# Verify the trait column exists with the correct name\n", "print(f\"Clinical features columns: {clinical_features.columns.tolist()}\")\n", "if trait not in clinical_features.columns:\n", " print(f\"Warning: '{trait}' column not found, adding it explicitly\")\n", " clinical_features[trait] = underweight_feature.values\n", "\n", "# Save the clinical data to out_clinical_data_file\n", "os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)\n", "clinical_features.to_csv(out_clinical_data_file)\n", "print(f\"Saved clinical data with {len(clinical_features)} samples\")\n", "\n", "# Step 2: Normalize gene symbols in gene expression data\n", "# Transpose to get genes as rows\n", "gene_df = genetic_df\n", "\n", "# Normalize gene symbols using NCBI Gene database synonyms\n", "normalized_gene_df = normalize_gene_symbols_in_index(gene_df)\n", "print(f\"After normalization: {len(normalized_gene_df)} genes remaining\")\n", "\n", "# Save the normalized gene expression 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 expression data\")\n", "\n", "# Step 3: Link clinical and genetic data\n", "# Merge clinical features with genetic expression data\n", "linked_data = clinical_features.join(normalized_gene_df.T, how='inner')\n", "print(f\"Linked data shape: {linked_data.shape} (samples x features)\")\n", "\n", "# Verify trait column exists in linked_data\n", "print(f\"First few columns in linked_data: {linked_data.columns[:5].tolist()}\")\n", "if trait not in linked_data.columns:\n", " print(f\"ERROR: '{trait}' column not found in linked_data\")\n", " # Try to fix by adding it if we still have the original data\n", " if clinical_features is not None and trait in clinical_features.columns:\n", " common_indices = set(linked_data.index).intersection(set(clinical_features.index))\n", " linked_data[trait] = clinical_features.loc[common_indices, trait]\n", " print(f\"Added '{trait}' column from clinical_features\")\n", "\n", "# Step 4: Handle missing values\n", "cleaned_data = handle_missing_values(linked_data, trait_col=trait)\n", "print(f\"After handling missing values, data shape: {cleaned_data.shape}\")\n", "\n", "# Step 5: Determine if trait or demographics are severely biased\n", "trait_biased, cleaned_data = judge_and_remove_biased_features(cleaned_data, trait=trait)\n", "\n", "# Step 6: Validate data quality and save cohort information\n", "note = \"The dataset contains gene expression data along with clinical information for pancreatic cancer patients from TCGA. The 'Underweight' trait was derived from the initial_weight column.\"\n", "is_usable = validate_and_save_cohort_info(\n", " is_final=True,\n", " cohort=\"TCGA\",\n", " info_path=json_path,\n", " is_gene_available=True,\n", " is_trait_available=True,\n", " is_biased=trait_biased,\n", " df=cleaned_data,\n", " note=note\n", ")\n", "\n", "# Step 7: Save the linked data if usable\n", "if is_usable:\n", " os.makedirs(os.path.dirname(out_data_file), exist_ok=True)\n", " cleaned_data.to_csv(out_data_file)\n", " print(f\"Saved usable linked data to {out_data_file}\")\n", "else:\n", " print(\"Dataset was determined to be unusable and was 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 }