Export the results of agg.linreg

I know this might be a stupid question, but I was wondering how to export the output of agg.linreg

Thank you

To a file? You can export a table to a file using Table.export.

For example:

gwas.export('file.txt')

You may want to flatten things out sometimes:

gwas.flatten().export('file.txt')

So I use the following:

gwas=hl.agg.linreg(“my.pheno.health, [1, mt.GT.n_alt_alleles(), my.pheno.age,my.GT.n_alt_alleles()*mt.pheno.age])
and the gwas object has no export attribute.

However, if I use hl.linear _regression_rows(), I can easily export the data

the linreg aggregator needs to be used with an annotate, e.g.:

mt = mt.annotate_rows(
    gwas=hl.agg.linreg(
        “my.pheno.health, 
        [1, mt.GT.n_alt_alleles(), my.pheno.age,my.GT.n_alt_alleles()*mt.pheno.age]))
mt.rows().select('gwas').flatten().export(...)

Thank you again for taking the time and answering my questions, I really appreciate it.

I was also wondering, if there is a way to sort these results by p_value or multi p_value and view only the first variant?

totally.

mt = mt.annotate_rows(
    linreg=hl.agg.linreg(
        my.pheno.health, 
        [1, mt.GT.n_alt_alleles(), my.pheno.age,my.GT.n_alt_alleles()*mt.pheno.age]))
gwas = mt.rows()
gwas.order_by(-gwas.linreg.p_value[0]).show()

(show will print the first 10 by default, you could also do show(1))