Skip to contents

Creates a VCF object from GWAS summary statistics or fine-mapping results and writes it to disk. Supports bgzipped VCF (.vcf.gz/.vcf.bgz) and BCF (.bcf) output formats via VariantAnnotation and Rsamtools.

Usage

writeSumstatsVcf(x, outputPath, sampleName = NULL, ...)

# S4 method for class 'GwasSumStats'
writeSumstatsVcf(x, outputPath, sampleName = NULL, study = NULL, ...)

# S4 method for class 'FineMappingResultBase'
writeSumstatsVcf(
  x,
  outputPath,
  sampleName = NULL,
  study = NULL,
  context = NULL,
  trait = NULL,
  method = NULL,
  splitByContext = FALSE,
  splitByTrait = FALSE,
  ...
)

Arguments

x

Input data: a GwasSumStats object, a FineMappingResult object, or a data.frame with columns chrom, pos, ref, alt.

outputPath

File path for output. Extension determines format: .vcf.gz or .vcf.bgz for bgzipped VCF, .bcf for BCF, .vcf for uncompressed VCF.

sampleName

Name for the VCF sample column (default: trait name or method name from the S4 object).

...

Additional arguments passed to methods.

study

Character or NULL. Restrict the written records to this study; NULL includes all studies.

context

Character or NULL. Restrict the written records to this context; NULL includes all contexts.

trait

Character or NULL. Restrict the written records to this trait; NULL includes all traits.

method

Character or NULL. Restrict the written records to this method; NULL includes all methods.

splitByContext

Logical. If TRUE, write one VCF per context. Default FALSE.

splitByTrait

Logical. If TRUE, write one VCF per trait. Default FALSE.

Value

Invisible path to the written file.

Examples

data(gwasSumStatsS4Example)
writeSumstatsVcf(
  gwasSumStatsS4Example, outputPath = tempfile(fileext = ".vcf"))