Repository navigation
Conversation
…eat/biosample-enrichment-regression
Comment on lines
+510
to
+512
| - pts_credible_set | ||
| - pts_study | ||
| - pts_target |
Contributor
There was a problem hiding this comment.
The L2G already requires cs, study & target upstream, no need to add these, will make the dag render more complex then needed.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
biosample_enrichmentstep topts. For each GWAS study and each tissue or cell type in a specificity panel, it tests whether the genes L2G prioritises are more specific to that biosample than gene length and gene density explain.There is one linear regression per study × biosample, fitted over protein-coding genes:
specificity_scorein the biosample.Optionally, studies with an identical
diseaseIdsset can be pooled (pool_by_disease, off by default).The code is split in two:
pts/src/pts/transformers/biosample_enrichment.pyhandles the data (loading, joining, shaping, writing).pts/src/pts/transformers/enrichment/regression.pydoes only the numbers (numpy arrays in, numbers out).Main:
1.
biosample_enrichment()is called by thetransformtask frompts/config.yaml. It reads the settings: panels, pooling, kind of standard error and window sizes.2. Loading and preparing inputs (
biosample_enrichment.py). All inputs are read lazily withscan_dataset.gene_covariates()targetgwas_studies()studystudy_gene_scores()l2g_prediction+credible_setstudyLocusIdnStudiesPooled)3. Per panel.
specificity_matrix()pivots the panel'sbaseline_expressionrows into a gene × biosample table.score_panel()then:regression.Designonce for the panel;4. The regression (
regression.py).Design.__init__runs once per panel. It removes from each biosample's specificity what length and density explain. By Frisch-Waugh-Lovell, this gives the same slope as the full model and lets every study reuse the adjustment. It also precomputes per-region totals.Design.fitruns once per batch. The slope for the whole batch is one matrix product. The standard error comes from_noise_by_region(default),_noise_by_gene(HC0) or the classical formula.upper_tail_p,bonferroniandbenjamini_hochbergturn z-scores into p-values and corrected p-values.5. Writing. Each unit's results are expanded back to its member studies. The panels are concatenated, cast to
OUTPUT_SCHEMA, sorted, and written withwrite_datasettooutput/biosample_enrichment: one row per study × biosample.Other changes
pts/config.yaml: the new step, with a GTEx tissue panel.orchestration/.../unified_pipeline.yaml: apts_biosample_enrichmentnode, also added topts_release_metrics.depends_on. It is published but no other step reads it.croissant: the distribution entry and thebiosample_enrichmentrecord set.pts/pyproject.toml:statsmodelsadded to thetestgroup only, as the reference for the tests.Validation
baseline_expressionspecificity gives a per-study Spearman of 0.985 (median) against CELLEX.In one picture