deCODE Study Index
gentropy.datasource.decode.study_index.deCODEStudyIdParts
¶
Bases: NamedTuple
deCODE study ID parts.
Examples:
>>> data = [("deCODE-proteomics-smp_Proteomics_SMP_PC0_10000_2_GENE1_PROTEIN1_00000001",),]
>>> schema = "studyId STRING"
>>> df = spark.createDataFrame(data, schema)
>>> id_parts = deCODEStudyIdParts.extract_study_id_parts(f.col("studyId"))
>>> df.select(*id_parts).show(truncate=False)
+---------------------+------------------+---------+---------------------+----------------------+
|projectId |datasourceType |aptamerId|geneSymbolFromStudyId|proteinNameFromStudyId|
+---------------------+------------------+---------+---------------------+----------------------+
|deCODE-proteomics-smp|Proteomics_SMP_PC0|10000-2 |GENE1 |PROTEIN1 |
+---------------------+------------------+---------+---------------------+----------------------+
>>> df.select(id_parts.trait).show(truncate=False)
+-----------------------------------------+
|traitFromSource |
+-----------------------------------------+
|Proteomics_SMP_PC0_10000-2_GENE1_PROTEIN1|
+-----------------------------------------+
Source code in src/gentropy/datasource/decode/study_index.py
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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | |
aptamer_id: Column
instance-attribute
¶
Aptamer identifier extracted from the study ID.
datasource_type: Column
instance-attribute
¶
Data source type - SMP or Raw.
gene_symbol: Column
instance-attribute
¶
Gene Symbol derived from the study ID.
project_id: Column
instance-attribute
¶
Project ID extracted from the study ID.
protein_name: Column
instance-attribute
¶
Protein name derived from the study ID.
trait: Column
property
¶
Trait derived from the study ID.
extract_study_id_parts(study_id: Column) -> deCODEStudyIdParts
classmethod
¶
Extract gene symbol from study ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
study_id
|
Column
|
Study ID column. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
deCODEStudyIdParts |
deCODEStudyIdParts
|
Extracted parts of the study ID. |
Source code in src/gentropy/datasource/decode/study_index.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
get_pattern() -> str
staticmethod
¶
Regex pattern to extract deCODE study ID parts.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Regex pattern. |
The pattern captures the following groups: (1) project ID (2) study type (3) inner part (PC0 or SMP_PC0) (4) aptamer identifier (5) gene symbol (6) protein name (2-6) trait
Source code in src/gentropy/datasource/decode/study_index.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
gentropy.datasource.decode.study_index.deCODEStudyIndex
¶
Factory helpers for constructing the deCODE pQTL study index.
This class is not instantiated directly. Its class methods transform the
deCODEManifest,
AptamerMetadata, and
MolecularComplex datasets into a
ProteinQuantitativeTraitLocusStudyIndex.
Sample-size and ancestry metadata are populated from
deCODEPublicationMetadata, and the
study ID is optionally updated after harmonisation to incorporate curated
gene symbols and protein names sourced from the aptamer mapping table.
Source code in src/gentropy/datasource/decode/study_index.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |
from_manifest(manifest: deCODEManifest, aptamer_metadata: AptamerMetadata, molecular_complex: MolecularComplex) -> ProteinQuantitativeTraitLocusStudyIndex
classmethod
¶
Build a pQTL study index by joining the manifest, aptamer table, and protein complexes.
Processing steps:
- Parse the structured study-ID components (project, assay type, aptamer ID, gene symbol, protein name) from every row in the manifest.
- Filter out rows where the gene symbol or protein name encoded in the study ID
is missing (
NA/No_Protein/Deprecated). - Inner-join the aptamer mapping table on
aptamerIdto obtain curated target metadata; this restricts the study index to aptamers present in the SomaScan study table (a subset of the full manifest). - Left-join the protein-complex table on the sorted, comma-joined UniProt protein
ID string to annotate multi-target aptamers with a
molecularComplexId. - Populate bibliographic and cohort metadata from
deCODEPublicationMetadata, including sample sizes, biosample ID, ancestry, and LD population structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
deCODEManifest
|
Manifest dataset cataloguing all available assays. |
required |
aptamer_metadata
|
AptamerMetadata
|
Curated aptamer-to-protein mapping table. |
required |
molecular_complex
|
MolecularComplex
|
Protein complex annotations from
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
ProteinQuantitativeTraitLocusStudyIndex |
ProteinQuantitativeTraitLocusStudyIndex
|
Study index ready for harmonisation. |
Source code in src/gentropy/datasource/decode/study_index.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
get_discovery_samples(project_id: Column, metadata: deCODEPublicationMetadata) -> Column
classmethod
¶
Get discoverySamples based on projectId.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
Column
|
Project ID column. |
required |
metadata
|
deCODEPublicationMetadata
|
Metadata for the deCODE publication. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Column |
Column
|
Number of discovery samples column. |
Source code in src/gentropy/datasource/decode/study_index.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
get_initial_sample(project_id: Column, metadata: deCODEPublicationMetadata) -> Column
classmethod
¶
Get initial sample size based on projectId.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
Column
|
Project ID column. |
required |
metadata
|
deCODEPublicationMetadata
|
Metadata for the deCODE publication. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Column |
Column
|
Initial sample size column. |
Source code in src/gentropy/datasource/decode/study_index.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
get_n_samples(project_id: Column, metadata: deCODEPublicationMetadata) -> Column
classmethod
¶
Get number of samples based on projectId.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_id
|
Column
|
Project ID column. |
required |
metadata
|
deCODEPublicationMetadata
|
Metadata for the deCODE publication. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Column |
Column
|
Number of samples column. |
Source code in src/gentropy/datasource/decode/study_index.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
update_study_id(study_id: Column, targets: Column) -> Column
staticmethod
¶
Update study ID to include gene symbol and protein name from target metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
study_id
|
Column
|
Original study ID column. |
required |
targets
|
Column
|
Target metadata column containing gene symbol and protein name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Column |
Column
|
Updated study ID column with gene symbol and protein name. |
The updated study ID will have the format: {projectId}{datasourceType}{aptamerId}{geneSymbols}{proteinNames}
Where geneSymbols and proteinNames are comma-joined values from the targets array.
In case the geneSymbol or proteinName are missing, we use the placeholder value "_NA" to maintain the structure of the study ID.
Source code in src/gentropy/datasource/decode/study_index.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | |