LineWise-class: Class '"LineWise"'

LineWise-classR Documentation

Class "LineWise"

Description

S4 class container for storing R-based code for a workflow step. LineWise class instances are constructed by the LineWise function, based on the R-based code, step name, and dependency tree. When the container is built from the R Markdown, using importWF function, two other slots are populated: codeChunkStart and rmdPath. codeChunkStart will store the first line of each R chunk, and rmdPath will store the R Markdown file path.

Usage

## Constructor

LineWise(code, step_name = "default", codeChunkStart = integer(), 
            rmdPath = character(), dependency="", 
            run_step = "mandatory",
            run_session = "management", 
            run_remote_resources = NULL) 
        

Arguments

code

R code separated either by a semi-colon (\;), or by a newline, and enclosed by braces ({ }).

step_name

character. Step name needs to be unique and is required when appending this step to the workflow.

codeChunkStart

integer. R Markdown code chunk line start. This element will be populated when the object is built by importWF.

rmdPath

character. Path of R Markdown file used by importWF.

dependency

character. Dependency tree, required when appending this step to the workflow. Character name of a previous step in the workflow. Default is empty string "".

run_step

character. If the step has "mandatory" or "optional" flag for the execution.

run_session

character. If the step has "management" or "compute" flag for the execution.

run_remote_resources

List for reserving for each cluster job sufficient computing resources including memory (Megabyte), number of nodes, CPU cores, walltime (minutes), etc. It is necessary two aditional files: conffile and template. conffile is the path to conf file (default location ./.batchtools.conf.R). This file contains in its simplest form just one command, such as this line for the Slurm scheduler: cluster.functions <- makeClusterFunctionsSlurm(template="batchtools.slurm.tmpl"). For more detailed information visit this page: https://mllg.github.io/batchtools/index.html template The template files for a specific queueing/scheduling systems can be downloaded from here: https://github.com/mllg/batchtools/tree/master/inst/templates. Slurm, PBS/Torque, and Sun Grid Engine (SGE) templates are provided

Objects from the Class

Objects can be created by calls of the form new("LineWise", ...).

Slots

codeLine:

Object of class "expression" storing R-based code.

codeChunkStart:

Object of class "interger" storing start line from the rmdPath file, when the "LineWise" is built from R Markdown.

stepName:

Object of class "character" storing step name.

dependency:

Object of class "list" storing dependency tree.

status:

Object of class "list" storing status steps.

files:

Object of class "list" storing file for R Markdown file and the file containing stdout and stderr after running the R-based code.

runInfo:

Object of class "list" storing all the runInfo information of the workflow

Functions and Methods

See 'Usage' for details on invocation.

Constructor:

LineWise:

Returns a LineWise object.

Accessors:

codeLine

Printing method for the CodeLine slot.

codeChunkStart

Extract start line of the R Markdown R chunk.

rmdPath

Extract Rmarkdown file path.

stepName

Extract the step name.

dependency

Extract the dependency tree.

status

Extract status of the step.

files

Extract log file path storing stdout and stderr after running step.

appendCodeLine<-

Replacement method for append a R code line.

replaceCodeLine<-

Replacement method for replace a R code line.

Methods:

[

Return a new LineWise object made of the selected R code lines.

[[

Extract the slot information from LineWine object.

[[<-

Replacement method for LineWine slots.

$

Extract slots elements by name.

length

Extract number of R-based code lines.

names

Extract slot names.

show

Summary view of LineWise elements.

coerce

signature(from = "LineWise", to = "list")as(LineWise, "list")

coerce

signature(from = "list", to = "LineWise")as(list, "LineWise")

linewise

Coerce back to list as(LineWise, "list")

Author(s)

Daniela Cassol

See Also

SYSargsList

Examples

showClass("LineWise")
lw <- LineWise(code = {
              log_out <- log(10)
              },
              step_name = "R_log")

codeLine(lw)

## ImportWF option
file_path <- system.file("extdata/spr_simple_lw.Rmd", package="systemPipeR")
sal <- SPRproject(overwrite = TRUE)
# file_path <- "../inst/extdata/spr_simple_lw.Rmd"
sal <- importWF(sal, file_path)
sal <- runWF(sal)
lw2 <- sal$stepsWF[[2]]
lw2
names(lw2)
length(lw2)

## Accessors
codeLine(lw2)
codeChunkStart(lw2)
rmdPath(lw2)
stepName(lw2)
dependency(lw2)
status(lw2)
files(lw2)

## Replacement
appendCodeLine(lw2, after = 0) <- "log <- log(10)"
codeLine(lw2)
replaceCodeLine(lw2, 1) <- "plot(iris)"
codeLine(lw2)

## Coerce
lw2 <- linewise(lw2) ## OR lw2 <- as(lw2, "list") 
lw2 <- as(lw2, "LineWise")

tgirke/systemPipeR documentation built on Sept. 24, 2024, 9:48 a.m.