as.BGData: Convert Other Objects to BGData Objects.

Description Usage Arguments Details Value See Also Examples

View source: R/BGData.R

Description

Converts other objects to BGData objects by loading supplementary phenotypes and map files referenced by the object to be used for the @pheno and @map slot, respectively. Currently supported are BEDMatrix::BEDMatrix objects, plain or nested in LinkedMatrix::ColumnLinkedMatrix objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
as.BGData(x, alternatePhenotypeFile = NULL, ...)

## S3 method for class 'BEDMatrix'
as.BGData(x, alternatePhenotypeFile = NULL, ...)

## S3 method for class 'ColumnLinkedMatrix'
as.BGData(x, alternatePhenotypeFile = NULL,
  ...)

## S3 method for class 'RowLinkedMatrix'
as.BGData(x, alternatePhenotypeFile = NULL,
  ...)

Arguments

x

An object. Currently supported are BEDMatrix::BEDMatrix objects, plain or nested in LinkedMatrix::ColumnLinkedMatrix objects.

alternatePhenotypeFile

Path to an alternate phenotype file.

...

Additional arguments to the utils::read.table() or data.table::fread() call (if data.table package is installed) call to parse the alternate pheno file.

Details

The .ped and .raw formats only allows for a single phenotype. If more phenotypes are required it is possible to store them in an alternate phenotype file. The path to such a file can be provided with alternatePhenotypeFile and will be merged with the data in the @pheno slot. The first and second columns of that file must contain family and within-family IDs, respectively.

For BEDMatrix::BEDMatrix objects: If a .fam file (which corresponds to the first six columns of a .ped or .raw file) of the same name and in the same directory as the BED file exists, the @pheno slot will be populated with the data stored in that file. Otherwise a stub that only contains an IID column populated with the rownames of @geno will be generated. The same will happen for a .bim file for the @map slot.

For LinkedMatrix::ColumnLinkedMatrix objects: See the case for BEDMatrix::BEDMatrix objects, but only the .fam file of the first node of the LinkedMatrix::LinkedMatrix will be read and used for the @pheno slot, and the .bim files of all nodes will be combined and used for the @map slot.

Value

A BGData object.

See Also

readRAW() to convert text files to BGData objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Path to example data
path <- system.file("extdata", package = "BGData")

# Convert a single BEDMatrix object to a BGData object
chr1 <- BEDMatrix::BEDMatrix(paste0(path, "/chr1.bed"))
bg1 <- as.BGData(chr1)

# Convert multiple BEDMatrix objects in a ColumnLinkedMatrix to a BGData object
chr2 <- BEDMatrix::BEDMatrix(paste0(path, "/chr2.bed"))
chr3 <- BEDMatrix::BEDMatrix(paste0(path, "/chr3.bed"))
clm <- ColumnLinkedMatrix(chr1, chr2, chr3)
bg2 <- as.BGData(clm)

# Load additional (alternate) phenotypes
bg3 <- as.BGData(clm, alternatePhenotypeFile = paste0(path, "/pheno.txt"))

QuantGen/BGData documentation built on Nov. 16, 2018, 7:22 p.m.