# Annotation table for logreg

**URL:** https://discuss.hail.is/t/annotation-table-for-logreg/694
**Category:** Help \[0.1\]
**Created:** [October 16, 2018, 1:34pm UTC](https://discuss.hail.is/t/annotation-table-for-logreg/694 "2018-10-16T13:34:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hhx037](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/hhx037/32/160_2.png) [@hhx037](https://discuss.hail.is/u/hhx037)
#### Post date: [October 16, 2018, 1:34pm UTC](https://discuss.hail.is/t/annotation-table-for-logreg/694/1 "2018-10-16T13:34:17Z")

</div>

Hi,

I was wondering what was the best way to import a table in which some of the phenotypes are reported as 0 (control) and 1 (case), in order to perform a logistic regression. At the moment I use hl.cond to create bool columns:

```
def case(pheno):
    return hl.cond(pheno == 1, True, False)

table = table.annotate(pheno_case = case(table.pheno))
ds = ds.annotate_cols(**table[ds.s])

```

and then:

`gwas = hl.logistic_regression(test='score',y=ds.pheno_case,x=ds.GT.n_alt_alleles(),covariates=[ds.is_female, ds.age, ds.weight, ds.PC1, ds.PC2, ds.PC3, ds.PC4, ds.PC5])`

I must be doing something wrong though, as when I use logreg all the p-values are inflated\* (and that’s also the case even if I use 0/1 instead of False/True)

- I know there are inflated because I have performed logistic regressions on that same set using other software. Also, interestingly, using linreg (with 0s and 1s, obviously) does give the expected result, no inflation.

---

<div class="post-metadata">

### Author: ![jbloom](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/jbloom/32/109_2.png) [@jbloom](https://discuss.hail.is/u/jbloom)
#### Post date: [October 16, 2018, 1:51pm UTC](https://discuss.hail.is/t/annotation-table-for-logreg/694/2 "2018-10-16T13:51:46Z")

</div>

Hi there! You need to include the intercept explicitly as a covariate 1. See the examples in the documentation of logistic\_regression.

---

<div class="post-metadata">

### Author: ![hhx037](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/hhx037/32/160_2.png) [@hhx037](https://discuss.hail.is/u/hhx037)
#### Post date: [October 16, 2018, 2:10pm UTC](https://discuss.hail.is/t/annotation-table-for-logreg/694/3 "2018-10-16T14:10:40Z")

</div>

Argh… yes, it works now! Thank you.

To get back to the table question, is using hl.cond the best way to get bool, or is there an automatic way to specify 0/1 columns that should be treated as bool during table import?

---

<div class="post-metadata">

### Author: ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)
#### Post date: [October 16, 2018, 2:21pm UTC](https://discuss.hail.is/t/annotation-table-for-logreg/694/4 "2018-10-16T14:21:12Z")

</div>

What does the `hl.cond` look like? There may be an easier way. For example, `hl.cond(mt.foo == 1, True, False)` is the same as just `mt.foo == 1`.

You can also use 0/1 numeric phenotypes for logistic regression – we check internally.

---

<div class="post-metadata">

### Author: ![hhx037](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/hhx037/32/160_2.png) [@hhx037](https://discuss.hail.is/u/hhx037)
#### Post date: [October 16, 2018, 2:38pm UTC](https://discuss.hail.is/t/annotation-table-for-logreg/694/5 "2018-10-16T14:38:37Z")

</div>

Splendid, no need for the hl.cond then, thanks 😅
