# Outer Joining Multiple VCFs

**URL:** <https://discuss.hail.is/t/outer-joining-multiple-vcfs/1350>\
**Category:** Hail Query & hailctl\
**Created:** [March 23, 2020, 1:57pm UTC](https://discuss.hail.is/t/outer-joining-multiple-vcfs/1350 "2020-03-23T13:57:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maryam\_Zekavat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/maryam_zekavat/32/377_2.png) [@Maryam\_Zekavat](https://discuss.hail.is/u/Maryam_Zekavat)\
**Post date:** [March 23, 2020, 1:57pm UTC](https://discuss.hail.is/t/outer-joining-multiple-vcfs/1350/1 "2020-03-23T13:57:07Z")

</div>

Hello!  
I wanted to see if there’s a simple way to outer join multiple VCFs in Hail. I have ~50,000 VCFs each of which has somatic calls from 1 individual, and basically my goal is to perform QC on each VCF (ex: removing non-PASS variants and low-qual genotypes), then join all the 50,000 VCFs into 1 hail .mt (I don’t need any entry-level info on each variant except for GT and VAF, VEP-annotate that .mt, and export\_entries on for downstream analysis.

Would be fantastic if there was a way to do this all within hail.  
Hope to hear from you soon!  
Thanks,  
Maryam

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [April 3, 2020, 8:46pm UTC](https://discuss.hail.is/t/outer-joining-multiple-vcfs/1350/2 "2020-04-03T20:46:06Z")

</div>

The solution here will involve a hierarchical merge using `union_cols(..., row_join_type='outer')`

---

<div class="post-metadata">

**Author:** ![konradjk](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/konradjk/32/12_2.png) [@konradjk](https://discuss.hail.is/u/konradjk)\
**Post date:** [April 3, 2020, 8:58pm UTC](https://discuss.hail.is/t/outer-joining-multiple-vcfs/1350/3 "2020-04-03T20:58:17Z")

</div>

I’ve written a function to do the basics here (it was designed for non-genotype data, but hopefully it should be generic enough): [https://github.com/Nealelab/ukb\_common/blob/master/utils/results\_loading.py#L105](https://github.com/Nealelab/ukb_common/blob/master/utils/results_loading.py#L105)
