如何在 BigQuery Variant Schema 中进行继承/传递查询

How to do inheritance / transmission queries in BigQuery Variant Schema

Google Genomics Variant Transform 管道使用的 Variant Schema 将基因型表示为 BigQuery 中的嵌套记录 - 例如:

(来自:https://bigquery.cloud.google.com/table/genomics-public-data:1000_genomes.variants?pli=1&tab=preview

我无法理解如何编写涉及样本之间关系的查询 - 例如:

select all variants where sampleA.genotype=HET and sampleB.genotype=HET and sampleC.genotype=HOM-ALT

或类似查询,其中 sampleA 和 sampleB 是 sampleC 的父级,并且您正在寻找遵循特定继承模式的变体。

人们如何使用嵌套模式编写这些查询?

我认为会像下面这样 - 没有测试,因为 table 相当昂贵 - 但一个 运行 给出零输出意味着没有满足该特定标准的记录 - 但是至少你看到了如何进行此类查询的逻辑

SELECT * EXCEPT(cnt)
FROM (
    SELECT reference_name,  start, `end`,
        (SELECT COUNT(1) 
            FROM UNNEST(call) 
            WHERE (call_set_name="HG00261" AND genotype[SAFE_OFFSET(0)] = 0 AND genotype[SAFE_OFFSET(1)] = 1)
            OR (call_set_name="HG00593" AND genotype[SAFE_OFFSET(0)] = 1 AND genotype[SAFE_OFFSET(1)] = 0)
            OR (call_set_name="NA12749 " AND genotype[SAFE_OFFSET(0)] = 1 AND genotype[SAFE_OFFSET(1)] = 1)
        ) cnt
    FROM `genomics-public-data.1000_genomes.variants` 
)
WHERE cnt = 3