Skip to content

Commit

Permalink
Fix normalization of the penetrance table so the NULL model works
Browse files Browse the repository at this point in the history
  • Loading branch information
jrm5100 committed Apr 23, 2021
1 parent eebe6c0 commit c2a73d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pandas_genomics/sim/BAMS.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ def generate_case_control(
if (pen_table.min() != 0) or (pen_table.max() != 1):
pen_table_min = pen_table.min()
pen_table_range = pen_table.max() - pen_table_min
pen_table = (pen_table - pen_table_min) / pen_table_range
if pen_table_range > 0:
pen_table = (pen_table - pen_table_min) / pen_table_range
# Otherwise the penetrance table is flat, i.e. a null model

# Create table of Prob(GT) based on MAF, assuming HWE
prob_snp1 = np.array([(1 - maf1) ** 2, 2 * maf1 * (1 - maf1), (maf1) ** 2])
Expand Down
8 changes: 8 additions & 0 deletions tests/simulation/test_biallelic_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ def test():

# Test quantitative sim
simulated_df_quant = test_sim.generate_quantitative()


def test_null():
bas = BAMS(PenetranceTables.NULL)
simulated = bas.generate_case_control(10000, 1000, 0.1, 0.1)
# maf should be similar to the specified one despite a large fraction of cases
# specifically assert it is within 5%
assert abs(0.1 - simulated["SNP1"].genomics.maf) / 0.1 < 0.05

0 comments on commit c2a73d8

Please sign in to comment.