本页介绍如何使用 BigQuery 分析变体。变体是已被确认为与参考基因组不同的基因组区域。
下面的例子说明了如何计算每个样品的每条染色体单核苷酸多态性 (SNP) 中转换到颠换的比率。
分析来自 Illumina Platinum Genomes 数据集的变体
以下示例使用来自 Illumina Platinum Genomes 项目的数据。数据位于 BigQuery 的 platinum_genomes_deepvariant_variants_20180823
表中。
如需分析表中的变体,请完成以下步骤:
在 Google Cloud 控制台中转到 BigQuery 页面。
点击编写查询。
将下述查询复制粘贴到新查询文本区域中:
#standardSQL -- -- Compute the transition/transversion ratio per sample and reference name. -- WITH filtered_snp_calls AS ( SELECT reference_name, c.name, CONCAT(reference_bases, '->', alternate_bases[ORDINAL(1)].alt) AS mutation FROM `bigquery-public-data.human_genome_variants.platinum_genomes_deepvariant_variants_20180823` AS v, UNNEST(v.call) AS c WHERE # Only include biallelic SNPs. reference_bases IN ('A','C','G','T') AND alternate_bases[ORDINAL(1)].alt IN ('A','C','G','T') AND (ARRAY_LENGTH(alternate_bases) = 1 OR (ARRAY_LENGTH(alternate_bases) = 2 AND alternate_bases[ORDINAL(2)].alt = '<*>')) # Skip homozygous reference calls and no-calls. AND EXISTS (SELECT g FROM UNNEST(c.genotype) AS g WHERE g > 0) AND NOT EXISTS (SELECT g FROM UNNEST(c.genotype) AS g WHERE g < 0) # Include only high quality calls. AND NOT EXISTS (SELECT ft FROM UNNEST(c.filter) ft WHERE ft NOT IN ('PASS', '.')) ), mutation_type_counts AS ( SELECT reference_name, name, SUM(CAST(mutation IN ('A->G', 'G->A', 'C->T', 'T->C') AS INT64)) AS transitions, SUM(CAST(mutation IN ('A->C', 'C->A', 'G->T', 'T->G', 'A->T', 'T->A', 'C->G', 'G->C') AS INT64)) AS transversions FROM filtered_snp_calls GROUP BY reference_name, name ) SELECT reference_name, name, transitions, transversions, transitions/transversions AS titv FROM mutation_type_counts WHERE transversions > 0 ORDER BY titv DESC, name
点击运行查询。查询会返回以下响应:
行 reference_name 名称 转换 颠换 titv 1 chr22 NA12892 35299 15017 2.3506026503296265 2 chr22 NA12889 34091 14624 2.331167943107221 3 chr17 NA12892 67297 28885 2.3298251687727194 4 chr22 NA12878 33627 14439 2.3289008934136715 5 chr22 NA12877 34751 14956 2.3235490772933938 6 chr22 NA12891 33534 14434 2.323264514341139 7 chr17 NA12877 70600 30404 2.3220628864623074 8 chr17 NA12878 66010 28475 2.3181738366988585 9 chr17 NA12890 67242 29057 2.314141170802216 10 chr17 NA12889 69767 30189 2.311007320547219 … … … … … …
titv
列显示了转换到颠换的比率。
后续步骤
- 如需了解如何使用 BigQuery 分析变体的更多示例,请参阅教程。
- 了解 BigQuery 变体表架构。
- 使用 R、RMarkdown 或 JavaScript 分析 BigQuery 中的变异。
- 了解如何使用 R 执行查询并使结果可视化。