BGData (version 2.1.0)

as.BGData: Convert Other Objects to BGData Objects.

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

as.BGData(x, alternatePhenotypeFile = NULL, ...)

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

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

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

Arguments

x

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

alternatePhenotypeFile
...

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.

Value

A '>BGData object.

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.

See Also

readRAW() to convert text files to '>BGData objects.

Examples

Run this code
# NOT RUN {
# 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"))
# }

Run the code above in your browser using DataLab