Based on the pedigree simulation, we start with
library(pedSimulate) ped <- simulatePed( F0size = 4, Va0 = 15, Ve = 225, littersize = 2, ngen = 2, overlap.s = 1, m.rate = 0.5, seed = 5298 )
The simulated pedigree
ped
Adding genotypes can be done by
set.seed(9157) n_nr_SNP <- 3 AF <- runif(n_nr_SNP, 0.1, 0.9) gen <- simulateGen(ped = ped, AF = AF, seed = 6984)
The genotypes
gen
Marker effects are assumed
vec_mrk_eff <- c(13.7, 2.1, 9.9)
Contributions to add
vec_p_to_add <- gen %*% vec_mrk_eff vec_p_to_add
ped$P <- as.vector(ped$P + vec_p_to_add) ped
tbl_gen <- tibble::as_tibble(gen) tbl_gen
A vector ov column names
vec_col_names <- sapply(1:n_nr_SNP, function(x) paste0("SNP", x, collapse = ""), USE.NAMES = FALSE) vec_col_names
colnames(tbl_gen) <- vec_col_names tbl_gen
Append genotypes to ped
library(dplyr) tbl_ped <- tibble::as_tibble(ped) # select relevant columns tbl_ped_data_out <- ped %>% select(ID, SIRE, DAM, SEX, P) # set unknown paretns to NA tbl_ped_data_out$SIRE[tbl_ped_data_out$SIRE == 0] <- NA tbl_ped_data_out$DAM[tbl_ped_data_out$DAM == 0] <- NA tbl_gen_data_out <- tbl_gen[(!is.na(tbl_ped_data_out$SIRE) & !is.na(tbl_ped_data_out$DAM)), ] tbl_ped_data_out <- tbl_ped_data_out[(!is.na(tbl_ped_data_out$SIRE) & !is.na(tbl_ped_data_out$DAM)), ] # remove founder genotypes tbl_gen_data_out <- dplyr::bind_cols(tbl_ped_data_out, tbl_gen_data_out) tbl_gen_data_out
Further preparation
# rouding tbl_gen_data_out$P <- round(tbl_gen_data_out$P, digits = 1) tbl_gen_data_out
Write data to a file
s_data_out_path <- file.path(here::here(), "docs", "data", "asm_exam_p05.csv") if (!file.exists(s_data_out_path)) readr::write_csv(tbl_gen_data_out, s_data_out_path)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.