vcf2df: VCF to DF

View source: R/vcf2df.R

vcf2dfR Documentation

VCF to DF

Description

Function to convert a VariantAnnotation CollapsedVCF/ExpandedVCF object to a data.frame.

Usage

vcf2df(
  vcf,
  add_sample_names = TRUE,
  add_rowranges = TRUE,
  drop_empty_cols = TRUE,
  unique_cols = TRUE,
  unique_rows = TRUE,
  unlist_cols = TRUE,
  sampled_rows = NULL,
  verbose = TRUE
)

Arguments

vcf

Variant Call Format (VCF) file imported into R as a VariantAnnotation CollapsedVCF/ ExpandedVCF object.

add_sample_names

Append sample names to column names (e.g. "EZ" –> "EZ_ubm-a-2929").

add_rowranges

Include rowRanges from VCF as well.

drop_empty_cols

Drop columns that are filled entirely with: NA, ".", or "".

unique_cols

Only keep uniquely named columns.

unique_rows

Only keep unique rows.

unlist_cols

If any columns are lists instead of vectors, unlist them. Required to be TRUE when unique_rows=TRUE.

sampled_rows

First N rows to sample. Set NULL to use full sumstats_file. when determining whether cols are empty.

verbose

Print messages.

Value

data.frame version of VCF

Source

Original code source

vcfR

if(!require("pinfsc50")) install.packages("pinfsc50") vcf_file <- system.file("extdata", "pinf_sc50.vcf.gz", package = "pinfsc50") vcf <- read.vcfR( vcf_file, verbose = FALSE ) vcf_df_list <- vcfR::vcfR2tidy(vcf, single_frame=TRUE) vcf_df <- data.table::data.table(vcf_df_list$dat)

Examples

  
#### VariantAnnotation ####
# path <- "https://github.com/brentp/vcfanno/raw/master/example/exac.vcf.gz"
path <- system.file("extdata", "ALSvcf.vcf",
                    package = "MungeSumstats")
                    
vcf <- VariantAnnotation::readVcf(file = path)
vcf_df <- MungeSumstats:::vcf2df(vcf = vcf)

neurogenomics/MungeSumstats documentation built on Aug. 10, 2024, 5:59 a.m.