Description Usage Arguments Value Note Examples
View source: R/trait_genetics_tidy.R
Compute heritability and genotypic BLUEs for each selected grouping variable adjusting for covariate.
1 2 3 4 5 6 7 8 9 | heritability_n_blues(
df,
grouping_var,
grouping_items_sel,
dependent_var,
covariate = NULL,
genotype_var,
replication_var
)
|
df |
A dataframe or similar object of coercible class. |
grouping_var |
Column name of the grouping variable such as location or environment of character or factor type. |
grouping_items_sel |
A character vector of items which are subset of grouping variable selected for obtaining heritability. |
dependent_var |
Column name of response variable whose heritability estimates are being obtained through model. |
covariate |
Column name of numeric variable. Adjusted values of dependent variable for this covariate will be used in obtaining estimates. |
replication_var |
Column name of variable representing replicated records of genotypes/treatments. |
genotype |
Column name of variable representing genotypes/treatments. |
A list
Adapted from 'meta-r' application package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(lme4)
library(emmeans)
require(tidyverse)
# load data
df <- expdean::simple_rcbd_df
df <- mutate_at(df, c("Genotype", "Rep"), as.factor)
# check for factor levels
df %>%
select_if(list(~is.factor(.)|is.character(.))) %>%
map_int(~length(unique(.x)))
# calculate genetic correlation for locations in absence of other grouping factors while adjusting for covariate
heritability_n_blues(df, grouping_items_sel = c("Buenos Aires", "Beijin", "Karaj"),
grouping_var = Location,
genotype = Genotype, replication_var = Rep,
dependent_var = YLD, covariate = TGW)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.