From cc2e6d0a2d1e10a3ef76c4a20e296d0b3f3d8662 Mon Sep 17 00:00:00 2001 From: arnovanhilten Date: Thu, 21 Apr 2022 15:43:47 +0200 Subject: [PATCH 1/3] added missing dependency --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index fef0278..4ba5dfe 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,5 @@ pyranges==0.0.95 pytest==6.2.3 tables==3.6.1 tqdm==4.59.0 +PyYAML==6.0 + From 13315fa84db854daaf455fd824eb5e3e477ddfe3 Mon Sep 17 00:00:00 2001 From: RossDeVito Date: Mon, 24 Jun 2024 16:20:01 -0700 Subject: [PATCH 2/3] Correct mixing with noise to reach desired heritability to g' = sqrt(h)*g + sqrt(1-h)*N(0,1) --- scripts/phenotype_simulator.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/phenotype_simulator.py b/scripts/phenotype_simulator.py index 310f76b..4f639a0 100644 --- a/scripts/phenotype_simulator.py +++ b/scripts/phenotype_simulator.py @@ -111,9 +111,19 @@ def heritability_injection(self, scores): """ #Normalize scores scores = (scores - np.mean(scores))/np.std(scores) - #Apply g' = h*g + sqrt(1-h^2)*N(0,1) - phenotype_scores = self.heritability * scores + np.random.randn(len(scores)) * np.sqrt(1 - self.heritability * self.heritability) - self.get_distribution(phenotype_scores, title = "Phenotype Scores with Heredity {} {}".format(self.heritability, self.phenotype_experiment_name), ylabel="Number of People", xlabel="Genetic Risk Score") + #Where h is heritability, apply g' = sqrt(h)*g + sqrt(1-h)*N(0,1) + phenotype_scores = ( + np.sqrt(self.heritability) * scores + + np.sqrt(1 - self.heritability) * np.random.randn(len(scores)) + ) + self.get_distribution( + phenotype_scores, + title = "Phenotype Scores with Heredity {} {}".format( + self.heritability, self.phenotype_experiment_name + ), + ylabel="Number of People", + xlabel="Genetic Risk Score" + ) return phenotype_scores def patient_level_score_injection(self, scores): From f56a922a692beb5abcb6e0864b710f843c64ea35 Mon Sep 17 00:00:00 2001 From: Ross DeVito Date: Mon, 24 Jun 2024 16:39:32 -0700 Subject: [PATCH 3/3] Revert "added missing dependency" --- requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4ba5dfe..fef0278 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,3 @@ pyranges==0.0.95 pytest==6.2.3 tables==3.6.1 tqdm==4.59.0 -PyYAML==6.0 -