loadExposome: Creation of an ExposomeSet from 'data.frames'

View source: R/loadExposome.R

loadExposomeR Documentation

Creation of an ExposomeSet from data.frames

Description

Given three data.frames that defines the exposome (measures of exposome, exposome description and individuals phentype) it loads them and creates an object of type ExposomeSet.

Usage

loadExposome(
  exposures,
  description,
  phenotype,
  description.famCol = "family",
  exposures.asFactor = 5,
  warnings = TRUE
)

Arguments

exposures

data.frame of exposures.

description

data.frame with the description of the exposures (relation between exposures and exposure-family).

phenotype

data.frame with the phenotypes of interest.

description.famCol

(default "family") Index where the family's name (per exposures) if found in file "description". It can be both numeric or character.

exposures.asFactor

(default 5) The exposures with more than this number of unique items will be considered as "continuous" while the exposures with less or equal number of items will be considered as "factor".

warnings

(default TRUE) If TRUE shows useful information/warnings from the process of loading the exposome.

Details

The rows of the exposure's data.frames, that corresponds to samples' names, must be the same than the phenotype's data.frames. In the same way, the columns in exposure's data.frames must be the same in description data.frame.

Value

An object of class ExposomeSet.

Note

ExposomeSet's fData will contain some inner columns called .std, .trn, .fct and .type in order to trace the transformations an exposure suffers and to know, at eny moment, if an exposure is categorical or continuous. The "description" file can contains a column called type with values "factor" and "numeric" to speficy how an exposure needs to be understood. If given, this column will be renamed to .type. If not given, it will be created using exposures.asFactor value.

See Also

ExposomeSet for class description, readExposome for constructor from txt/csv files.

Examples

path <- file.path(path.package("rexposome"), "extdata")
description <- file.path(path, "description.csv")
phenotype <- file.path(path, "phenotypes.csv")
exposures <- file.path(path, "exposures.csv")
dd <- read.csv(description, header=TRUE)
ee <- read.csv(exposures, header=TRUE)
pp <- read.csv(phenotype, header=TRUE)
rownames(dd) <- dd[, 2]
dd <- dd[ , -2]
rownames(ee) <- ee[ , 1]
ee <- ee[ , -1]
rownames(pp) <- pp[ , 1]
pp <- pp[ , -1]
exp <- loadExposome(
exposures = ee,
description = dd,
phenotype = pp,
description.famCol = "Family"
)

isglobal-brge/rexposome documentation built on Feb. 4, 2023, 12:35 p.m.