Writes GWAS summary statistics, fine-mapping results or TWAS weights to a
GWAS-VCF-style file via VariantAnnotation and Rsamtools: one record per
variant, one SAMPLE per study / fitted model, and the per-variant statistics
as FORMAT fields. Supports bgzipped VCF (.vcf.gz/.vcf.bgz); BCF (.bcf)
additionally needs a working Rsamtools::asBcf(), which recent
Rsamtools releases disable, so prefer .vcf.bgz.
Usage
exportToVcf(x, outputPath, sampleName = NULL, ...)
# S4 method for class 'list'
exportToVcf(x, outputPath, sampleName = NULL, ...)
# S4 method for class 'GwasSumStats'
exportToVcf(x, outputPath, sampleName = NULL, studyName = NULL)
# S4 method for class 'FineMappingResultBase'
exportToVcf(
x,
outputPath,
sampleName = NULL,
studyName = NULL,
context = NULL,
trait = NULL,
method = NULL,
splitByContext = FALSE,
splitByTrait = FALSE
)
# S4 method for class 'TwasWeights'
exportToVcf(
x,
outputPath,
sampleName = NULL,
studyName = NULL,
context = NULL,
trait = NULL,
method = NULL
)Arguments
- x
A
GwasSumStats,QtlFineMappingResult,GwasFineMappingResultorTwasWeightsobject, or alistof fine-mapping results or ofTwasWeightsobjects to combine first.- outputPath
File path for output. Extension determines format:
.vcf.gzor.vcf.bgzfor bgzipped VCF,.bcffor BCF,.vcffor uncompressed VCF.- sampleName
Name(s) for the VCF sample column(s). Default
NULLderives them from the object's identity tuple.- ...
Additional arguments passed to methods.
- studyName
Character or
NULL. Restrict the written records to this study;NULLincludes all studies.- context
Character or
NULL. Restrict the written records to this context;NULLincludes all contexts.- trait
Character or
NULL. Restrict the written records to this trait;NULLincludes all traits.- method
Character or
NULL. Restrict the written records to this method;NULLincludes all methods.- splitByContext
Logical. If
TRUE, write one VCF per context. DefaultFALSE.- splitByTrait
Logical. If
TRUE, write one VCF per trait. DefaultFALSE.
Details
Which FORMAT fields are written depends on the input:
GwasSumStatsES/SS/AFfor one study.- a fine-mapping result
the marginal fields (
ES,SE,LP,SS,AF) plus the posterior ones (PIP,LBF,LFSR, and aCS/PURpair per credible-set coverage present).TwasWeightsWGT, the prediction weight.
Every fit the selectors match becomes a SAMPLE of ONE file: the records are
the union of their variants, the FORMAT schema is the union of their fields,
and a fit that did not include a variant – or does not report a field –
leaves those cells empty. So two methods over a region, or a dozen weight
methods for one gene, are compared by reading one file rather than a dozen.
Each sample is described in its own ##SAMPLE header line, carrying
the fit's identity tuple and how many variants it contributed.
Cross-validation results are not exported – see exportToBed
for why – and an export requires the full-data fit.
splitByContext / splitByTrait opt out of that and write one
single-sample file per fit, at a path decorated with the axis value.