gap_snps: Filter down to one SNPs every _n_ bases.

View source: R/utility_functions.R

gap_snpsR Documentation

Filter down to one SNPs every n bases.

Description

Selects one SNPs every n bases. This can be used to filter for SNPs in tight LD, such as when only one SNP per RAD-tag is desired.

Usage

gap_snps(x, facet = NULL, n)

Arguments

x

snpRdata object

facet

character, default NULL. SNP facet specifying chromosomes or scaffolds. SNP positions will be independently considered depending on the facet level.

n

Integer. Specifies the minimum distance between selected SNPs.

Details

Note that this approach takes the first SNP every n bases, and so is non-random. filter_snps can be used beforehand to ensure that the selected SNPs are above a desired quality threshold to ensure that poor SNPs are not selected over loci with more robust genotyping data.

It is strongly recommended to provide a SNP facet to the facet argument. This will define "chromosomes" for the purpose of selecting SNPs. If not set, snpR will assume that all SNPs are on the same chromosome, which may produce undesired results.

Value

A snpRdata object containing the selected SNPs.

Author(s)

William Hemstrom

Examples

# put large gaps inbetween the example data
gapped <- gap_snps(stickSNPs, "chr", 100000)

# filter first to grab only very good SNPs
vgood <- filter_snps(stickSNPs, min_ind = .8)
gapped <- gap_snps(vgood, "chr", 100000)

hemstrow/snpR documentation built on March 20, 2024, 7:03 a.m.