Last data update: 2014.03.03

R: Create genotype counts from bi-allelic marker data
MakeCountsR Documentation

Create genotype counts from bi-allelic marker data

Description

MakeCounts creates a matrix of genotype counts, with one row for each bi-allelic marker, containing 4 columns with the counts AA, AB, BB and NA (missings) respectively

Usage

MakeCounts(X, alleles, pos1 = 1, pos2 = 3, coding = c(AA=0,AB=1,BB=2))

Arguments

X

A matrix or dataframe with bi-allelic genotyping information, markers in columns, individuals in rows

alleles

a vector of alleles for each marker (e.g. c("A/T","A/G",...)). Only relevanit if X is a matrix with text entries.

pos1

position of the first allele in the allele string (1 by default)

pos2

position of the second allele in the allele string (3 by default)

coding

indicates how homozygotes and heterozygote are coded as numbers. Only relevant if X is a matrix with numeric entries.

Details

MakeCounts is thought for bi-allelic marker data only. Missings are should be coded by NA. It produces the right input for HWTernaryPlot.

Heterozygotes may be coded in the data as "AB" or "BA". Both entries will be counted as a heterozygote.

Value

A matrix of 4 columns

Author(s)

Jan Graffelman jan.graffelman@upc.edu

See Also

HWTernaryPlot

Examples

SNP1 <- c("GG","GG","GG","GG","GG","GG","GG","GG","GG")
SNP2 <- c("CG","GG","CC","GG","GG","CG","CG","CG","CG")
SNP3 <- c("AA","AA","AA","AG","AA","AG","AA","AA","AA")
SNP4 <- c("GG","GG","GG","GG","GG","GG","GG","GG","GG")
SNP5 <- c("CC","CC","CC","CC","CC","CC","CT","CT","CT")
X <- cbind(SNP1,SNP2,SNP3,SNP4,SNP5)
Y <- MakeCounts(X,c("A/G","C/G","A/G","A/G","C/T"))
print(Y)
W <- matrix(sample(c(0,1,2,NA),100,replace=TRUE),ncol=5)
Z <- MakeCounts(W,coding=c(0,1,2))

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(HardyWeinberg)
Loading required package: mice
Loading required package: Rcpp
mice 2.25 2015-11-09
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/HardyWeinberg/MakeCounts.Rd_%03d_medium.png", width=480, height=480)
> ### Name: MakeCounts
> ### Title: Create genotype counts from bi-allelic marker data
> ### Aliases: MakeCounts
> ### Keywords: misc
> 
> ### ** Examples
> 
> SNP1 <- c("GG","GG","GG","GG","GG","GG","GG","GG","GG")
> SNP2 <- c("CG","GG","CC","GG","GG","CG","CG","CG","CG")
> SNP3 <- c("AA","AA","AA","AG","AA","AG","AA","AA","AA")
> SNP4 <- c("GG","GG","GG","GG","GG","GG","GG","GG","GG")
> SNP5 <- c("CC","CC","CC","CC","CC","CC","CT","CT","CT")
> X <- cbind(SNP1,SNP2,SNP3,SNP4,SNP5)
> Y <- MakeCounts(X,c("A/G","C/G","A/G","A/G","C/T"))
> print(Y)
     AA AB BB NA
[1,]  0  0  9  0
[2,]  1  5  3  0
[3,]  7  2  0  0
[4,]  0  0  9  0
[5,]  6  3  0  0
> W <- matrix(sample(c(0,1,2,NA),100,replace=TRUE),ncol=5)
> Z <- MakeCounts(W,coding=c(0,1,2))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>