# Programatically define covariates

**URL:** <https://discuss.hail.is/t/programatically-define-covariates/948>\
**Category:** Hail Query & hailctl\
**Created:** [May 2, 2019, 3:36pm UTC](https://discuss.hail.is/t/programatically-define-covariates/948 "2019-05-02T15:36:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhchung](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/jhchung/32/269_2.png) [@jhchung](https://discuss.hail.is/u/jhchung)\
**Post date:** [May 2, 2019, 3:36pm UTC](https://discuss.hail.is/t/programatically-define-covariates/948/1 "2019-05-02T15:36:11Z")

</div>

Hi,

Is there a way to define a list of covariates for the `logistic_regression_rows` (or any regression method)? I have an example working where I define covariates for analysis, but I would like to make it more flexible and define covariates in a config file and pass a list to the regression step.

Thanks.

---

<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:** [May 2, 2019, 10:07pm UTC](https://discuss.hail.is/t/programatically-define-covariates/948/2 "2019-05-02T22:07:06Z")

</div>

supposing you have a list of python strings indicating covariate fields, `covs`:

```python
r = hl.logistic_regression_rows(x=mt.GT.n_alt_alleles(), 
                                y=..., 
                                covariates=[mt[cov] for cov in covs])

```

---

<div class="post-metadata">

**Author:** ![jhchung](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/jhchung/32/269_2.png) [@jhchung](https://discuss.hail.is/u/jhchung)\
**Post date:** [May 3, 2019, 6:26pm UTC](https://discuss.hail.is/t/programatically-define-covariates/948/3 "2019-05-03T18:26:00Z")

</div>

Thanks!

I was able to get the following code to work for phenotypes stored in a `pheno` column annotation

```auto
r = hl.logistic_regression_rows(
    x=mt.GT.n_alt_alleles(),
    y = ...,
    covariates = [mt['pheno'][cov] for cov in covs]
)

```
