get pbg_metrics data frames

ingest_training_stats(
  simba_ref,
  gg_dirname = "graph0",
  tr_output = "model",
  jsonpath
)

Arguments

simba_ref

reference to simba module

gg_dirname

character(1) the dirname specified for build_and_train_pbg, defaults to 'graph0'

tr_output

character(1) the output specified for build_and_train_pbg defaults to 'model'

jsonpath

character(1) path to training_stats.json

Value

a list with two data.frames of training statistics

Examples

# full run-based, commented out as too long
# p3k = get_10x3kpbmc_path(overwrite=TRUE) # allow repetition
# ref = simba_ref()
# pp = ref$read_h5ad(p3k)
# bb = basic_preproc(pp, simba_ref=ref)
# gg = build_and_train_pbg( bb, simba_ref=ref )
# ts = ingest_training_stats(ref)
# head(ts$df1)
#
# use archived pbg output
#
tpath = system.file(file.path("extdata", "pbg3k.tar.xz"), package="Simba4Bioc")
untar(tpath, exdir = tempdir())
#> Warning: '/bin/tar -xf '' -C '/home/vincent/TEMP/Rtmpf7vh4D'' returned error code 2
jsonpath = paste0(tempdir(), "/pbg/graph0/model/training_stats.json")
ts = ingest_training_stats(jsonpath=jsonpath)
#> Warning: cannot open file '/home/vincent/TEMP/Rtmpf7vh4D/pbg/graph0/model/training_stats.json': No such file or directory
#> Error in file(con, "r"): cannot open the connection
head(ts$df1)
#> Error in (function (cond) .Internal(C_tryCatchHelper(addr, 1L, cond)))(structure(list(message = "object of type 'closure' is not subsettable",     call = ts$df1, object = function (data = NA, start = 1, end = numeric(),         frequency = 1, deltat = 1, ts.eps = getOption("ts.eps"),         class = if (nseries > 1) c("mts", "ts", "matrix", "array") else "ts",         names = if (!is.null(dimnames(data))) colnames(data) else paste("Series",             seq(nseries)))     {        if (is.data.frame(data))             data <- data.matrix(data)        if (is.matrix(data)) {            nseries <- ncol(data)            ndata <- nrow(data)            dimnames(data) <- list(NULL, names)        }        else {            nseries <- 1            ndata <- length(data)        }        if (ndata == 0)             stop("'ts' object must have one or more observations")        if (missing(frequency))             frequency <- 1/deltat        else if (missing(deltat))             deltat <- 1/frequency        if (frequency > 1 && 0 < (d <- abs(frequency - round(frequency))) &&             d < ts.eps)             frequency <- round(frequency)        if (!missing(start))             start <- as.numeric(start)        if (length(start) > 1L) {            start <- start[1L] + (start[2L] - 1)/frequency        }        if (!missing(end))             end <- as.numeric(end)        if (length(end) > 1L) {            end <- end[1L] + (end[2L] - 1)/frequency        }        if (missing(end))             end <- start + (ndata - 1)/frequency        else if (missing(start))             start <- end - (ndata - 1)/frequency        if (start > end)             stop("'start' cannot be after 'end'")        cycles <- as.numeric((end - start) * frequency)        if (abs(round(cycles) - cycles) > ts.eps * max(cycles,             1))             stop("'end' must be a whole number of cycles after 'start'")        nobs <- floor(cycles + 1.01)        if (nobs != ndata)             data <- if (NCOL(data) == 1) {                if (ndata < nobs)                   rep_len(data, nobs)                else if (ndata > nobs)                   data[1L:nobs]            }            else {                if (ndata < nobs)                   data[rep_len(1L:ndata, nobs), ]                else if (ndata > nobs)                   data[1L:nobs, ]            }        attr(data, "tsp") <- c(start, end, frequency)        if (!is.null(class) && class[[1]] != "none")             attr(data, "class") <- class        data    }), class = c("notSubsettableError", "error", "condition"))): error in evaluating the argument 'x' in selecting a method for function 'head': object of type 'closure' is not subsettable