applyMethod {SeqVarTools} | R Documentation

## Apply method to GDS object

### Description

Apply a method to a subset of variants and/or samples in a GDS object

### Usage

    ## S4 method for signature 'SeqVarGDSClass,function,character'
    applyMethod(gdsobj, FUN, variant, sample=NULL, ...)
    ## S4 method for signature 'SeqVarGDSClass,function,numeric'
    applyMethod(gdsobj, FUN, variant, sample=NULL, ...)
    ## S4 method for signature 'SeqVarGDSClass,function,GRanges'
    applyMethod(gdsobj, FUN, variant, sample=NULL, ...)
    ## S4 method for signature 'SeqVarGDSClass,function,missing'
    applyMethod(gdsobj, FUN, variant, sample=NULL, ...)

### Arguments

`gdsobj` | A `SeqVarGDSClass` object with VCF data.
`FUN` | A method or function to be applied to `gdsobj`.
`variant` | A vector of variant.id values or a `GRanges` object defining the variants to be included in the call to `FUN`.
`sample` | A vector of sample.id values defining the samples to be included in the call to `FUN`.
`...` | Additional arguments, passed to `FUN`.

### Details

`applyMethod` applies a method or function `FUN` to the subset of variants defined by `variant` and samples defined by `sample` in a GDS object.

If a filter was previously set with `seqSetFilter`, it will be saved and reset after the call to `applyMethod`.

### Value

The result of the call to `FUN`.

### Author(s)

Stephanie Gogarten

### See Also

`SeqVarGDSClass`

### Examples

    gds <- seqOpen(seqExampleFileName("gds"))
    variant.id <- seqGetData(gds, "variant.id")
    sample.id <- seqGetData(gds, "sample.id")
    applyMethod(gds, getGenotype, variant.id[1:5], sample.id[1:10])

    library(GenomicRanges)
    chrom <- seqGetData(gds, "chromosome")
    pos22 <- seqGetData(gds, "position")[chrom == 22]
    ranges <- GRanges(seqnames="22", IRanges(min(pos22), max(pos22)))
    applyMethod(gds, heterozygosity, ranges, margin="by.sample")
    applyMethod(gds, heterozygosity, ranges, margin="by.variant")

    seqClose(gds)

[Package SeqVarTools version 1.26.0 Index]