Learn R Programming

CrypticIBDcheck (version 0.3-3)

new.IBD: Create a data structure suitable for input to IBDcheck

Description

Create a data structure suitable for input to IBDcheck. This is a wrapper function for the constructor function IBD that creates the object. The wrapper provides basic checks of the input and creates the snp.support and subject.support data frames required for an IBD object.

Usage

new.IBD(snp.data, Chromosome, Position, popsam, Gen_loc=NULL, 
        pvalue_HWE=NULL, subids=NULL, ...)

Arguments

snp.data

A snp.matrix object containing the genotypes. Rows correspond to subjects and columns correspond to SNPs.

Chromosome

a vector containing the chromosome numbers of the SNPs

Position

a vector of physical map positions

popsam

A logical vector indicating whether each subject can be considered part of a random sample (TRUE) or not (FALSE). See Details for more information. Only those subjects for which popsam==TRUE are used for estimating conditional IBS probabilities and fitting LD models.

Gen_loc

A vector of genetic map positions in centiMorgans. If NULL (the default), they will be inferred using the function SNPgenmap.

pvalue_HWE

A vector of p-values from tests of Hardy-Weinberg proportions for each SNP. If NULL (the default), they will be filled in using all population sample subjects (popsam==TRUE) in snp.data.

subids

a vector of subject IDs

...

additional arguments to be passed to the constructor IBD

Value

An object of class IBD. See the help file for the constructor function IBD for details.

Details

The arguments snp.data, Chromosome, Position and popsam are required. Only subjects with popsam==TRUE are used for estimating conditional IBS probabilities and fitting LD models; those with popsam==FALSE are excluded. A typical use of popsam is to exclude cases when the data are from case control study of a rare disease, where cases are oversampled relative to their frequency in the population but controls may be regarded as a population sample.

If Gen_loc is missing it is inferred from Position by the SNPgenmap function. Currently SNPgenmap assumes physical map positions are on build 36 of the human genome. If subids is missing, the row names of snp.data are used as subject identifiers.

See Also

IBDcheck

Examples

Run this code
# NOT RUN {
data(Nhlsim)
popsam<-Nhlsim$csct==0 #controls
dat<-new.IBD(Nhlsim$snp.data,Nhlsim$chromosome,Nhlsim$physmap,popsam)

# }
# NOT RUN {
# Read PLINK-formatted data via the read.snps.pedfile() function of the 
# chopsticks package 
# [source("http://bioconductor.org/biocLite.R"); biocLite("chopsticks") to install]
# Assume PLINK data is in files mydata.ped and mydata.map.
require(chopsticks)
mydata = read.snps.pedfile("mydata.ped")
# mydata is now a list with elements mydata$snp.data, mydata$snp.support and 
# mydata$subject.support. Chromosome number and physical position of the SNPs 
# are in mydata$snp.support$chromosome and mydata$snp.support$position, respectively.
dat<-new.IBD(mydata$snp.data,mydata$snp.support$chromosome,
             mydata$snp.support$position,popsam=rep(1,nrow(mydata$snp.support)))
# }

Run the code above in your browser using DataLab