Skip to contents

Type the name of the class to see the details and methods

Value

A C++ class with the following fields/methods for manipulating the VCF/BCF

Fields

new

Constructor given a vcf file

  • Parameter: vcffile - The path of a vcf file

new

Constructor given a vcf file and the region

  • Parameter: vcffile - The path of a vcf file

  • Parameter: region - The region to be constrained

new

Constructor given a vcf file, the region and the samples

  • Parameter: vcffile - The path of a vcf file

  • Parameter: region - The region to be constrained

  • Parameter: samples - The samples to be constrained. Comma separated list of samples to include (or exclude with "^" prefix).

setRegion

try to set specific region to work with. will throw errors if no index or region found. Use getStatus to check if the region is valid or empty!

getStatus

return 1: region is valid and not empty. 0: region is valid but empty. -1: no index file. -2: region not found or invalid region form

variant

Try to get next variant record. return FALSE if there are no more variants or hit the end of file, otherwise TRUE.

chr

Return the CHROM field of current variant

pos

Return the POS field of current variant

id

Return the CHROM field of current variant

ref

Return the REF field of current variant

alt

Return the ALT field of current variant

qual

Return the QUAL field of current variant

filter

Return the FILTER field of current variant

info

Return the INFO field of current variant

infoInt

Return the tag value of integer type in INFO field of current variant

  • Parameter: tag - The tag name to retrieve in INFO

infoFloat

Return the tag value of float type in INFO field of current variant

  • Parameter: tag - The tag name to retrieve in INFO

infoStr

Return the tag value of string type in INFO field of current variant

  • Parameter: tag - The tag name to retrieve in INFO

infoIntVec

Return the tag value in a vector of integer type in INFO field of current variant

  • Parameter: tag - The tag name to retrieve in INFO

infoFloatVec

Return the tag value in a vector of float type in INFO field of current variant

  • Parameter: tag - The tag name to retrieve in INFO

genotypes

Return the genotype values in a vector of integers

  • Parameter: collapse - Boolean value indicates wheather to collapse the size of genotypes, eg, return diploid genotypes.

formatInt

Return the tag value of integer type for each sample in FORAMT field of current variant

  • Parameter: tag - The tag name to retrieve in FORAMT

formatFloat

Return the tag value of float type for each sample in FORAMT field of current variant

  • Parameter: tag - The tag name to retrieve in FORAMT

formatStr

Return the tag value of string type for each sample in FORAMT field of current variant

  • Parameter: tag - The tag name to retrieve in FORAMT

isSNP

Test if current variant is exculsively a SNP or not

isIndel

Test if current variant is exculsively a INDEL or not

isSV

Test if current variant is exculsively a SV or not

isMultiAllelics

Test if current variant is exculsively a Multi Allelics or not

isMultiAllelicSNP

Test if current variant is exculsively a Multi Biallelics (SNPs) or not

hasSNP

Test if current variant has a SNP or not

hasINDEL

Test if current variant has a INDEL or not

hasINS

Test if current variant has a INS or not

hasDEL

Test if current variant has a DEL or not

hasMNP

Test if current variant has a MNP or not

hasBND

Test if current variant has a BND or not

hasOTHER

Test if current variant has a OTHER or not

hasOVERLAP

Test if current variant has a OVERLAP or not

nsamples

Return the number of samples

samples

Return a vector of samples id

header

Return the raw string of the vcf header

string

Return the raw string of current variant including newline

line

Return the raw string of current variant without newline

output

Init an output object for streaming out the variants to another vcf

updateSamples

update samples name in the output VCF

  • Parameter: s - A comma-seperated string for new samples names

write

Streaming out current variant the output vcf

close

Close the connection to the output vcf

setCHR

Modify the CHR of current variant

  • Parameter: s - A string for CHR

setID

Modify the ID of current variant

  • Parameter: s - A string for ID

setPOS

Modify the POS of current variant

  • Parameter: pos - An integer for POS

setRefAlt

Modify the REF and ALT of current variant

  • Parameter: s - A string reperated by comma

setInfoInt

Modify the given tag of INT type in the INFO of current variant

  • Parameter: tag - A string for the tag name

  • Parameter: v - An integer for the tag value

setInfoFloat

Modify the given tag of FLOAT type in the INFO of current variant

  • Parameter: tag - A string for the tag name

  • Parameter: v - A double for the tag value

setInfoStr

Modify the given tag of STRING type in the INFO of current variant

  • Parameter: tag - A string for the tag name

  • Parameter: s - A string for the tag value

setPhasing

Modify the phasing status of each sample

  • Parameter: v - An integer vector with size of the number of samples. only 1s and 0s are valid.

setGenotypes

Modify the genotypes of current variant

  • Parameter: v - An integer vector for genotypes. Use NA or -9 for missing value.

setFormatInt

Modify the given tag of INT type in the FORMAT of current variant

  • Parameter: tag - A string for the tag name

  • Parameter: v - An integer for the tag value

setFormatFloat

Modify the given tag of FLOAT type in the FORMAT of current variant

  • Parameter: tag - A string for the tag name

  • Parameter: v - A double for the tag value

setFormatStr

Modify the given tag of STRING type in the FORMAT of current variant

  • Parameter: tag - A string for the tag name

  • Parameter: s - A string for the tag value

rmInfoTag

Remove the given tag from the INFO of current variant

  • Parameter: s - A string for the tag name

rmFormatTag

Remove the given tag from the FORMAT of current variant

  • Parameter: s - A string for the tag name

setVariant

Modify current variant by adding a vcf line

  • Parameter: s - A string for one line in the VCF

addINFO

Add a INFO in the header of the vcf

  • Parameter: id - A string for the tag name

  • Parameter: number - A string for the number

  • Parameter: type - A string for the type

  • Parameter: desc - A string for description of what it means

addFORMAT

Add a FORMAT in the header of the vcf

  • Parameter: id - A string for the tag name

  • Parameter: number - A string for the number

  • Parameter: type - A string for the type

  • Parameter: desc - A string for description of what it means

Examples

vcffile <- system.file("extdata", "raw.gt.vcf.gz", package="vcfppR")
br <- vcfreader$new(vcffile)
res <- rep(0L, br$nsamples())
while(br$variant()) {
  if(br$isSNP()) {
  gt <- br$genotypes(TRUE) == 1
  gt[is.na(gt)] <- FALSE
  res <- res + gt
  }
}