Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficiently perform simple merge/append on many VCFs? #9097

Open
bbimber opened this issue Feb 18, 2025 · 4 comments
Open

Efficiently perform simple merge/append on many VCFs? #9097

bbimber opened this issue Feb 18, 2025 · 4 comments

Comments

@bbimber
Copy link
Contributor

bbimber commented Feb 18, 2025

Hello,

This isnt exactly a GATK question, but I think this problem would be faced by many GATK users. Our current practice is to run many GATK-based jobs scatter/gathered, meaning 100s or 1000s of individual jobs where each operates against a set of coordinates. The result is N number of VCFs that we need to append to one another and bgzip to make a final VCF. This process is painfully slow when dealing with many jobs and large VCFs. Are there simple linux tricks to make this faster?

Our current pattern is something like this:

#!/bin/bash

# first write the VCF header to a file by itself named header.vcf

# Then zcat them in a block, piped to bgzip:
{
cat header.vcf
zcat vcf1.vcf.gz | grep -v '^#';
zcat vcf2.vcf.gz | grep -v '^#';
zcat vcf3.vcf.gz | grep -v '^#';
zcat vcf4.vcf.gz | grep -v '^#';
etc....
} | bgzip -f --threads XX > finalVcf.vcf.gz

I hope this slightly off topic question is alright here. I appreciate any suggestions people might have.

@gokalpcelik
Copy link
Contributor

gokalpcelik commented Feb 18, 2025

Why don't you use bcftools or gatk GatherVcfs?

In your case bcftools would be the best. Just provide all the parameters and pass the list of files with wildcards or regexes.

@bbimber
Copy link
Contributor Author

bbimber commented Feb 18, 2025

There is nothing VCF-specific to this, so frankly avoiding any parsing whatsoever (which is why GATK is honestly often not the right direction). Fair point on bcftools - i will compare them.

The point of this question is about speed and low overhead.

@cmnbroad
Copy link
Collaborator

I believe both GatherVcfs (picard) and GatherVcfsCloud (gatk) try to avoid doing any parsing at all if the shards are already block-gzipped - I believe they just transfer the blocks directly. So at least for that case they might be fine.

@bbimber
Copy link
Contributor Author

bbimber commented Feb 18, 2025

Interesting - i will check that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants