File size: 4,152 Bytes
f88156f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "461d7761",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-03-25T07:00:18.889703Z",
     "iopub.status.busy": "2025-03-25T07:00:18.889550Z",
     "iopub.status.idle": "2025-03-25T07:00:19.056212Z",
     "shell.execute_reply": "2025-03-25T07:00:19.055827Z"
    }
   },
   "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 = \"Bone_Density\"\n",
    "\n",
    "# Input paths\n",
    "tcga_root_dir = \"../../input/TCGA\"\n",
    "\n",
    "# Output paths\n",
    "out_data_file = \"../../output/preprocess/Bone_Density/TCGA.csv\"\n",
    "out_gene_data_file = \"../../output/preprocess/Bone_Density/gene_data/TCGA.csv\"\n",
    "out_clinical_data_file = \"../../output/preprocess/Bone_Density/clinical_data/TCGA.csv\"\n",
    "json_path = \"../../output/preprocess/Bone_Density/cohort_info.json\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b4e032e6",
   "metadata": {},
   "source": [
    "### Step 1: Initial Data Loading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "427fe1ea",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2025-03-25T07:00:19.057737Z",
     "iopub.status.busy": "2025-03-25T07:00:19.057582Z",
     "iopub.status.idle": "2025-03-25T07:00:19.064119Z",
     "shell.execute_reply": "2025-03-25T07:00:19.063799Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No suitable directory found in TCGA for Bone_Density.\n",
      "TCGA focuses on cancer types, not directly on bone density measurements.\n",
      "Skipping this trait as recommended in the guidelines.\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "import pandas as pd\n",
    "\n",
    "# 1. Find the most relevant directory for Bone Density\n",
    "subdirectories = os.listdir(tcga_root_dir)\n",
    "target_trait = trait.lower().replace(\"_\", \" \")  # Convert to lowercase for case-insensitive matching\n",
    "\n",
    "# Words related to bone density that might appear in directory names\n",
    "bone_related_terms = [\"bone\", \"density\", \"osteoporosis\", \"skeletal\", \"osseous\"]\n",
    "\n",
    "# First try direct matches\n",
    "matched_dir = None\n",
    "for subdir in subdirectories:\n",
    "    subdir_lower = subdir.lower()\n",
    "    # Check if any bone-related term is in the directory name\n",
    "    if any(term in subdir_lower for term in bone_related_terms):\n",
    "        matched_dir = subdir\n",
    "        break\n",
    "\n",
    "# If no direct match found, look specifically for Sarcoma as it may include bone sarcomas\n",
    "if not matched_dir:\n",
    "    for subdir in subdirectories:\n",
    "        if \"sarcoma_(sarc)\" in subdir.lower():\n",
    "            matched_dir = subdir\n",
    "            break\n",
    "\n",
    "# No suitable directory found - we should skip this trait\n",
    "print(f\"No suitable directory found in TCGA for {trait}.\")\n",
    "print(\"TCGA focuses on cancer types, not directly on bone density measurements.\")\n",
    "print(\"Skipping this trait as recommended in the guidelines.\")\n",
    "\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",
    ")"
   ]
  }
 ],
 "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
}