deCODE Summary Statistics
gentropy.datasource.decode.summary_statistics.deCODEHarmonisationConfig
¶
Bases: BaseModel
Configuration for deCODE harmonisation step.
Variant flipping logic
The flipping window size has to be the same as the one used for
creating the variant direction dataset, otherwise the join will produce incorrect results.
The default value is sourced from gentropy.dataset.variant_direction.DEFAULT_WINDOW_SIZE
to keep both sides in sync.
Source code in src/gentropy/datasource/decode/summary_statistics.py
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 | |
flipping_window_size: int = DEFAULT_WINDOW_SIZE
class-attribute
instance-attribute
¶
Window size (bp) used to partition the VariantDirection dataset (exact match only!).
Defaults to DEFAULT_WINDOW_SIZE from gentropy.dataset.variant_direction.
min_allele_count_threshold: int = Field(ge=1)
class-attribute
instance-attribute
¶
Minimum minor allele count required to retain a variant.
perform_min_allele_count_filter: bool
instance-attribute
¶
Whether to filter variants based on minor allele count (MAC) threshold.
perform_sample_size_filter: bool
instance-attribute
¶
Whether to remove variants with low sample size.
remove_ambiguous_alleles: bool
instance-attribute
¶
Whether to exclude strand-ambiguous variants (A/T or C/G) from the gnomAD reference slice used for allele flipping.
When True, ambiguous entries are dropped from vd_slice so they cannot
influence the flip direction. Ambiguous variants in the summary statistics that
have no gnomAD match are still retained in the output with direction=1
(no flip) — they are not removed from the harmonised result. This is intentional:
excluding unmatched ambiguous variants would discard data without any evidence
that the orientation is wrong.
remove_monomorphic_alleles: bool
instance-attribute
¶
Whether to remove variants with equal effect and other alleles during harmonisation.
sample_size_threshold: int = Field(ge=1)
class-attribute
instance-attribute
¶
Minimum sample size to retain a variant. Must be >= 1.
verify_atgc: bool
instance-attribute
¶
Whether to verify that all alleles are A/T/G/C during harmonisation.
Strict ATGC validation also removes * (star) and ! (multiallelic) alleles,
so no dedicated symbol filters are required.
gentropy.datasource.decode.summary_statistics.deCODESummaryStatistics
¶
Utility class for ingesting and harmonising deCODE proteomics summary statistics.
This class is never instantiated directly. It exposes two class-method pipelines:
-
txtgz_to_parquet– reads one or more gzipped TSV files from the deCODE S3 bucket in parallel (using aThreadPoolExecutor) and writes them as Parquet files partitioned bystudyId. -
from_source– takes the raw Parquet output together with theVariantDirectiongnomAD reference and theProteinQuantitativeTraitLocusStudyIndexand produces fully harmonisedSummaryStatisticsand an updated study index with curated study IDs.
Class attributes
N_THREAD_OPTIMAL (int): Recommended number of ingestion threads (10). N_THREAD_MAX (int): Hard upper limit on ingestion threads (500).
Source code in src/gentropy/datasource/decode/summary_statistics.py
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 159 160 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 | |
from_source(raw_summary_statistics: DataFrame, variant_direction: VariantDirection, decode_study_index: ProteinQuantitativeTraitLocusStudyIndex, config: deCODEHarmonisationConfig) -> tuple[SummaryStatistics, ProteinQuantitativeTraitLocusStudyIndex]
classmethod
¶
Harmonise raw deCODE summary statistics and produce an updated study index.
The harmonisation pipeline performs the following steps in order:
- Schema alignment – renames deCODE-specific column names and builds
the source-oriented variant ID using
chr_pos_ref_alt. - Allele, MAC, and sample-size filtering – applies the enabled
validity filters and configurable thresholds. If
config.remove_ambiguous_allelesisTrue, strand-ambiguous variants (A/T or C/G) are removed from the gnomAD reference slice only — ambiguous sumstat variants absent from gnomAD are retained with no flip applied (seedeCODEHarmonisationConfig.remove_ambiguous_alleles). - Allele-flipping – left-joins against the gnomAD
VariantDirectiondataset (positive strand only) using(chromosome, rangeId, variantId). Variants found in gnomAD are flipped to the gnomAD reference orientation; unmatched variants are kept as-is. - EAF inference –
infer_allele_frequency_from_mafmaps the deCODEimpMAFto an effect-allele frequency using the gnomAD EUR AF. - Sanity filter – applies the standard
SummaryStatistics.sanity_filter. - Study-ID update – replaces the raw study IDs derived from file paths with IDs that embed curated gene symbols and protein names from the aptamer mapping table.
Variant flipping window
config.flipping_window_size must match the window used when
building the VariantDirection dataset. A mismatch will silently produce
incorrect join keys.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_summary_statistics
|
DataFrame
|
Raw summary-statistics Parquet DataFrame
as produced by |
required |
variant_direction
|
VariantDirection
|
gnomAD variant-direction reference used for allele flipping and EAF inference. |
required |
decode_study_index
|
ProteinQuantitativeTraitLocusStudyIndex
|
pQTL study
index produced by |
required |
config
|
deCODEHarmonisationConfig
|
Configuration used during the harmonisation step. |
required |
Returns:
| Type | Description |
|---|---|
tuple[SummaryStatistics, ProteinQuantitativeTraitLocusStudyIndex]
|
tuple[SummaryStatistics, ProteinQuantitativeTraitLocusStudyIndex]: A 2-tuple of the harmonised summary statistics and the study index with updated, curated study IDs. |
Source code in src/gentropy/datasource/decode/summary_statistics.py
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 | |
txtgz_to_parquet(session: Session, summary_statistics_list: list[str], raw_summary_statistics_output_path: str, n_threads: int = N_THREAD_OPTIMAL) -> None
classmethod
¶
Convert txt.gz (tsv) summary statistics to Parquet format.
This method reads multiple gzipped TSV summary statistics files, processes them in parallel using the specified number of threads, and writes the combined output in Parquet format, partitioned by studyId.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Session
|
Gentropy session. |
required |
summary_statistics_list
|
list[str]
|
List of summary statistics paths. |
required |
raw_summary_statistics_output_path
|
str
|
Output path for raw summary statistics in Parquet format. |
required |
n_threads
|
int
|
Number of threads to use. |
N_THREAD_OPTIMAL
|
Source code in src/gentropy/datasource/decode/summary_statistics.py
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 159 160 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 | |