Programatically define covariates

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.

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

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]
)