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的父级,您正在寻找遵循特定继承模式的变体。
人们如何使用嵌套模式编写这些查询?
答案 0 :(得分:1)
我认为这将类似于以下内容-由于表非常昂贵,尚未经过测试-但一次运行给出的输出为零,这意味着没有满足该特定条件的记录-但至少您会看到这样做的逻辑这样的查询
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