readExposome: Creation of an ExposomeSet from files

View source: R/readExposome.R

readExposomeR Documentation

Creation of an ExposomeSet from files

Description

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

Usage

readExposome(
  exposures,
  description,
  phenotype,
  sep = ",",
  na.strings = c("NA", "-", "?", " ", ""),
  exposures.samCol = "sample",
  description.expCol = "exposure",
  description.famCol = "family",
  phenotype.samCol = "sample",
  exposures.asFactor = 5,
  warnings = TRUE
)

Arguments

exposures

String with the path to the file with the matrix of exposures.

description

String with the path to the file with the description of the exposures (relation between exposures and exposure-family).

phenotype

String with the path to the file with the phenotypes of interest.

sep

(default ",") Separator used by read.table to load the files "exposures", "description" and "phenotype".

na.strings

(default c("NA", "-", "?", " ", "")) Character defining the NA values in expsome's files.

exposures.samCol

(default "sample") Index where the samples' name are found in file "exposures". It can be both charatcer or numeric.

description.expCol

(default "exposure") Index where the exposures' name are found in file "description". It can be both numeric or character.

description.famCol

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

phenotype.samCol

(default "sample") Index where the sample's name are found in file "phenotype". 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 file, that corresponds to samples' names, must be the same than the phenotype's file. In the same way, the columns in exposure's file must be the same found as rows in description file.

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, loadExposome for constructor from loaded data.frames

Examples

## Locate the data-files
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")

## Create ExposomeSet from files
exp <- readExposome(
  exposures = exposures,
  description = description,
  phenotype = phenotype,
  exposures.samCol = 1,
  description.expCol = 2,
  description.famCol = 1,
  phenotype.samCol = 1
)

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