align.alleles: align.alleles

View source: R/snp-match.R

align.allelesR Documentation

align.alleles

Description

switch alleles in x to match order in y

Usage

align.alleles(x, y, do.plot = TRUE, mafdiff = 0.1, known.dups = NULL,
  return.sw = FALSE)

Arguments

x

annotSnpStats object

y

annotSnpStats object

do.plot

if TRUE (default), generate a summary plot that can be a useful visual check nothing has gone wrong. The points should lie close to the line of equality.

mafdiff

SNPs with MAF within mafdiff of 0.5 will not be aligned automatically. This is of concern only for T/A and C/G SNPs, which are not uniquely resolveable by allele codes.

known.dups

if duplicate samples exist, supply a list returned by running dups(x,y). The alignment of genotypes in these duplicate samples will be used to inform alignment of genotypes in other samples.

return.sw

if TRUE, don't do the switch, just return index of switches. NA means indeterminable, data should be set to missing.

Value

new annotSnpStats object derived from x, with alleles switched to match those in y

Author(s)

Chris Wallace

Examples

x <- example.data(1:100,1:10)
y <- example.data(101:200,1:10)
## switch columns 6:10
y.switched <- switch.alleles(y,6:10)
## automatically switch back
y.aligned <- align.alleles(y.switched,x,do.plot=TRUE)
## check by comparing counted allele frequencies for SNPs 1:5 and 6:10
cbind(x=col.summary(x)[,"RAF"],
      y=col.summary(y)[,"RAF"], 
      y.switched=col.summary(y.switched)[,"RAF"],
      y.aligned=col.summary(y.aligned)[,"RAF"])

chr1swallace/annotSnpStats documentation built on April 18, 2023, 11:22 a.m.