library(knitr)
library(st4gi)
#library(rmdformats)


traits <- params$trait
treat <- params$treat
rep <- params$rep
data <- params$data
maxp <- params$maxp
meta <- params$meta
host <- params$host

geno <- treat
# This is an automatedly created report.

# See more details in section on materials.

Abstract

 phs_lbl = "Advanced Trial"
 ttl <- stringr::str_sub(meta$title, 1, 2)
 if (stringr::str_detect(ttl, "PT")) {phs_lbl = "Preliminary Trial"}
 if (stringr::str_detect(ttl, "OT")) {phs_lbl = "Observation Trial"}
 brp_lbl = "Yield Breeding Program"

This trial has the identifier r meta$title. It was conducted under the supervision of r meta$contact as a r phs_lbl as part of a r brp_lbl in r meta$site, r meta$country in r meta$year. A total of r length(unique(data[, treat])) clones (including reference clones) were evaluated for r length(params$trait) traits.

Materials and Methods

Model specification and data description

There is data from r length(unique(data[, treat])) treatments, evaluated using a randomize complete block design with r unique(data[, rep]) blocks. The statistical model is $$ y_{ij} = \mu + \tau_i + \beta_j + \epsilon_{ij} $$ where

In this model we assume that the errors are independent and have a normal distribution with common variance, that is, $\epsilon_{ij} \sim N(0,\sigma_{\epsilon}^2)$.

The following traits are analyzed: r paste(params$trait, collapse = ", ").

gid = unique(data$germplasmDbId)
gnm = unique(data$germplasmName)


      path = "/stock/"

      #TODO change for genotypes
      out = paste0("<a href='http://",host, path, gid,"/view' target='_blank'>",gnm,"</a>")
      txt = paste0("") # TODO make trait choosable
      out = paste( out, collapse = ", ")
      gidOut = paste(txt, out)

The following germplasm was analyzed: r paste(gidOut).

Computational tools

s <- sessionInfo()

This report was created using r s$R.version on a r s$platform running r s$running in r s$locacel. The following base packages were loaded: r paste(unlist(s$basePkgs), collapse = ", ") and the following additional packages: r paste(names(s$otherPkgs), collapse = ", ").

Results

Raw data

Trait summaries

Trait analyses {.tabset}

    data = data[, c(treat, "REP", traits)]
    # 
    data[, treat] <- as.factor(data[, treat])

# exclude the response variable and empty variable for RF imputation
    datas <- names(data)[!names(data) %in% c(treat, "PED1")] # TODO replace "PED1" by a search
    #datas <- names(data)[!names(data) %in% c(treat)]

    x <- data[, datas]

    # x <- data[, trait]
    for(i in 1:ncol(x)){
      x[, i] <- as.numeric(x[, i])
    }
    # 
    y <- data[, treat]

    # determine which traits are having more than 10% missing values

    mval = 0.1
    n = ncol(data)
    m = nrow(data)
    off = round(mval * m, 0)
    mval = logical(n)
    mvan = numeric(n)

    # Remove all complete NA first
    # for(i in 1:n) {
    #   #mvan[i] = nrow(data[is.na(data[, i]), ])
    #   mval[i] = nrow(data[is.na(data[, i]), ]) == nrow(data)
    # }


    for(i in 1:n) {
      mvan[i] = nrow(data[is.na(data[, i]), ])
      mval[i] = nrow(data[is.na(data[, i]), ]) / m  * 100 <= off
    }
    mvnm = names(data)[!mval]
    dat = data
    if (any(is.na(x))){
      #capture.output({
      dat <- randomForest::rfImpute(x = x, y = y )
      names(dat)[1] <- treat
      dat = dat[, mval]
    }
      #names(data)[1] <- "REP"
     #  xnm = names(dat)
    trts = names(dat)[-c(1,2)]
    dat[, treat] <- as.character(dat[, treat])
    #lc <- st4gi::checkdata01(trts, treat, rep, dat)
    tbl = dat

The following traits were not analyzed since they had too many missing values (>= 10%): r paste(mvnm). For the remaining traits missing values were imputed using all available information.

Valid traits: r paste(names(dat)[-c(1,2)]).

out <- NULL
for (k in 1:length(trts)) {
   lc <- st4gi::checkdata01(trts[k], treat, rep, tbl)
   out <- c(out, knit_expand('child_rcbd2_old.Rmd'))
}

r paste(knit(text = out), collapse = '\n')



CIP-RIU/hidap documentation built on April 30, 2021, 9:21 p.m.