# \donttest{
f <- "https://raw.githubusercontent.com/joshqsumner/pcvrTestData/main/pcv4-single-value-traits.csv"
tryCatch(
{
sv <- read.pcv(
f,
reader = "fread"
)
sv$genotype <- substr(sv$barcode, 3, 5)
sv$genotype <- ifelse(sv$genotype == "002", "B73",
ifelse(sv$genotype == "003", "W605S",
ifelse(sv$genotype == "004", "MM", "Mo17")
)
)
sv$fertilizer <- substr(sv$barcode, 8, 8)
sv$fertilizer <- ifelse(sv$fertilizer == "A", "100",
ifelse(sv$fertilizer == "B", "50", "0")
)
sv <- bw.time(sv,
plantingDelay = 0, phenotype = "area_pixels",
cutoff = 10, timeCol = "timestamp", group = c("barcode", "rotation"), plot = FALSE
)
phenotypes <- colnames(sv)[19:35]
phenoForm <- paste0("cbind(", paste0(phenotypes, collapse = ", "), ")")
groupForm <- "DAS+DAP+barcode+genotype+fertilizer"
form <- as.formula(paste0(phenoForm, "~", groupForm))
sv <- aggregate(form, data = sv, mean, na.rm = TRUE)
sv <- bw.outliers(sv,
phenotype = "area_pixels",
group = c("DAS", "genotype", "fertilizer"),
plotgroup = c("barcode")
)$data
pixels_per_cmsq <- 42.5^2 # pixel per cm^2
sv$area_cm2 <- sv$area_pixels / pixels_per_cmsq
sv$height_cm <- sv$height_pixels / 42.5
df <- sv
phenotypes <- c("area_cm2", "height_cm")
grouping <- c("fertilizer", "genotype", "DAS")
controlGroup <- "100"
control <- "fertilizer"
rt <- relativeTolerance(df, phenotypes, grouping, control, controlGroup)
head(rt)
sapply(rt, function(c) sum(is.na(c)))
},
error = function(e) {
message(e)
}
)
# }
Run the code above in your browser using DataLab