4
$\begingroup$

I’m currently using QCTOOL v2 to process imputed .bgen files from UK Biobank, however they seem to be processing very slowly. Is this normal?

My command is pretty basic; I’m filtering out a list of SNPs and samples:

/path_to/qctool \
-g /path_to/ukbXXXX_c22_b0_v3.bgen \
-s /path_to/ukbXXXX_c22_b0_v3.sample \
-og /output_path/ukb_c22_filt.bgen \
-os /output_path/ukb_c22_filt.sample \
-excl-rsids /path_to/snps_rem_c22.txt \
-excl-samples /path_to/samples_to_rem.txt

It is currently processing SNPs at a rate of 1.2/s (e.g. 71169/?,57205.8s,1.2/s).

The computational facility I'm using should not limit the speed of an operation.

  • Have I made any mistakes in my qctool query?
  • Or any other ideas on why it's running so slowly?

Alternative suggestions on how to process these files would be appreciated for example, although I would prefer to use QCTOOL perhaps I have to use PLINK.


From the website, https://www.well.ox.ac.uk/~gav/qctool_v2/

"QCTOOL is a command-line utility program for manipulation and quality control of gwas datasets and other genome-wide data"

$\endgroup$
4
  • $\begingroup$ Hi @Cat could you provide information on computer(s) you are using, e.g. are you using a desktop, laptop or the cloud? What's the RAM of the machine, how full is the hard drive and how big are the files, that sort of thing. $\endgroup$
    – M__
    Apr 16, 2022 at 10:38
  • $\begingroup$ crossposted biostars.org/p/9519364 $\endgroup$
    – user438383
    Apr 16, 2022 at 19:14
  • $\begingroup$ Also whether the files (either input files or output files) are on a local or network drive, that can make a huge difference to the speed. $\endgroup$
    – terdon
    Apr 18, 2022 at 12:55
  • $\begingroup$ bgen/qctool2 is just pretty slow in general I've found. For performance, convert to pgen format and use plink2, seems to be orders of magnitude faster as long as you have enough RAM to hold the files in memory, $\endgroup$
    – user438383
    Nov 4, 2022 at 13:53

1 Answer 1

1
$\begingroup$

I contacted the QCTOOL team directly and received this response:

The design of BGEN means that when you subset samples the data has to be recompressed - this is essentially what makes this slow. (By contrast you can subset SNPs very quickly without recompression using bgenix https://code.enkre.net/bgen.) It is therefore definitely worth considering not subsetting samples but using a sample inclusion/exclusion list instead, if your analysis software supports that.

If you have to subset and want to use QCTOOL - some things to try are: I typically use the options -bgen-compression zstd -bgen-bits 8 now, c.f. https://doi.org/10.1101/308296 this is faster but first check your downstream software supports zstd compression. Use a map/reduce type pipeline (i.e. chunk data for re-encoding) - this can be implemented using bgenix and cat-bgen.

I assume you’re working with the latest version?

Have you tried first stripping the SNPs, then stripping the samples?

Ever since working with the imputed data from the UKB I was never successful in chopping pieces of bgen files using qctool in a timely manner. If my memory serves me well, qctool manages to strip SNPs fairly quickly, but is super slow to remove samples. Try PLINK 1.9 or 2.0.

As for “The computational facility I'm using should not limit the speed of an operation.”, depending on how disk data moves in/out of slave nodes and how busy the cluster is, I did saw processes to become I/O starved on large clusters.

Also, consider that most tools that perform association testing can utilize SNPs and samples lists. BOLT, SAIGE, regenie, SNPtest… so there might not be a need to pre-filter. Put “NA” as phenotypes you’d like to be “removed” from the testing.

In the end I did not pre-filter SNPs or samples - I set samples to NA within the phenotype file, and used a SNP inclusion list in the second stage of SAIGE with the flag idstoIncludeFile.

$\endgroup$
1
  • $\begingroup$ When subsetting SNPs (and keeping all samples), I find bgenix to be about 100x faster than qctool. $\endgroup$ Jan 15, 2023 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.