gs_summaries: Summaries for Genomic Selection

View source: R/genomic_selection.R

gs_summariesR Documentation

Summaries for Genomic Selection

Description

Generates summaries of predictions from different folds for Genomic Selection analysis.

Usage

gs_summaries(predictions, save_at = NULL, digits = 4)

Arguments

predictions

(data.frame) The genomic, observed and predicted data. The data.frame must contain the columns Fold, Line, Env, Observed and Predicted. If the response variable is categorical make sure to set Observed and Predicted as factor. For categorical response variables it is also necessary to include a column for each class in the response variable with the predicted probabilities, the column must have the class as name. If predictions contains a column nameed Trait, the summaries will be computed and saved per trait.

save_at

(character(1)) The directory's name where the summaries and predictions are going to be saved as CSV. If NULL is provided, the results are only returned but not saved. NULL by default.

digits

(numeric(1)) Digits of precision to use in the summaries. 4 by default.

Value

A list with 3 summaries: "line", "env" and "fold".

Examples

## Not run: 
# For a continuous response ------------------------------------------------
set.seed(1)

# Simulated data
predictions <- data.frame(
  Fold = rep(c("F1", "F2"), each = 24),
  Env = rep(c("E1", "E2"), each = 12),
  Line = rep(c("L1", "L2", "L3"), 16),
  Observed = rnorm(48, 10, 1),
  Predicted = rnorm(48, 10, 1)
)

summaries <- gs_summaries(predictions, save_at = "numeric_summaries")
summaries$line
summaries$env
summaries$fold

# For a categorical response ------------------------------------------------
set.seed(2)

# Simulated data
predictions <- data.frame(
    Fold = rep(c("F1", "F2"), each = 24),
    Env = rep(c("E1", "E2"), each = 12),
    Line = rep(c("L1", "L2", "L3"), 16),
    Observed = sample(c("A", "B"), 24, TRUE),
    A = runif(48, 0, 1)
  ) %>%
  dplyr::mutate(
    B = 1 - A,
    Predicted = factor(ifelse(A > 0.5, "A", "B")),
    Observed = factor(Observed)
  )
summaries <- gs_summaries(predictions, save_at = "categorical_summaries")
summaries$line
summaries$env
summaries$fold

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.