Learn R Programming

WhopGenome (version 0.9.4)

vcf_addfilter: Add a condition for SNP filtering from VCF files.

Description

Add a condition for filtering SNPs based on any column in a given VCF file.

Usage

vcf_addfilter(vcf, columnnam, fieldnam, cmptype, cmpvalue1, cmpvalue2 = 0, action)

Arguments

vcf
VCF file handle
columnnam
name of column containing the to-be-checked values
fieldnam
name of the subfield or "" to check
cmptype
Type of comparison to perform. See Details
cmpvalue1
Comparison reference value 1 or lower bound
cmpvalue2
Comparison reference value 2 or upper bound
action
Action to take if comparison matches : NOP, SKIP, KEEP or fails: SKIP_NOT, KEEP_NOT

Value

Success status: TRUE on success, FALSE if the rule could not be added.

Details

Parameter 'columnnam': Name of a VCF column, in which the data of interest is stored Parameter 'fieldnam': For the INFO and samples columns, the key under which the interesting data is stored. Example: vcf_addfilter( vcffile , "INFO", "H2", "DOES_EXIST", 0, 0, "DROP_NOT" ) would cause any subsequent calls to read functions that perform filtering to drop lines that do not have the "H2" key in the INFO column, which indicates that the SNP is not marked as being registered in HapMap2. The parameters and are not used by the "DOES_EXIST" operation.

Comparison types:

  • DOES_EXIST Rule matches, if in column named by is a key with the same name as in

for integer values:

  • INT_CMP is value = ref1 ?
  • INT_CMP_OO is value in open range (ref1, ref2)
  • INT_CMP_OC is value in half-closed range (ref1, ref2]
  • INT_CMP_CO is value in half-closed range [ref1, ref2)
  • INT_CMP_CC is value in closed range [ref1, ref2]

for floating point values:

  • FLT_CMP is value = ref1 ?
  • FLT_CMP_OO is value in open range (ref1, ref2)
  • FLT_CMP_OC is value in half-closed range (ref1, ref2]
  • FLT_CMP_CO is value in half-closed range [ref1, ref2)
  • FLT_CMP_CC is value in closed range [ref1, ref2]

Examples

Run this code
	##
	##	Example:
	##
	vcffile <- vcf_open( system.file( "extdata" , "ex.vcf.gz" , package="WhopGenome" ) )
	vcf_setregion(vcffile, "Y", 1, 100000 )
	vcf_addfilter( vcffile, "POS", "", "INT_CMP_OO",
					as.integer(49005), as.integer(49007), "DROP" )
	vcf_describefilters( vcffile )
	####
	####
	vcf_readLineVecFiltered( vcffile )
	vcf_readLineVecFiltered( vcffile )
	vcf_readLineVecFiltered( vcffile )
	#######
	#######
	vcf_clearfilters( vcffile )
	vcf_describefilters( vcffile )
	vcf_restartregion( vcffile )
	####
	####
	vcf_readLineVecFiltered( vcffile )
	vcf_readLineVecFiltered( vcffile )
	vcf_readLineVecFiltered( vcffile )
	##
	##
	vcf_close( vcffile )

Run the code above in your browser using DataLab