| phenotypes {corehunter} | R Documentation |
Create Core Hunter phenotype data from data frame or file.
Description
Specify either a data frame containing the phenotypic trait observations or a file from which to read the data. See https://www.corehunter.org for documentation and examples of the phenotype data format used by Core Hunter.
Usage
phenotypes(data, types, min, max, file)
Arguments
data |
Data frame containing one row per individual and one column per trait.
Unique row and column names are required and used as item and trait ids, respectively.
The data frame may optionally include a first column |
types |
Variable types (optional). Vector of characters, each of length one or two. Ignored when reading from file. The first letter indicates the scale type and should be one of The second letter optionally indicates the variable encoding (in Java) and should
be one of If no explicit variable types are specified these are automatically inferred from
the data frame column types and classes, whenever possible. Columns of type
Boolean encoded nominals ( Ordinal variables of class If explicit types are given for some variables others can still be automatically inferred
by setting their type to |
min |
Minimum values of interval or ratio variables (optional).
Numeric vector. Ignored when reading from file.
If undefined for some variables the respective minimum is inferred from the data.
If the data exceeds the minimum it is also updated accordingly.
For nominal and ordinal variables just put |
max |
Maximum values of interval or ratio variables (optional).
Numeric vector. Ignored when reading from file.
If undefined for some variables the respective maximum is inferred from the data.
If the data exceeds the maximum it is also updated accordingly.
For nominal and ordinal variables just put |
file |
File containing the phenotype data. |
Value
Phenotype data of class chpheno with elements
dataPhenotypes (data frame).
sizeNumber of individuals in the dataset.
idsUnique item identifiers.
namesItem names. Names of individuals to which no explicit name has been assigned are equal to the unique
ids.typesVariable types and encodings.
rangesVariable ranges, when applicable (
NAelsewhere).javaJava version of the data object.
fileNormalized path of file from which the data was read (if applicable).
Examples
# create from data frame
pheno.data <- data.frame(
season = c("winter", "summer", "summer", "winter", "summer"),
yield = c(34.5, 32.6, 22.1, 54.12, 43.33),
size = ordered(c("l", "s", "s", "m", "l"), levels = c("s", "m", "l")),
resistant = c(FALSE, TRUE, TRUE, FALSE, TRUE)
)
pheno <- phenotypes(pheno.data)
# explicit types
pheno <- phenotypes(pheno.data, types = c("N", "R", "O", "NB"))
# treat last column as symmetric binary, auto infer others
pheno <- phenotypes(pheno.data, types = c(NA, NA, NA, "NS"))
# explicit ranges
pheno <- phenotypes(pheno.data, min = c(NA, 20.0, NA, NA), max = c(NA, 60.0, NA, NA))
# read from file
pheno.file <- system.file("extdata", "phenotypes.csv", package = "corehunter")
pheno <- phenotypes(file = pheno.file)