text:
title: "RNA-Seq Workflow Template"
author: "Author: Daniela Cassol (danielac@ucr.edu) and Thomas Girke (thomas.girke@ucr.edu)"
date: "Last update: 26 May, 2022"
output:
  BiocStyle::html_document:
    toc_float: true
    code_folding: show
package: systemPipeR
vignette: |
  %\VignetteEncoding{UTF-8}
  %\VignetteIndexEntry{WF: RNA-Seq Workflow Template}
  %\VignetteEngine{knitr::rmarkdown}
fontsize: 14pt
bibliography: bibtex.bib
editor_options:
  chunk_output_type: console
---

# Introduction

Users want to provide here background information about the design of their RNA-Seq project.

# Samples and environment settings

## Environment settings and input data

[*systemPipeRdata*](http://bioconductor.org/packages/release/data/experiment/html/systemPipeRdata.html) package is a helper package to generate a fully populated [*systemPipeR*](http://bioconductor.org/packages/release/bioc/html/systemPipeR.html)
workflow environment in the current working directory with a single command.
All the instruction for generating the workflow are provide in the *systemPipeRdata* vignette [here](http://www.bioconductor.org/packages/devel/data/experiment/vignettes/systemPipeRdata/inst/doc/systemPipeRdata.html#1_Introduction).

``` r
systemPipeRdata::genWorkenvir(workflow = "rnaseq", mydirname = "rnaseq")
setwd("rnaseq")
```

Typically, the user wants to record here the sources and versions of the
reference genome sequence along with the corresponding annotations. In
the provided sample data set all data inputs are stored in a `data`
subdirectory and all results will be written to a separate `results` directory,
while the `systemPipeRNAseq.Rmd` workflow and the `targets` file are expected to be
located in the parent directory.

The chosen data set used by this report [SRP010938](http://www.ncbi.nlm.nih.gov/sra/?term=SRP010938)
contains 18 paired-end (PE) read sets from *Arabidposis thaliana*
(Howard et al. 2013). To minimize processing time during testing, each FASTQ
file has been subsetted to 90,000-100,000 randomly sampled PE reads that
map to the first 100,000 nucleotides of each chromosome of the *A.
thaliana* genome. The corresponding reference genome sequence (FASTA) and
its GFF annotation files have been truncated accordingly. This way the entire
test sample data set is less than 200MB in storage space. A PE read set has been
chosen for this test data set for flexibility, because it can be used for testing both types
of analysis routines requiring either SE (single end) reads or PE reads.

To work with real data, users want to organize their own data similarly
and substitute all test data for their own data. To rerun an established
workflow on new data, the initial `targets` file along with the corresponding
FASTQ files are usually the only inputs the user needs to provide.

For more details, please consult the documentation
[here](http://www.bioconductor.org/packages/release/bioc/vignettes/systemPipeR/inst/doc/systemPipeR.html). More information about the `targets` files from *systemPipeR* can be found [here](http://www.bioconductor.org/packages/release/bioc/vignettes/systemPipeR/inst/doc/systemPipeR.html#42_Structure_of_initial_targets_data).

### Experiment definition provided by `targets` file

The `targets` file defines all FASTQ files and sample comparisons of the analysis workflow.

``` r
targetspath <- system.file("extdata", "targetsPE.txt", package = "systemPipeR")
targets <- read.delim(targetspath, comment.char = "#")
targets[1:4, -c(5, 6)]
```

    ##                     FileName1                   FileName2
    ## 1 ./data/SRR446027_1.fastq.gz ./data/SRR446027_2.fastq.gz
    ## 2 ./data/SRR446028_1.fastq.gz ./data/SRR446028_2.fastq.gz
    ## 3 ./data/SRR446029_1.fastq.gz ./data/SRR446029_2.fastq.gz
    ## 4 ./data/SRR446030_1.fastq.gz ./data/SRR446030_2.fastq.gz
    ##   SampleName Factor        Date
    ## 1        M1A     M1 23-Mar-2012
    ## 2        M1B     M1 23-Mar-2012
    ## 3        A1A     A1 23-Mar-2012
    ## 4        A1B     A1 23-Mar-2012

To work with custom data, users need to generate a *`targets`* file containing
the paths to their own FASTQ files.

# Workflow environment

*`systemPipeR`* workflows can be designed and built from start to finish with a
single command, importing from an R Markdown file or stepwise in interactive
mode from the R console.

This tutorial will demonstrate how to build the workflow in an interactive mode,
appending each step. The workflow is constructed by connecting each step via
`appendStep` method. Each `SYSargsList` instance contains instructions for
processing a set of input files with a specific command-line or R software
and the paths to the corresponding outfiles generated by a particular command-line
software/step.

To create a workflow within *`systemPipeR`*, we can start by defining an empty
container and checking the directory structure:

``` r
library(systemPipeR)
sal <- SPRproject()
sal
```

## Required packages and resources

The `systemPipeR` package needs to be loaded (H Backman and Girke 2016).

``` r
appendStep(sal) <- LineWise(code = {
    library(systemPipeR)
}, step_name = "load_SPR")
```

## Read preprocessing

### Preprocessing with `preprocessReads` function

The function `preprocessReads` allows to apply predefined or custom
read preprocessing functions to all FASTQ files referenced in a
`SYSargsList` container, such as quality filtering or adapter trimming
routines. Internally, `preprocessReads` uses the `FastqStreamer` function from
the `ShortRead` package to stream through large FASTQ files in a
memory-efficient manner. The following example performs adapter trimming with
the `trimLRPatterns` function from the `Biostrings` package.

Here, we are appending this step to the `SYSargsList` object created previously.
All the parameters are defined on the `preprocessReads/preprocessReads-pe.yml` file.

``` r
appendStep(sal) <- SYSargsList(step_name = "preprocessing", targets = "targetsPE.txt",
    dir = TRUE, wf_file = "preprocessReads/preprocessReads-pe.cwl",
    input_file = "preprocessReads/preprocessReads-pe.yml", dir_path = system.file("extdata/cwl",
        package = "systemPipeR"), inputvars = c(FileName1 = "_FASTQ_PATH1_",
        FileName2 = "_FASTQ_PATH2_", SampleName = "_SampleName_"),
    dependency = c("load_SPR"))
```

After the preprocessing step, the `outfiles` files can be used to generate the new
targets files containing the paths to the trimmed FASTQ files. The new targets
information can be used for the next workflow step instance, *e.g.* running the
NGS alignments with the trimmed FASTQ files. The `appendStep` function is
automatically handling this connectivity between steps. Please check the next
step for more details.

The following example shows how one can design a custom read *'preprocessReads'*
function using utilities provided by the `ShortRead` package, and then run it
in batch mode with the *'preprocessReads'* function. Here, it is possible to
replace the function used on the `preprocessing` step and modify the `sal` object.
Because it is a custom function, it is necessary to save the part in the R object,
and internally the `preprocessReads.doc.R` is loading the custom function.
If the R object is saved with a different name (here `"param/customFCT.RData"`),
please replace that accordingly in the `preprocessReads.doc.R`.

Please, note that this step is not added to the workflow, here just for
demonstration.

First, we defined the custom function in the workflow:

``` r
appendStep(sal) <- LineWise(code = {
    filterFct <- function(fq, cutoff = 20, Nexceptions = 0) {
        qcount <- rowSums(as(quality(fq), "matrix") <= cutoff,
            na.rm = TRUE)
        # Retains reads where Phred scores are >= cutoff
        # with N exceptions
        fq[qcount <= Nexceptions]
    }
    save(list = ls(), file = "param/customFCT.RData")
}, step_name = "custom_preprocessing_function", dependency = "preprocessing")
```

After, we can edit the input parameter:

``` r
yamlinput(sal, "preprocessing")$Fct
yamlinput(sal, "preprocessing", "Fct") <- "'filterFct(fq, cutoff=20, Nexceptions=0)'"
yamlinput(sal, "preprocessing")$Fct  ## check the new function
cmdlist(sal, "preprocessing", targets = 1)  ## check if the command line was updated with success
```

### Read trimming with Trimmomatic

[Trimmomatic](http://www.usadellab.org/cms/?page=trimmomatic) software (Bolger, Lohse, and Usadel 2014)
performs a variety of useful trimming tasks for Illumina paired-end and single
ended data. Here, an example of how to perform this task using parameters template
files for trimming FASTQ files.

This step is optional.

``` r
appendStep(sal) <- SYSargsList(step_name = "trimming", targets = "targetsPE.txt",
    wf_file = "trimmomatic/trimmomatic-pe.cwl", input_file = "trimmomatic/trimmomatic-pe.yml",
    dir_path = system.file("extdata/cwl", package = "systemPipeR"),
    inputvars = c(FileName1 = "_FASTQ_PATH1_", FileName2 = "_FASTQ_PATH2_",
        SampleName = "_SampleName_"), dependency = "load_SPR",
    run_step = "optional")
```

### FASTQ quality report

The following `seeFastq` and `seeFastqPlot` functions generate and plot a series of useful
quality statistics for a set of FASTQ files, including per cycle quality box
plots, base proportions, base-level quality trends, relative k-mer
diversity, length, and occurrence distribution of reads, number of reads
above quality cutoffs and mean quality distribution. The results are
written to a PDF file named `fastqReport.pdf`.

``` r
appendStep(sal) <- LineWise(code = {
    fastq <- getColumn(sal, step = "preprocessing", "targetsWF",
        column = 1)
    fqlist <- seeFastq(fastq = fastq, batchsize = 10000, klength = 8)
    pdf("./results/fastqReport.pdf", height = 18, width = 4 *
        length(fqlist))
    seeFastqPlot(fqlist)
    dev.off()
}, step_name = "fastq_report", dependency = "preprocessing")
```

![](results/fastqReport.png)

Figure 1: FASTQ quality report for 18 samples

## Alignments

### Read mapping with `HISAT2`

The following steps will demonstrate how to use the short read aligner `Hisat2`
(Kim, Langmead, and Salzberg 2015). First, the `Hisat2` index needs to be created.

``` r
appendStep(sal) <- SYSargsList(step_name = "hisat2_index", dir = FALSE,
    targets = NULL, wf_file = "hisat2/hisat2-index.cwl", input_file = "hisat2/hisat2-index.yml",
    dir_path = "param/cwl", dependency = "load_SPR")
```

### `HISAT2` mapping

The parameter settings of the aligner are defined in the `workflow_hisat2-pe.cwl`
and `workflow_hisat2-pe.yml` files. The following shows how to construct the
corresponding *SYSargsList* object.

``` r
appendStep(sal) <- SYSargsList(step_name = "hisat2_mapping",
    dir = TRUE, targets = "preprocessing", wf_file = "workflow-hisat2/workflow_hisat2-pe.cwl",
    input_file = "workflow-hisat2/workflow_hisat2-pe.yml", dir_path = "param/cwl",
    inputvars = c(preprocessReads_1 = "_FASTQ_PATH1_", preprocessReads_2 = "_FASTQ_PATH2_",
        SampleName = "_SampleName_"), rm_targets_col = c("FileName1",
        "FileName2"), dependency = c("preprocessing", "hisat2_index"))
```

To double-check the command line for each sample, please use the following:

``` r
cmdlist(sal, step = "hisat2_mapping", targets = 1)
```

### Read and alignment stats

The following provides an overview of the number of reads in each sample
and how many of them aligned to the reference.

``` r
appendStep(sal) <- LineWise(code = {
    fqpaths <- getColumn(sal, step = "preprocessing", "targetsWF",
        column = "FileName1")
    bampaths <- getColumn(sal, step = "hisat2_mapping", "outfiles",
        column = "samtools_sort_bam")
    read_statsDF <- alignStats(args = bampaths, fqpaths = fqpaths,
        pairEnd = TRUE)
    write.table(read_statsDF, "results/alignStats.xls", row.names = FALSE,
        quote = FALSE, sep = "\t")
}, step_name = "align_stats", dependency = "hisat2_mapping")
```

## Create symbolic links for viewing BAM files in IGV

The `symLink2bam` function creates symbolic links to view the BAM alignment files in a
genome browser such as IGV without moving these large files to a local
system. The corresponding URLs are written to a file with a path
specified under `urlfile`, here `IGVurl.txt`.
Please replace the directory and the user name.

``` r
appendStep(sal) <- LineWise(code = {
    bampaths <- getColumn(sal, step = "hisat2_mapping", "outfiles",
        column = "samtools_sort_bam")
    symLink2bam(sysargs = bampaths, htmldir = c("~/.html/", "somedir/"),
        urlbase = "http://cluster.hpcc.ucr.edu/~tgirke/", urlfile = "./results/IGVurl.txt")
}, step_name = "bam_IGV", dependency = "hisat2_mapping", run_step = "optional")
```

## Read quantification

Reads overlapping with annotation ranges of interest are counted for
each sample using the `summarizeOverlaps` function (Lawrence et al. 2013).
The read counting is preformed for exon gene regions in a non-strand-specific
manner while ignoring overlaps among different genes. Subsequently, the expression
count values are normalized by *reads per kp per million mapped reads*
(RPKM). The raw read count table (`countDFeByg.xls`) and the corresponding
RPKM table (`rpkmDFeByg.xls`) are written to separate files in the directory of
this project. Parallelization is achieved with the `BiocParallel` package,
here using 4 CPU cores.

### Create a database for gene annotation

``` r
appendStep(sal) <- LineWise(code = {
    library(GenomicFeatures)
    txdb <- suppressWarnings(makeTxDbFromGFF(file = "data/tair10.gff",
        format = "gff", dataSource = "TAIR", organism = "Arabidopsis thaliana"))
    saveDb(txdb, file = "./data/tair10.sqlite")
}, step_name = "create_db", dependency = "hisat2_mapping")
```

### Read counting with `summarizeOverlaps` in parallel mode using multiple cores

``` r
appendStep(sal) <- LineWise(code = {
    library(GenomicFeatures)
    library(BiocParallel)
    txdb <- loadDb("./data/tair10.sqlite")
    outpaths <- getColumn(sal, step = "hisat2_mapping", "outfiles",
        column = "samtools_sort_bam")
    eByg <- exonsBy(txdb, by = c("gene"))
    bfl <- BamFileList(outpaths, yieldSize = 50000, index = character())
    multicoreParam <- MulticoreParam(workers = 4)
    register(multicoreParam)
    registered()
    counteByg <- bplapply(bfl, function(x) summarizeOverlaps(eByg,
        x, mode = "Union", ignore.strand = TRUE, inter.feature = FALSE,
        singleEnd = FALSE, BPPARAM = multicoreParam))
    countDFeByg <- sapply(seq(along = counteByg), function(x) assays(counteByg[[x]])$counts)
    rownames(countDFeByg) <- names(rowRanges(counteByg[[1]]))
    colnames(countDFeByg) <- names(bfl)
    rpkmDFeByg <- apply(countDFeByg, 2, function(x) returnRPKM(counts = x,
        ranges = eByg))
    write.table(countDFeByg, "results/countDFeByg.xls", col.names = NA,
        quote = FALSE, sep = "\t")
    write.table(rpkmDFeByg, "results/rpkmDFeByg.xls", col.names = NA,
        quote = FALSE, sep = "\t")
    ## Creating a SummarizedExperiment object
    colData <- data.frame(row.names = SampleName(sal, "hisat2_mapping"),
        condition = getColumn(sal, "hisat2_mapping", position = "targetsWF",
            column = "Factor"))
    colData$condition <- factor(colData$condition)
    countDF_se <- SummarizedExperiment::SummarizedExperiment(assays = countDFeByg,
        colData = colData)
    ## Add results as SummarizedExperiment to the workflow
    ## object
    SE(sal, "read_counting") <- countDF_se
}, step_name = "read_counting", dependency = "create_db")
```

When providing a `BamFileList` as in the example above, `summarizeOverlaps` methods
use by default `bplapply` and use the register interface from BiocParallel package.
If the number of workers is not set, `MulticoreParam` will use the number of cores
returned by `parallel::detectCores()`. For more information,
please check `help("summarizeOverlaps")` documentation.

Note, for most statistical differential expression or abundance analysis
methods, such as `edgeR` or `DESeq2`, the raw count values should be used as input. The
usage of RPKM values should be restricted to specialty applications
required by some users, *e.g.* manually comparing the expression levels
among different genes or features.

### Sample-wise correlation analysis

The following computes the sample-wise Spearman correlation coefficients from
the `rlog` transformed expression values generated with the `DESeq2` package. After
transformation to a distance matrix, hierarchical clustering is performed with
the `hclust` function and the result is plotted as a dendrogram
(also see file `sample_tree.pdf`).

``` r
appendStep(sal) <- LineWise(code = {
    library(DESeq2, quietly = TRUE)
    library(ape, warn.conflicts = FALSE)
    ## Extracting SummarizedExperiment object
    se <- SE(sal, "read_counting")
    dds <- DESeqDataSet(se, design = ~condition)
    d <- cor(assay(rlog(dds)), method = "spearman")
    hc <- hclust(dist(1 - d))
    pdf("results/sample_tree.pdf")
    plot.phylo(as.phylo(hc), type = "p", edge.col = "blue", edge.width = 2,
        show.node.label = TRUE, no.margin = TRUE)
    dev.off()
}, step_name = "sample_tree", dependency = "read_counting")
```

![](results/sample_tree.png)

Figure 2: Correlation dendrogram of samples

## Analysis of DEGs

The analysis of differentially expressed genes (DEGs) is performed with
the `glm` method of the `edgeR` package (Robinson, McCarthy, and Smyth 2010). The sample
comparisons used by this analysis are defined in the header lines of the
`targets.txt` file starting with `<CMP>`.

### Run `edgeR`

``` r
appendStep(sal) <- LineWise(code = {
    library(edgeR)
    countDF <- read.delim("results/countDFeByg.xls", row.names = 1,
        check.names = FALSE)
    cmp <- readComp(stepsWF(sal)[["hisat2_mapping"]], format = "matrix",
        delim = "-")
    edgeDF <- run_edgeR(countDF = countDF, targets = targetsWF(sal)[["hisat2_mapping"]],
        cmp = cmp[[1]], independent = FALSE, mdsplot = "")
}, step_name = "run_edger", dependency = "read_counting")
```

### Add gene descriptions

``` r
appendStep(sal) <- LineWise(code = {
    library("biomaRt")
    m <- useMart("plants_mart", dataset = "athaliana_eg_gene",
        host = "https://plants.ensembl.org")
    desc <- getBM(attributes = c("tair_locus", "description"),
        mart = m)
    desc <- desc[!duplicated(desc[, 1]), ]
    descv <- as.character(desc[, 2])
    names(descv) <- as.character(desc[, 1])
    edgeDF <- data.frame(edgeDF, Desc = descv[rownames(edgeDF)],
        check.names = FALSE)
    write.table(edgeDF, "./results/edgeRglm_allcomp.xls", quote = FALSE,
        sep = "\t", col.names = NA)
}, step_name = "custom_annot", dependency = "run_edger")
```

### Plot DEG results

Filter and plot DEG results for up and down regulated genes. The
definition of *up* and *down* is given in the corresponding help
file. To open it, type `?filterDEGs` in the R console.

``` r
appendStep(sal) <- LineWise(code = {
    edgeDF <- read.delim("results/edgeRglm_allcomp.xls", row.names = 1,
        check.names = FALSE)
    pdf("results/DEGcounts.pdf")
    DEG_list <- filterDEGs(degDF = edgeDF, filter = c(Fold = 2,
        FDR = 20))
    dev.off()
    write.table(DEG_list$Summary, "./results/DEGcounts.xls",
        quote = FALSE, sep = "\t", row.names = FALSE)
}, step_name = "filter_degs", dependency = "custom_annot")
```

### Venn diagrams of DEG sets

The `overLapper` function can compute Venn intersects for large numbers of sample
sets (up to 20 or more) and plots 2-5 way Venn diagrams. A useful
feature is the possibility to combine the counts from several Venn
comparisons with the same number of sample sets in a single Venn diagram
(here for 4 up and down DEG sets).

``` r
appendStep(sal) <- LineWise(code = {
    vennsetup <- overLapper(DEG_list$Up[6:9], type = "vennsets")
    vennsetdown <- overLapper(DEG_list$Down[6:9], type = "vennsets")
    pdf("results/vennplot.pdf")
    vennPlot(list(vennsetup, vennsetdown), mymain = "", mysub = "",
        colmode = 2, ccol = c("blue", "red"))
    dev.off()
}, step_name = "venn_diagram", dependency = "filter_degs")
```

## GO term enrichment analysis

### Obtain gene-to-GO mappings

The following shows how to obtain gene-to-GO mappings from `biomaRt` (here for *A.
thaliana*) and how to organize them for the downstream GO term
enrichment analysis. Alternatively, the gene-to-GO mappings can be
obtained for many organisms from Bioconductor's `*.db` genome annotation
packages or GO annotation files provided by various genome databases.
For each annotation this relatively slow preprocessing step needs to be
performed only once. Subsequently, the preprocessed data can be loaded
with the `load` function as shown in the next subsection.

``` r
appendStep(sal) <- LineWise(code = {
    library("biomaRt")
    # listMarts() # To choose BioMart database
    # listMarts(host='plants.ensembl.org')
    m <- useMart("plants_mart", host = "https://plants.ensembl.org")
    # listDatasets(m)
    m <- useMart("plants_mart", dataset = "athaliana_eg_gene",
        host = "https://plants.ensembl.org")
    # listAttributes(m) # Choose data types you want to
    # download
    go <- getBM(attributes = c("go_id", "tair_locus", "namespace_1003"),
        mart = m)
    go <- go[go[, 3] != "", ]
    go[, 3] <- as.character(go[, 3])
    go[go[, 3] == "molecular_function", 3] <- "F"
    go[go[, 3] == "biological_process", 3] <- "P"
    go[go[, 3] == "cellular_component", 3] <- "C"
    go[1:4, ]
    if (!dir.exists("./data/GO"))
        dir.create("./data/GO")
    write.table(go, "data/GO/GOannotationsBiomart_mod.txt", quote = FALSE,
        row.names = FALSE, col.names = FALSE, sep = "\t")
    catdb <- makeCATdb(myfile = "data/GO/GOannotationsBiomart_mod.txt",
        lib = NULL, org = "", colno = c(1, 2, 3), idconv = NULL)
    save(catdb, file = "data/GO/catdb.RData")
}, step_name = "get_go_annot", dependency = "filter_degs")
```

### Batch GO term enrichment analysis

Apply the enrichment analysis to the DEG sets obtained the above differential
expression analysis. Note, in the following example the `FDR` filter is set
here to an unreasonably high value, simply because of the small size of the toy
data set used in this vignette. Batch enrichment analysis of many gene sets is
performed with the function. When `method=all`, it returns all GO terms passing
the p-value cutoff specified under the `cutoff` arguments. When `method=slim`,
it returns only the GO terms specified under the `myslimv` argument. The given
example shows how a GO slim vector for a specific organism can be obtained from
`BioMart`.

``` r
appendStep(sal) <- LineWise(code = {
    library("biomaRt")
    load("data/GO/catdb.RData")
    DEG_list <- filterDEGs(degDF = edgeDF, filter = c(Fold = 2,
        FDR = 50), plot = FALSE)
    up_down <- DEG_list$UporDown
    names(up_down) <- paste(names(up_down), "_up_down", sep = "")
    up <- DEG_list$Up
    names(up) <- paste(names(up), "_up", sep = "")
    down <- DEG_list$Down
    names(down) <- paste(names(down), "_down", sep = "")
    DEGlist <- c(up_down, up, down)
    DEGlist <- DEGlist[sapply(DEGlist, length) > 0]
    BatchResult <- GOCluster_Report(catdb = catdb, setlist = DEGlist,
        method = "all", id_type = "gene", CLSZ = 2, cutoff = 0.9,
        gocats = c("MF", "BP", "CC"), recordSpecGO = NULL)
    m <- useMart("plants_mart", dataset = "athaliana_eg_gene",
        host = "https://plants.ensembl.org")
    goslimvec <- as.character(getBM(attributes = c("goslim_goa_accession"),
        mart = m)[, 1])
    BatchResultslim <- GOCluster_Report(catdb = catdb, setlist = DEGlist,
        method = "slim", id_type = "gene", myslimv = goslimvec,
        CLSZ = 10, cutoff = 0.01, gocats = c("MF", "BP", "CC"),
        recordSpecGO = NULL)
    write.table(BatchResultslim, "results/GOBatchSlim.xls", row.names = FALSE,
        quote = FALSE, sep = "\t")
}, step_name = "go_enrich", dependency = "get_go_annot")
```

### Plot batch GO term results

The `data.frame` generated by `GOCluster` can be plotted with the `goBarplot` function. Because of the
variable size of the sample sets, it may not always be desirable to show
the results from different DEG sets in the same bar plot. Plotting
single sample sets is achieved by subsetting the input data frame as
shown in the first line of the following example.

``` r
appendStep(sal) <- LineWise(code = {
    gos <- BatchResultslim[grep("M6-V6_up_down", BatchResultslim$CLID),
        ]
    gos <- BatchResultslim
    pdf("results/GOslimbarplotMF.pdf", height = 8, width = 10)
    goBarplot(gos, gocat = "MF")
    goBarplot(gos, gocat = "BP")
    goBarplot(gos, gocat = "CC")
    dev.off()
}, step_name = "go_plot", dependency = "go_enrich")
```

![](results/GOslimbarplotMF.png)

Figure 5: GO Slim Barplot for MF Ontology

## Clustering and heat maps

The following example performs hierarchical clustering on the `rlog`
transformed expression matrix subsetted by the DEGs identified in the above
differential expression analysis. It uses a Pearson correlation-based distance
measure and complete linkage for cluster joining.

``` r
appendStep(sal) <- LineWise(code = {
    library(pheatmap)
    geneids <- unique(as.character(unlist(DEG_list[[1]])))
    y <- assay(rlog(dds))[geneids, ]
    pdf("results/heatmap1.pdf")
    pheatmap(y, scale = "row", clustering_distance_rows = "correlation",
        clustering_distance_cols = "correlation")
    dev.off()
}, step_name = "heatmap", dependency = "go_enrich")
```

![](results/heatmap1.png)

Figure 6: Heat Map with Hierarchical Clustering Dendrograms of DEGs

## Version Information

``` r
appendStep(sal) <- LineWise(code = {
    sessionInfo()
}, step_name = "sessionInfo", dependency = "heatmap")
```

# Running workflow

## Interactive job submissions in a single machine

For running the workflow, `runWF` function will execute all the steps store in
the workflow container. The execution will be on a single machine without
submitting to a queuing system of a computer cluster.

``` r
sal <- runWF(sal)
```

## Parallelization on clusters

Alternatively, the computation can be greatly accelerated by processing many files
in parallel using several compute nodes of a cluster, where a scheduling/queuing
system is used for load balancing.

The `resources` list object provides the number of independent parallel cluster
processes defined under the `Njobs` element in the list. The following example
will run 18 processes in parallel using each 4 CPU cores.
If the resources available on a cluster allow running all 18 processes at the
same time, then the shown sample submission will utilize in a total of 72 CPU cores.

Note, `runWF` can be used with most queueing systems as it is based on utilities
from the `batchtools` package, which supports the use of template files (*`*.tmpl`*)
for defining the run parameters of different schedulers. To run the following
code, one needs to have both a `conffile` (see *`.batchtools.conf.R`* samples [here](https://mllg.github.io/batchtools/))
and a `template` file (see *`*.tmpl`* samples [here](https://github.com/mllg/batchtools/tree/master/inst/templates))
for the queueing available on a system. The following example uses the sample
`conffile` and `template` files for the Slurm scheduler provided by this package.

The resources can be appended when the step is generated, or it is possible to
add these resources later, as the following example using the `addResources`
function:

``` r
resources <- list(conffile=".batchtools.conf.R",
                  template="batchtools.slurm.tmpl",
                  Njobs=18,
                  walltime=120, ## minutes
                  ntasks=1,
                  ncpus=4,
                  memory=1024, ## Mb
                  partition = "short"
                  )
sal <- addResources(sal, c("hisat2_mapping"), resources = resources)
sal <- runWF(sal)
```

## Visualize workflow

*`systemPipeR`* workflows instances can be visualized with the `plotWF` function.

``` r
plotWF(sal, rstudio = TRUE)
```

## Checking workflow status

To check the summary of the workflow, we can use:

``` r
sal
statusWF(sal)
```

## Accessing logs report

*`systemPipeR`* compiles all the workflow execution logs in one central location,
making it easier to check any standard output (`stdout`) or standard error
(`stderr`) for any command-line tools used on the workflow or the R code stdout.

``` r
sal <- renderLogs(sal)
```

# Funding

This project is funded by NSF award [ABI-1661152](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1661152).

# References

Bolger, Anthony M, Marc Lohse, and Bjoern Usadel. 2014. "Trimmomatic: A Flexible Trimmer for Illumina Sequence Data." *Bioinformatics* 30 (15): 2114–20.

H Backman, Tyler W, and Thomas Girke. 2016. "systemPipeR: NGS workflow and report generation environment." *BMC Bioinformatics* 17 (1): 388. <https://doi.org/10.1186/s12859-016-1241-0>.

Howard, Brian E, Qiwen Hu, Ahmet Can Babaoglu, Manan Chandra, Monica Borghi, Xiaoping Tan, Luyan He, et al. 2013. "High-Throughput RNA Sequencing of Pseudomonas-Infected Arabidopsis Reveals Hidden Transcriptome Complexity and Novel Splice Variants." *PLoS One* 8 (10): e74183. <https://doi.org/10.1371/journal.pone.0074183>.

Kim, Daehwan, Ben Langmead, and Steven L Salzberg. 2015. "HISAT: A Fast Spliced Aligner with Low Memory Requirements." *Nat. Methods* 12 (4): 357–60.

Lawrence, Michael, Wolfgang Huber, Hervé Pagès, Patrick Aboyoun, Marc Carlson, Robert Gentleman, Martin T Morgan, and Vincent J Carey. 2013. "Software for Computing and Annotating Genomic Ranges." *PLoS Comput. Biol.* 9 (8): e1003118. <https://doi.org/10.1371/journal.pcbi.1003118>.

Robinson, M D, D J McCarthy, and G K Smyth. 2010. "EdgeR: A Bioconductor Package for Differential Expression Analysis of Digital Gene Expression Data." *Bioinformatics* 26 (1): 139–40. <https://doi.org/10.1093/bioinformatics/btp616>.


text:
FOUNDATION_EXPORT double BraintreeVersionNumber;

//! Project version string for Braintree.
FOUNDATION_EXPORT const unsigned char BraintreeVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import "PublicHeader.h"

redpajama_set_name: RedPajamaGithub


text:
<?php

declare(strict_types=1);

namespace Sonata\Doctrine\Adapter;

final class AdapterChain implements AdapterInterface
{
    /**
     * @var AdapterInterface[]
     */
    private array $adapters = [];

    public function addAdapter(AdapterInterface $adapter): void
    {
        $this->adapters[] = $adapter;
    }

    public function getNormalizedIdentifier(object $model): ?string
    {
        foreach ($this->adapters as $adapter) {
            $identifier = $adapter->getNormalizedIdentifier($model);

            if (null !== $identifier) {
                return $identifier;
            }
        }

        return null;
    }

    public function getUrlSafeIdentifier(object $model): ?string
    {
        foreach ($this->adapters as $adapter) {
            $safeIdentifier = $adapter->getUrlSafeIdentifier($model);

            if (null !== $safeIdentifier) {
                return $safeIdentifier;
            }
        }

        return null;
    }
}


text:
package org.b3log.symphony.repository;

import org.b3log.latke.repository.AbstractRepository;
import org.b3log.latke.repository.annotation.Repository;
import org.b3log.symphony.model.Product;

/**
 * Product repository.
 *
 * @author Liang Ding
 * @version 1.0.0.1, Feb 24, 2016
 * @since 1.4.0
 */
@Repository
public class ProductRepository extends AbstractRepository {

    /**
     * Public constructor.
     */
    public ProductRepository() {
        super(Product.PRODUCT);
    }
}


text:
Jenkins Dashboard in console

Draft - WIP

## Usage
```
go build && ./goJenkinsDashboard -logtostderr=true -stderrthreshold=INFO -jenkinsUrl=http://192.168.59.103:10000
```

Filter on jobs :
```

go build && ./goJenkinsDashboard -logtostderr=true -stderrthreshold=INFO -jenkinsUrl=http://192.168.59.103:10000 -filter=^job\[0-9\]$
```

Refreshing interval :
```

go build && ./goJenkinsDashboard -logtostderr=true -stderrthreshold=INFO -jenkinsUrl=http://192.168.59.103:10000 -interval=2s
```

see examples on filter on http://play.golang.org/p/Mpl-NThwrS

## Screenshot
![Go Jenkins Dashboard](goJenkinsDashboard.png)


text:
/*---------------JSHint---------------*/
/* global ForestEcosystem             */
/* global PubTest                     */
/*------------------------------------*/
'use strict';

(function() {

  // Create PubTest for ForestEcosystem
  var test = new PubTest('ForestEcosystem');
  var CONFIG = {
    // GridSimulation
    canvasID: 'imagination',
    gridRows: 25,
    gridCols: 25,
    delay: 125,

    // Starting population
    treeRatio: 0.5,
    lumberjackRatio: 0.10,
    bearRatio: 0.05,

    // Population control
    minMaul: 5,
    minLumber: 7,
  };

  // Test Case: clearList
  test.testCase(function() {
    var clearList = ForestEcosystem.prototype.clearList;
    var demoList = [1, 2, 3, 4, 5];

    test.assertEqual(demoList.length, 5,
      'length of demoList should be 5');

    clearList(demoList);

    test.assertEqual(demoList.length, 0,
      'length of demoList should be 0');
  });

  // Test Case: spawnForestLife
  test.testCase(function() {
    var forest = new ForestEcosystem(CONFIG);

    test.assertEqual(forest.population.tree.length, 0,
      'length of starting tree population should be 0');

    test.assertEqual(forest.population.lumberjack.length, 0,
      'length of starting lumberjack population should be 0');

    test.assertEqual(forest.population.bear.length, 0,
      'length of starting bear population should be 0');

    forest.spawnForestLife('sapling', 0, 0);
    forest.spawnForestLife('tree', 0, 1);
    forest.spawnForestLife('elder', 0, 2);
    forest.spawnForestLife('lumberjack', 1, 0);
    forest.spawnForestLife('bear', 1, 1);

    test.assertEqual(forest.population.tree.length, 3,
      'length of tree population should be 3');

    test.assertEqual(forest.population.lumberjack.length, 1,
      'length of lumberjack population should be 1');

    test.assertEqual(forest.population.bear.length, 1,
      'length of bear population should be 1');
  });

  // Test Case: removeForestLife
  test.testCase(function() {
    var forest = new ForestEcosystem(CONFIG);
    forest.spawnForestLife('sapling', 0, 0);
    forest.spawnForestLife('tree', 0, 1);
    forest.spawnForestLife('tree', 0, 2);
    forest.spawnForestLife('elder', 0, 3);
    forest.spawnForestLife('lumberjack', 1, 0);
    forest.spawnForestLife('lumberjack', 1, 1);
    forest.spawnForestLife('bear', 2, 0);
    forest.spawnForestLife('bear', 2, 1);

    test.assertEqual(forest.population.tree.length, 4,
      'length of tree population should be 4');

    test.assertEqual(forest.population.lumberjack.length, 2,
      'length of lumberjack population should be 2');

    test.assertEqual(forest.population.bear.length, 2,
      'length of bear population should be 2');

    test.assertEqual(forest.population.tree[0].type, 'sapling',
      'type of first element in tree population should be sapling');

    forest.removeForestLife(forest.population.tree[0], 0);
    forest.removeForestLife(forest.population.lumberjack[0], 0);
    forest.removeForestLife(forest.population.bear[0], 0);

    test.assertEqual(forest.population.tree.length, 3,
      'length of tree population should be 3');

    test.assertEqual(forest.population.lumberjack.length, 1,
      'length of lumberjack population should be 1');

    test.assertEqual(forest.population.bear.length, 1,
      'length of bear population should be 1');

    test.assertEqual(forest.population.tree[0].type, 'tree',
      'type of first element in tree population should be tree');

  });

  // Test Case: removeRandom
  test.testCase(function() {
    var forest = new ForestEcosystem(CONFIG);
    var jackPop = 5;
    for (var i=0; i<jackPop; i++) { forest.spawnRandom('lumberjack'); }

    test.assertEqual(forest.population.lumberjack.length, jackPop,
      'number of lumberjacks should be ' + jackPop);

    forest.removeRandom('lumberjack');
    jackPop--;

    test.assertEqual(forest.population.lumberjack.length, jackPop,
      'number of lumberjacks should be one less');
  });

  // Test Case: moveForestLife
  test.testCase(function() {
    var forest = new ForestEcosystem(CONFIG);
    forest.spawnForestLife('lumberjack', 2, 2);
    var lumberjack = forest.population.lumberjack[0];

    test.assertEqual(lumberjack.position[0], 2,
      'position x of lumberjack should be 2');

    test.assertEqual(lumberjack.position[1], 2,
      'position y of lumberjack should be 2');

    forest.moveForestLife(lumberjack);

    test.assert(lumberjack.position[0] !== 2 || lumberjack.position[1] !== 2,
      'position of lumberjack should have changed');

    test.assertRange(lumberjack.position[0], 1, 3,
      'position x of lumberjack should have only changed by at most 1');

    test.assertRange(lumberjack.position[1], 1, 3,
      'position y of lumberjack should have only changed by at most 1');
  });

  // Test Case: lumberTracking
  test.testCase(function() {
    var forest = new ForestEcosystem(CONFIG);

    // Case: lumberjack population at least 1 after lumberTracking
    test.assertEqual(forest.population.lumberjack.length, 0,
      'population of lumberjack should be 0');

    forest.lumberTracking();

    test.assertEqual(forest.population.lumberjack.length, 1,
      'population of lumberjack should have increased by 1');

    // Case: lay off 1 lumberjack if quota not met
    for (var i=0; i<5; i++) { forest.spawnRandom('lumberjack'); }
    forest.stats.lumber.year = 0;

    test.assertEqual(forest.population.lumberjack.length, 6,
      'population of lumberjack should be 6');

    forest.lumberTracking();
    test.assertEqual(forest.stats.lumber, 0,
      'number of lumber collected this year should be 0');

    test.assertEqual(forest.population.lumberjack.length, 5,
      'number of lumberjack should be one less due to layoff');

    // Case: more lumberjack hired if passes quota
    forest.stats.lumber = 200;
    forest.lumberTracking();

    test.assert(forest.population.lumberjack.length > 6,
      'population of lumberjack should be greater than 6');
  });

  // Test Case: maulTracking
  test.testCase(function() {
    var forest = new ForestEcosystem(CONFIG);
    for (var i=0; i<5; i++) {
      forest.spawnRandom('bear');
    }

    test.assertEqual(forest.population.bear.length, 5,
      'population of bear should be 5');

    // Case: bear should spawn if 0 mauls this year
    forest.stats.maul.year = 0;
    forest.maulTracking();

    test.assertEqual(forest.population.bear.length, 6,
      'population of bear should be 6');
  });

  // Report test results
  test.results();

})();


text:
ENV["RAILS_ENV"] ||= 'test'

require 'rspec'
require 'active_record'
require 'active_model'

# Configuring database for activerecord
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"

# Require test model
require 'test_model'

# Stubing Rails.cache method
class Rails
  def self.cache
   @@cache ||= ActiveSupport::Cache::MemoryStore.new(:expires_in => 5.minutes)
  end
end

# Configure RSpec
RSpec.configure do |config|
  # config.include Rack::Test::Methods
end


text:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Advobot.Resources {
    using System;

    /// <summary>
    ///   A strongly-typed resource class, for looking up localized strings, etc.
    /// </summary>
    // This class was auto-generated by the StronglyTypedResourceBuilder
    // class via a tool like ResGen or Visual Studio.
    // To add or remove a member, edit your .ResX file then rerun ResGen
    // with the /str option, or rebuild your VS project.
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    internal class BotSettingNames {

        private static global::System.Resources.ResourceManager resourceMan;

        private static global::System.Globalization.CultureInfo resourceCulture;

        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal BotSettingNames() {
        }

        /// <summary>
        ///   Returns the cached ResourceManager instance used by this class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Resources.ResourceManager ResourceManager {
            get {
                if (object.ReferenceEquals(resourceMan, null)) {
                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Advobot.Resources.BotSettingNames", typeof(BotSettingNames).Assembly);
                    resourceMan = temp;
                }
                return resourceMan;
            }
        }

        /// <summary>
        ///   Overrides the current thread's CurrentUICulture property for all
        ///   resource lookups using this strongly typed resource class.
        /// </summary>
        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
        internal static global::System.Globalization.CultureInfo Culture {
            get {
                return resourceCulture;
            }
            set {
                resourceCulture = value;
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Always Download Users.
        /// </summary>
        internal static string AlwaysDownloadUsers {
            get {
                return ResourceManager.GetString("AlwaysDownloadUsers", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Game.
        /// </summary>
        internal static string Game {
            get {
                return ResourceManager.GetString("Game", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Log Level.
        /// </summary>
        internal static string LogLevel {
            get {
                return ResourceManager.GetString("LogLevel", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Banned Names.
        /// </summary>
        internal static string MaxBannedNames {
            get {
                return ResourceManager.GetString("MaxBannedNames", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Banned Punishments.
        /// </summary>
        internal static string MaxBannedPunishments {
            get {
                return ResourceManager.GetString("MaxBannedPunishments", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Banned Regex.
        /// </summary>
        internal static string MaxBannedRegex {
            get {
                return ResourceManager.GetString("MaxBannedRegex", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Banned Strings.
        /// </summary>
        internal static string MaxBannedStrings {
            get {
                return ResourceManager.GetString("MaxBannedStrings", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Message Gather Size.
        /// </summary>
        internal static string MaxMessageGatherSize {
            get {
                return ResourceManager.GetString("MaxMessageGatherSize", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Quotes.
        /// </summary>
        internal static string MaxQuotes {
            get {
                return ResourceManager.GetString("MaxQuotes", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Rule Categories.
        /// </summary>
        internal static string MaxRuleCategories {
            get {
                return ResourceManager.GetString("MaxRuleCategories", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Rules Per Category.
        /// </summary>
        internal static string MaxRulesPerCategory {
            get {
                return ResourceManager.GetString("MaxRulesPerCategory", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max Self Assignable Role Groups.
        /// </summary>
        internal static string MaxSelfAssignableRoleGroups {
            get {
                return ResourceManager.GetString("MaxSelfAssignableRoleGroups", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Max User Gather Count.
        /// </summary>
        internal static string MaxUserGatherCount {
            get {
                return ResourceManager.GetString("MaxUserGatherCount", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Message Cache Size.
        /// </summary>
        internal static string MessageCacheSize {
            get {
                return ResourceManager.GetString("MessageCacheSize", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Prefix.
        /// </summary>
        internal static string Prefix {
            get {
                return ResourceManager.GetString("Prefix", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Stream.
        /// </summary>
        internal static string Stream {
            get {
                return ResourceManager.GetString("Stream", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Users Ignored From Commands.
        /// </summary>
        internal static string UsersIgnoredFromCommands {
            get {
                return ResourceManager.GetString("UsersIgnoredFromCommands", resourceCulture);
            }
        }

        /// <summary>
        ///   Looks up a localized string similar to Users Unable To Dm Owner.
        /// </summary>
        internal static string UsersUnableToDmOwner {
            get {
                return ResourceManager.GetString("UsersUnableToDmOwner", resourceCulture);
            }
        }
    }
}


text:
'use strict';

var hasGeneratorSupport = require( './../lib' );

var bool = hasGeneratorSupport();
if ( bool ) {
	console.log( 'Environment has native generator support.' );
} else {
	console.log( 'Environment lacks native generator support.' );
}


text:
function LevelComponents(canvas, config, level) {
    this.canvas = canvas;
    this.config = config;
    this.level = level;
    this.brush = canvas.getContext('2d');
}

LevelComponents.prototype.getView = function() {
    if(typeof this.view === 'undefined') {
        var renderRegion = new RenderRegion(0, this.canvas.height * .15, this.canvas.width, this.canvas.height * .85);
        this.view = new LevelView(this.brush, renderRegion, 2, '#FFFFFF', this.getCurrentLevel());
    } else {
        this.view.level = this.getCurrentLevel();
    }
    if(this.level.puzzle.original === 1) {
        var tutorialController = new TutorialViewController(this.view);
        this.view.onDraw = function() {
            tutorialController.draw();
        }.bind(this);
    } else {
        this.view.onDraw = function() {};
    }
    return this.view;
};

LevelComponents.prototype.getStatusBar = function(score) {
    var view = this.view;
    if(typeof this.statusBar === 'undefined') {
        var renderRegion = new RenderRegion(view.leftMargin + view.spacing, 0, (view.blockSize + view.spacing) * 4, this.canvas.height * .15);
        this.statusBar = new StatusBar(this.brush, renderRegion, view.blockSize / 3.75, score, this.getCurrentLevel());
    }
    this.statusBar.level = this.getCurrentLevel();
    return this.statusBar;
};

LevelComponents.prototype.getInputController = function() {
    if(typeof this.inputController === 'undefined') {
        this.inputController = new LevelInputController(this.getView());
    }
    return this.inputController;
};

LevelComponents.prototype.getCurrentLevel = function() {
    if(typeof this.currentLevel === 'undefined' || this.currentLevel !== this.level) {
        this.currentLevel = this.level;
    }
    return this.currentLevel;
};

LevelComponents.prototype.getInputListeners = function() {
    if(typeof this.inputListeners === 'undefined') {
        this.inputListeners = [
            new KeyboardInput(this.getInputController()),
            new TouchInput(this.getInputController(), this.canvas)
        ];
    }
    return this.inputListeners;
};

LevelComponents.prototype.attachInputListeners = function() {
    var inputListeners = this.getInputListeners();
    for(var i = 0; i < inputListeners.length; i += 1) {
        inputListeners[i].listen();
    }
};

LevelComponents.prototype.detachInputListeners = function() {
    var inputListeners = this.getInputListeners();
    for(var i = 0; i < inputListeners.length; i += 1) {
        inputListeners[i].detach();
    }
};

LevelComponents.prototype.getCompleteAnimation = function(score) {
    var currentLevel = this.getCurrentLevel();
    return new LevelCompleteAnimation(this.getView(), this.getStatusBar(), this.canvas, function() {
        var levelCompleteViewController = new LevelCompleteViewController(this.canvas, currentLevel, score, '#FFFFFF');
        levelCompleteViewController.draw();
    });
};

LevelComponents.prototype.setInputControllers = function(inputController) {
    var inputListeners = this.getInputListeners();
    for(var i = 0; i < inputListeners.length; i += 1) {
        inputListeners[i].inputController = inputController;
    }
    console.log(inputController);
    this.inputListeners = inputListeners;
};

LevelComponents.prototype.getCompleteInputController = function(storageManager, onSelect) {
    if(typeof this.completeInputController === 'undefined') {
        this.completeInputController = new LevelCompleteInputController(this.level.puzzle.original, storageManager, onSelect);
    } else {
        this.completeInputController.level = this.level.puzzle.original;
    }
    return this.completeInputController;
};


text:
SYNONYM

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Sp. pl. 2:994. 1753

#### Original name
null

### Remarks
null


text:
package ml.regression;

import la.matrix.DenseMatrix;
import la.matrix.Matrix;
import ml.options.Options;

import static ml.utils.Matlab.*;

/***
 * Abstract super class for all regression methods.
 *
 * @author Mingjie Qian
 * @version 1.0 Feb. 1st, 2014
 */
public abstract class Regression {

	/**
	 * Number of dependent variables.
	 */
	public int ny;

	/**
	 * Number of independent variables.
	 */
	public int p;

	/**
	 * Number of examples.
	 */
	public int n;

	/**
	 * Training data matrix (n x p) with each row being
	 * a data example.
	 */
	public Matrix X;

	/**
	 * Dependent variable matrix for training (n x ny).
	 */
	public Matrix Y;

	/**
	 * Unknown parameters represented as a matrix (p x ny).
	 */
	public Matrix W;

	/**
	 * Convergence tolerance.
	 */
	public double epsilon;

	/**
	 * Maximal number of iterations.
	 */
	public int maxIter;

	public Regression() {
		ny = 0;
		p = 0;
		n = 0;
		X = null;
		Y = null;
		W = null;
		epsilon = 1e-6;
		maxIter = 600;
	}

	public Regression(double epsilon) {
		ny = 0;
		p = 0;
		n = 0;
		X = null;
		Y = null;
		W = null;
		this.epsilon = epsilon;
		maxIter = 600;
	}

	public Regression(int maxIter, double epsilon) {
		ny = 0;
		p = 0;
		n = 0;
		X = null;
		Y = null;
		W = null;
		this.epsilon = epsilon;
		this.maxIter = maxIter;
	}

	public Regression(Options options) {
		ny = 0;
		p = 0;
		n = 0;
		X = null;
		Y = null;
		W = null;
		this.epsilon = options.epsilon;
		this.maxIter = options.maxIter;
	}

	/**
	 * Feed training data for the regression model.
	 *
	 * @param X data matrix with each row being a data example
	 */
	public void feedData(Matrix X) {
		this.X = X;
		p = X.getColumnDimension();
		n = X.getRowDimension();
		if (Y != null && X.getRowDimension() != Y.getRowDimension()) {
			System.err.println("The number of dependent variable vectors and " +
					"the number of data samples do not match!");
			System.exit(1);
		}
	}

	/**
	 * Feed training data for this regression model.
	 *
	 * @param data an n x d 2D {@code double} array with each
	 *             row being a data example
	 */
	public void feedData(double[][] data) {
		feedData(new DenseMatrix(data));
	}

	/**
	 * Feed training dependent variables for this regression model.
	 *
	 * @param Y dependent variable matrix for training with each row being
	 *          the dependent variable vector for each data training data
	 *          example
	 */
	public void feedDependentVariables(Matrix Y) {
		this.Y = Y;
		ny = Y.getColumnDimension();
		if (X != null && Y.getRowDimension() != n) {
			System.err.println("The number of dependent variable vectors and " +
					"the number of data samples do not match!");
			System.exit(1);
		}
	}

	/**
	 * Feed training dependent variables for this regression model.
	 *
	 * @param depVars an n x c 2D {@code double} array
	 *
	 */
	public void feedDependentVariables(double[][] depVars) {
		feedDependentVariables(new DenseMatrix(depVars));
	}

	/**
	 * Train the regression model.
	 */
	public abstract void train();

	/**
	 * Train the regression model given initial weight matrix W0.
	 *
	 * @param W0 initial weight matrix (p x ny)
	 */
	public abstract void train(Matrix W0);

	/**
	 * Train the regression model given independent variable matrix
	 * X and dependent variable matrix Y.
	 *
	 * @param X independent variable matrix (n x p)
	 *
	 * @param Y dependent variable matrix (n x ny)
	 *
	 * @return weight matrix (p x ny)
	 */
	public abstract Matrix train(Matrix X, Matrix Y);

	/**
	 * Train the regression model given independent variable matrix
	 * X, dependent variable matrix Y and the initial weight matrix
	 * W0.
	 *
	 * @param X independent variable matrix (n x p)
	 *
	 * @param Y dependent variable matrix (n x ny)
	 *
	 * @param W0 initial weight matrix (p x ny)
	 *
	 * @return weight matrix (p x ny)
	 */
	public abstract Matrix train(Matrix X, Matrix Y, Matrix W0);

	/**
	 * Predict the dependent variables for test data Xt.
	 *
	 * @param Xt test data matrix with each row being a
	 *           data example.
	 *
	 * @return dependent variables for Xt
	 *
	 */
	public Matrix predict(Matrix Xt) {
		if (Xt.getColumnDimension() != p) {
			System.err.println("Dimensionality of the test data " +
					"doesn't match with the training data!");
			System.exit(1);
		}
		if (this instanceof LinearRegression) {
			return Xt.mtimes(W).plus(repmat(new DenseMatrix(((LinearRegression) this).B, 2), 3, 1));
		} else {
			return Xt.mtimes(W);
		}
	}

	/**
	 * Predict the dependent variables for test data Xt.
	 *
	 * @param Xt an n x d 2D {@code double} array with each
	 *           row being a data example
	 *
	 * @return dependent variables for Xt
	 *
	 */
	public Matrix predict(double[][] Xt) {
		return predict(new DenseMatrix(Xt));
	}

	public abstract void loadModel(String filePath);

	public abstract void saveModel(String filePath);

}


text:
package com.puppycrawl.tools.checkstyle.checks.usage.transmogrify;

public class AnonymousInnerClass extends ClassDef {

  protected SymTabAST _objblock;
  protected SymTabAST _classExtended;

  public AnonymousInnerClass(SymTabAST objblock,
                             SymTabAST classExtended,
                             Scope parentScope) {
    super(parentScope.getName() + "$" + parentScope.getEnclosingClass().getNextAnonymousId(),
          parentScope,
          objblock);

    _objblock = objblock;
    _classExtended = classExtended;
  }

  public void finishMakingDefinition() {
    if (_classExtended != null) {
        String extendedClassName = ASTUtil.constructDottedName(_classExtended);
        IClass superclass = getClassDefinition(extendedClassName);

        if (superclass != null) {
          setSuperclass(superclass);
          superclass.addSubclass(this);
        }
    }
  }

}


text:
function battle.attack(atk)
   local bm = pb.getBattleMenu()

   -- TODO: check if the attack is unlocked and has enough PPs
   if bm:getMenu() ~= 0 then return -1 end

   misc.moveCursor(2, 2, 0, function() return bm:getCursor() end)
   while bm:getMenu() == 0 do
      misc.pressButton(btn.a)
   end
   misc.moveCursor(2, 2, atk, function() return bm:getAttack() end)
   while bm:isOpen() == 1 do
      misc.pressButton(btn.a)
   end
end


text:
package edu.cmu.minorthird.ui;

/**
 * Defines the list of classes that can be selected by an instance of UIMain.
 */

public class AdvancedParameters{

	public static final String[] NAMES=new String[]{
					// bunches of parameters
					"repositoryKey",
					"testKey",
					//"candidateType",
					//"spanProp",
					"showTestDetails",
					"embeddedAnnotators",
					"featureExtractor",
					"mixup",
					"showData",
					// advanced help buttons
					//"spanPropHelp",
					//"candidateTypeHelp",
					"showDataHelp",
					"embeddedAnnotatorsHelp",
					"feHelp",
					"mixupHelp",
					"showTestDetailsHelp",
					"trainTestClassifierHelp",
					"featureExtractorHelp"
					};
}


text:
from django.conf.urls import url

from rpc4django.views import serve_rpc_request

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = [
    # Example:
    # (r'^example/', include('example.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # (r'^admin/(.*)', admin.site.root),
    url('^$', serve_rpc_request),
    url('^RPC2$', serve_rpc_request),
]


text:
package com.nick.scalpel.core.hook;

import com.nick.scalpel.Scalpel;
import com.nick.scalpel.core.Publishable;

public class Hooks implements Publishable {

    private Hooks() {
        // Noop.
    }

    public static void publishTo(Scalpel scalpel) {
        new Hooks().publish(scalpel);
    }

    @Override
    public void publish(Scalpel scalpel) {
        new RequireRootWirer(scalpel.getConfiguration(), new ChrisRootRequester()).publish(scalpel);
    }
}


text:
<?php
/**
 * Set the content width based on the theme's design and stylesheet.
 */
if (! isset( $content_width)) {
    $content_width = 740; /* pixels */
}

if (! function_exists('silencio_setup')) {
    function silencio_setup() {
        require_once(dirname(__FILE__) . '/res/functions/admin.php');
        require(get_template_directory() . '/res/functions/template-tags.php');
        require(get_template_directory() . '/res/functions/shortcodes.php');
        require(get_template_directory() . '/res/functions/widgets.php');
        require(get_template_directory() . '/res/functions/excerpts.php');
        require(get_template_directory() . '/res/functions/tinymce.php');
        require(get_template_directory() . '/res/functions/users.php');
        require(get_template_directory() . '/res/functions/metaboxes.php');
        require(get_template_directory() . '/res/functions/jetpack.php');
        require(get_template_directory() . '/res/functions/post-types.php');
        require(get_template_directory() . '/res/functions/wp_bootstrap_navwalker.php');
        // require( get_template_directory() . '/res/functions/taxonomies.php');

        add_theme_support('automatic-feed-links');
        add_theme_support('post-thumbnails');

        register_nav_menu('primary', __('Primary Menu', 'silencio'));
        register_nav_menu( 'footer-menu', __( 'Footer Menu', 'silencio' ) );
    }
}

add_action('after_setup_theme', 'silencio_setup');

// Custom Thumbnail Sizes
if (function_exists('add_image_size')) {
    add_image_size('blog-thumb', 300, 300, true); //(cropped)
    add_image_size('flavor-thumb', 300, 300, true); //(cropped)
    add_image_size('header-thumb', 1170, 400, true); //(cropped)
}

/**
 * Enqueue scripts and styles
 */
function silencio_scripts() {
    if (!is_admin() && DEV_ENVIRONMENT == 'local') {
        wp_deregister_script('jquery');
        wp_register_script('jquery', ("//code.jquery.com/jquery-1.10.2.js"), false, '1.8.2', true);
        wp_enqueue_script('jquery');

        // Enqueue 3rd party libs
        wp_enqueue_script('bootstrap', get_template_directory_uri() . '/res/js/bootstrap.js', array('jquery'), false, true);
        wp_enqueue_script('fitvids', get_template_directory_uri() . '/res/js/fitvids.js', array('jquery'), false, true);
        wp_enqueue_script('google.fastbutton', get_template_directory_uri() . '/res/js/google.fastbutton.js', array('jquery'), false, true);
        wp_enqueue_script('jquery.google.fastbutton', get_template_directory_uri() . '/res/js/jquery.google.fastbutton.js', array('jquery'), false, true);
    } elseif (!is_admin()) {
        wp_deregister_script('jquery');
        wp_register_script('jquery', ("//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"), false, '1.8.2', true);
        wp_enqueue_script('jquery');
    }

    // Disable this environment check & load min.css if you want to test in IE8 with respond.js
    if (DEV_ENVIRONMENT == 'local') {
        $global = 'js/global.js';
        $style = 'css/global.css';
    } else {
        $global = 'build/global.min.js';
        $style = 'build/global.min.css';
    }

    /*
     * If VIA_DEPLOYMENT is defined, contents are appended to bust client-side caches.
     * If it's not defined, fall back to file modified time.
     */
    wp_enqueue_script(
        'global',
        get_template_directory_uri() . '/res/' . $global,
        array('jquery'),
        defined('VIA_DEPLOYMENT') ? VIA_DEPLOYMENT : filemtime(get_stylesheet_directory() . '/res/' . $global),
        true
    );

    wp_register_style(
        'via-style',
        get_template_directory_uri() . '/res/' . $style,
        array(),
        defined('VIA_DEPLOYMENT') ? VIA_DEPLOYMENT : filemtime(get_stylesheet_directory() . '/res/' . $style),
        'all'
    );

    // enqueing:
    wp_enqueue_style('via-style');

    if (is_singular() && comments_open() && get_option('thread_comments')) {
        wp_enqueue_script('comment-reply');
    }
}

add_action('wp_enqueue_scripts', 'silencio_scripts');

/**
 * Add oEmbed support for widgets
 */
add_filter('widget_text', array($wp_embed, 'run_shortcode'), 8);
add_filter('widget_text', array($wp_embed, 'autoembed'), 8);

/**
 * Register widgetized area and update sidebar with default widgets
 */
function silencio_widgets_init() {

    register_sidebar(array(
        'name' => __('Home Sidebar', 'silencio'),
        'id' => 'home-sidebar',
        'before_widget' => '',
        'after_widget' => "",
        'before_title' => '
',
        'after_title' => '
'
    ));
}

add_action('widgets_init', 'silencio_widgets_init');

/**
 * Fix Uncaught Reference Error from Gravity Forms - Puts js call in the footer, where it should be.
 */
add_filter("gform_init_scripts_footer", "init_scripts");
function init_scripts() {
    return true;
}

/*
 * Registering Theme Options:
 */
require_once('res/functions/silencio-theme-settings-basic.php');

/*
 * Takes our theme option's location info and produces a maps link appropriate to the user's device.
 * @return string URL to appropriate maps service.
 */
function silencio_build_directions_url($street, $city, $state, $zip) {
    // Format our address for URLs
    $address = str_replace(' ', '+', implode('+', array($street, $city, $state, $zip))); // replaces all spaces w/ +

    // Check UA to see if this is an iPhone
    $is_iOS = strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone');

    // If yes, parse out the version of iOS
    if ($is_iOS !== false) {
        $results = array();
        preg_match('/iPhone OS (\d+)_(\d+)\s+/', $_SERVER['HTTP_USER_AGENT'], $results);
        $iOS_version = $results[1] . '.' . $results[2];
    }

    // Serve up an Apple Maps link if on an iOS 6 device, otherwise serve up a Google Maps link.
    if (isset($iOS_version) && $iOS_version >= 6) {
        return "https://maps.apple.com/maps?q=" . $address;
    } else {
        return "https://maps.google.com/maps?q=" . $address;
    }
}

/*
* Helper function for debugging variables
*
*/
if (!function_exists('debug')) {
    function debug($var) {
        $bt = debug_backtrace();
        $caller = array_shift($bt);

        echo '
' . basename($caller['file']) . ' - Line: ' . $caller['line'] . '
';
        echo '
';
        var_dump($var);
        echo '
';
    }
}


text:
  <?= $this->session->flashdata('alert') ?>

Associados

                <a class="btn btn-success" href="<?= base_url('associated/new') ?>">
                   Cadastrar Associado

                <a class="btn btn-success" href="<?= base_url('associated/printAssociated') ?>">
                   Imprimir Envelopes

                <form method="GET" action="<?=base_url('associated/search')?>" class="form-inline">

                        <input type="text" class="form-control"
                        name="q"
                        value="<?=set_value('search', isset($search) ? $search : '')?>"
                        placeholder="Buscar">

                            <button type="submit" class="btn btn-info">

                            </button>

                        <?php if(isset($search)) { ?>

                              <a href="<?=base_url('associated')?>" class="btn btn-danger">

                        <?php } ?>

                </form>

    <?= $this->session->flashdata('alert') ?>

          Código Único
          Nome
          Data Nascimento
          RG
          CPF

          Ações

        <?php foreach($associated as $associate): ?>

          <a href="<?=base_url('associated-detail/'. $associate->id_associate)?>"><?= $associate->uuid_associate ?>
          <?= $associate->name_associate ?>
          <?= date_format(date_create($associate->birth_date), 'd/m/y')?>
          <?= $associate->rg ?>
          <?= $associate->cpf ?>
          <?php if($associate->disable == 1){ echo 'Inativo'; } ?>

              <a class="btn btn-info btn-sm" href="<?= base_url('associated-detail/'. $associate->id_associate) ?>">
              <a class="btn btn-primary btn-sm" href="<?= base_url('associated/edit/'. $associate->id_associate) ?>">
              <a class="btn btn-warning btn-sm" href="<?= base_url('associated/'. $associate->id_associate .'/collections') ?>">

      <?php endforeach; ?>

            <?= $pagination ?>


text:
/* Nog aan te passen: begin van de maand */
SELECT  YEAR(CreatedOnDate) AS TheYear ,
        MONTH(CreatedOnDate) AS TheMonth ,
        COUNT(UserID) AS NbrOfRegistrations
FROM    {databaseOwner}[{objectQualifier}Users]
WHERE   CreatedOnDate > ( GETDATE() - 365 )
GROUP BY YEAR(CreatedOnDate) ,
        MONTH(CreatedOnDate)
ORDER BY TheYear DESC ,
        TheMonth DESC

SELECT  YEAR(CreatedOnDate) AS TheYear ,
        MONTH(CreatedOnDate) AS TheMonth ,
        DAY(CreatedOnDate) AS TheDay ,
        COUNT(UserID) AS NbrOfRegistrations
FROM    {databaseOwner}[{objectQualifier}Users]
WHERE   CreatedOnDate > ( GETDATE() - 30 )
GROUP BY YEAR(CreatedOnDate) ,
        MONTH(CreatedOnDate) ,
        DAY(CreatedOnDate)
ORDER BY TheYear DESC ,
        TheMonth DESC ,
        TheDay DESC

SELECT  YEAR(CreatedOnDate) AS TheYear ,
        COUNT(UserID) AS NbrOfRegistrations
FROM    {databaseOwner}[{objectQualifier}Users]
GROUP BY YEAR(CreatedOnDate)
ORDER BY TheYear DESC

/* Met cumulatieven */
SELECT  YEAR(d.CreatedOnDate) as TheYear,
        COUNT(f.UserID) Registrations ,
        COUNT(f.UserID)
        + COALESCE(( SELECT COUNT(dd.UserID)
                     FROM   {databaseOwner}[{objectQualifier}Users] fs
                            JOIN {databaseOwner}[{objectQualifier}Users] dd ON fs.UserID = dd.UserID
                     WHERE  YEAR(dd.CreatedOnDate) < YEAR(d.CreatedOnDate)
                   ), 0) CumRegistrations
FROM    {databaseOwner}[{objectQualifier}Users] f
        INNER JOIN {databaseOwner}[{objectQualifier}Users] d ON f.UserID = d.UserID
GROUP BY YEAR(d.CreatedOnDate)
ORDER BY YEAR(d.CreatedOnDate) DESC


text:
<?php

namespace dlds\thepay\api\dataApi\responses;

use dlds\thepay\api\dataApi\parameters\TpDataApiPayment;
use dlds\thepay\api\dataApi\TpValueFormatter;

class TpDataApiGetPaymentResponse extends TpDataApiResponse
{

    protected static $dateTimePaths = array(
        array('payment', 'createdOn'),
        array('payment', 'finishedOn'),
        array('payment', 'canceledOn')
    );

    /**
     * @var TpDataApiPayment|null
     */
    protected $payment;

    /**
     * @param array $response
     * @return TpDataApiGetPaymentResponse
     */
    public static function createFromResponse(array $response)
    {
        /** @var TpDataApiGetPaymentResponse $instance */
        $instance = parent::createFromResponse($response);

        $payment = new TpDataApiPayment($response['payment']);
        $instance->setPayment($payment);

        return $instance;
    }

    /**
     * @return TpDataApiPayment|null
     */
    public function getPayment()
    {
        return $this->payment;
    }

    /**
     * @param TpDataApiPayment|null $payment
     */
    public function setPayment(TpDataApiPayment $payment = null)
    {
        $this->payment = TpValueFormatter::format('TpDataApiPayment', $payment);
    }

}


text:
<!DOCTYPE html>

  <title>Connected Components</title>

  <link rel="stylesheet" href="../../JSAV/css/JSAV.css" type="text/css" />
  <link rel="stylesheet" href="../../lib/odsaStyle-min.css" type="text/css" />

    <var id="JSAV">initJSAV()</var>

        How many connected components does this graph have?

<var>"3"</var>

<var>"1"</var>

<var>"2"</var>

<var>"4"</var>

<var>"undetermined"</var>

The maximally connected subgraphs of an undirected graph are called connected components.

 Vertices 0, 1, 2, 3, and 4 form one connnected component


text:
Creating a framework as a study for learning new tools, tdd and solid
phpspec desc Fitz/Application
phpspec desc Fitz/Config/ConfigClass
phpspec run