knitr::opts_chunk$set(echo = TRUE)

Build the Workflow

Export dataset to file

appendStep(sal) <- LineWise(
    code = {
        mapply(
          function(x, y) write.csv(x, y),
          split(iris, factor(iris$Species)),
          file.path("results", paste0(names(split(iris, factor(iris$Species))), ".csv"))
        )
    }, 
    step_name = "export_iris"
)

Compress data

appendStep(sal) <- SYSargsList(
    step_name = "gzip", 
    targets="targets.txt", dir=TRUE,
    wf_file="gunzip/workflow_gzip.cwl", input_file="gunzip/gzip.yml",
    dir_path = "param/cwl",
    inputvars = c(FileName = "_FILE_PATH_", SampleName = "_SampleName_"), 
    dependency = "export_iris"
)

Decompress data

appendStep(sal) <- SYSargsList(
    step_name = "gunzip", 
    targets = "gzip", dir = TRUE,
    wf_file = "gunzip/workflow_gunzip.cwl", input_file = "gunzip/gunzip.yml",
    dir_path = "param/cwl",
    inputvars = c(gzip_file = "_FILE_PATH_", SampleName = "_SampleName_"), 
    rm_targets_col = "FileName", 
    dependency = "gzip"
)

Import data to R and perform statistical analysis and visualization

appendStep(sal) <- LineWise(
    code = {
        df <- lapply(getColumn(sal, step="gunzip", 'outfiles'), function(x) read.delim(x, sep=",")[-1])
        df <- do.call(rbind, df)

        stats <- data.frame(cbind(mean=apply(df[,1:4], 2, mean),
                       sd=apply(df[,1:4], 2, sd)))
        stats$species <- rownames(stats)

        plot <- ggplot2::ggplot(stats, ggplot2::aes(x=species, y=mean, fill=species)) + 
          ggplot2::geom_bar(stat = "identity", color="black", position=ggplot2::position_dodge()) +
          ggplot2::geom_errorbar(ggplot2::aes(ymin=mean-sd, ymax=mean+sd), width=.2, position=ggplot2::position_dodge(.9)) 
    }, 
  step_name = "stats",
  dependency = "gunzip"
)


systemPipeR/systemPipeShiny documentation built on Oct. 17, 2023, 3:40 a.m.