I tried to select some nested fields but I received a LookupError

I can access vep.transcript.gene but i want to use it as;

t.key_by().select(‘vep.transcript.gene’, ‘info.AF’).export(‘/path/to/file.tsv’)

which gives me error

select('abc') only works if 'abc' is the literal name of a field. Instead you can do this:

t = t.key_by()
t.select(gene=t.vep.transcript.gene, AF=t.info.AF).export(...)


EDIT: Fixed mistake discussed below.

1 Like

t_lc.key_by().select(gene=t_lc.vep.transcript_consequences[0].gene_symbol, lof=t_lc.vep.transcript_consequences[0].lof,hets=t_lc.hets, n_hets=t_lc.n_het, homs=t_lc.homs, n_homs=t_lc.n_hom).export(‘gs://cncd_analysts/outputs/APOC3_lc.tsv’)

I have used folowing command but its giving me this error;

ExpressionException: Cannot combine expressions from different source objects.
Found fields from 1 objects:
<hail.table.Table object at 0x7f70b53fbb38>: [‘vep’]

Sorry, I mis-wrote the above. When you run key_by() you create a new table and you are not allowed to reference fields from the old table. In particular t_lc.vep refers to a field of t_lc not a field of t_lc.key_by(). Try this:

t_lc = t_lc.key_by()
t_lc.select(
    gene=t_lc.vep.transcript_consequences[0].gene_symbol,
    lof=t_lc.vep.transcript_consequences[0].lof,
    hets=t_lc.hets,
    n_hets=t_lc.n_het,
    homs=t_lc.homs,
    n_homs=t_lc.n_hom
).export(‘gs://cncd_analysts/outputs/APOC3_lc.tsv’)
1 Like