Programatically define covariates

#1

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.

#2

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

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

1 Like
#3

Thanks!

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

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