Feature info {data-orientation=rows, data-navmenu="Features"}

{ .ftInfo }

Feature info { .ftInfo }

table <- as.data.table(rmdVars$fGroups, qualities = "score", average = TRUE)
table[, EIC := imgTags(chromPaths)]
setcolorder(table, c("group", "EIC"))
if (rmdVars$retMin)
    table[, ret := ret / 60]
for (col in names(table)[(sapply(table, is.numeric))])
    set(table, j = col, value = round(table[[col]], if (col == "mz") 5 else 2))

initDT <- DT::JS("function(settings, json) {",
                 "setTimeout(function() {",
                 "$(\".dataTable\").DataTable().columns.adjust().draw(); }",
                 ", 100); }")
buttonFunc <- function(cols)
{
    cols <- match(cols, names(table))
    DT::JS(paste("function (e, dt, node, config) {",
                 paste0(sprintf("dt.column(%d).visible(!dt.column(%d).visible());", cols, cols), collapse = "\n"),
                 "}"))
}

bts <- list(list(text = "Intensities", action = buttonFunc(replicateGroups(rmdVars$fGroups))))

hiddenCols <- integer()
if (hasFGroupScores(rmdVars$fGroups))
{
    setnames(table, "totalScore", "Total score")
    otherSc <- featureQualityNames(scores = TRUE, totScore = FALSE)
    bts <- c(bts, list(list(text = "Total score", action = buttonFunc("Total score")),
                       list(text = "Other scores", action = buttonFunc(otherSc))))
    hiddenCols <- match(otherSc, names(table))
}

if (isScreening(rmdVars$fGroups))
    bts <- c(bts, list(list(text = "Suspect name", action = buttonFunc("susp_name"))))

if (nrow(internalStandards(rmdVars$fGroups)) > 0)
{
    wrapISTDs <- function(s) wrapStr(gsub(",", ", ", s, fixed = TRUE), 50)
    if (isFGSet(rmdVars$fGroups))
    {
        for (s in sets(rmdVars$fGroups))
        {
            cn <- paste0("ISTD_assigned-", s)
            table[, (cn) := sapply(get(cn), wrapISTDs)]
        }
    } else if (!is.null(table[["ISTD_assigned"]]))
        table[, ISTD_assigned := sapply(ISTD_assigned, wrapISTDs)]
}

tabOpts <- list(dom = "Bfrtip", scrollX = TRUE, scrollY = "600px", deferRender = TRUE,
                paging = FALSE, autoWidth = FALSE,
                initComplete = initDT, order = list(list(0, "asc")),
                buttons = list(list(extend = "colvis", text = "Columns",
                                    background = TRUE, buttons = bts)))
if (length(hiddenCols))
    tabOpts <- c(tabOpts, list(columnDefs = list(list(visible = FALSE, targets = hiddenCols))))

DT::datatable(table, extensions = "Buttons", options = tabOpts, elementId = "ftInfoTable", escape = FALSE)


rickhelmus/patRoon documentation built on April 25, 2024, 8:15 a.m.