Skip to content
Snippets Groups Projects
Commit 4cd2f2d5 authored by bow's avatar bow
Browse files

Add templates for plotting scripts and their wrappers

parent b660ab1c
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env Rscript
#
# Script for plotting heatmap for the Gentrap pipeline
# General function to install package if it does not exist
# Otherwise, it only loads the package
usePackage <- function(p) {
r <- getOption("repos")
r["CRAN"] <- "http://cran.us.r-project.org"
options(repos = r)
rm(r)
if (!is.element(p, installed.packages()[,1]))
install.packages(p, dep = TRUE)
require(p, character.only = TRUE)
}
usePackage("getopt")
usePackage("edgeR")
usePackage("ggplot2")
usePackage("gplots")
usePackage("grid")
usePackage("jsonlite")
usePackage("reshape2")
usePackage("MASS")
usePackage("RColorBrewer")
# create spec for arg parsing
spec <- matrix(c(
# input table (merge of all samples)
'input-table', 'I', 1, 'character',
# output plot file
'output-plot', 'O', 1, 'character',
# perform TMM-normalization (only if we are dealing with count data)
'tmm-normalize', 'T', 0, 'logical'
# help
'help', 'H', 0, 'logical'
), byrow=TRUE, ncol=4)
opt <- getopt(spec)
# print help if requested
if (!is.null(opt[['help']])) {
cat(getopt(spec, usage=TRUE))
q(status=1)
}
#!/usr/bin/env Rscript
#
# Script for plotting PCA plots for the Gentrap pipeline
# General function to install package if it does not exist
# Otherwise, it only loads the package
usePackage <- function(p) {
r <- getOption("repos")
r["CRAN"] <- "http://cran.us.r-project.org"
options(repos = r)
rm(r)
if (!is.element(p, installed.packages()[,1]))
install.packages(p, dep = TRUE)
require(p, character.only = TRUE)
}
usePackage("getopt")
usePackage("edgeR")
usePackage("ggplot2")
usePackage("gplots")
usePackage("grid")
usePackage("jsonlite")
usePackage("reshape2")
usePackage("MASS")
usePackage("RColorBrewer")
# create spec for arg parsing
spec <- matrix(c(
# input table (merge of all samples)
'input-table', 'I', 1, 'character',
# output plot file
'output-plot', 'O', 1, 'character',
# perform TMM-normalization (only if we are dealing with count data)
'tmm-normalize', 'T', 0, 'logical'
# help
'help', 'H', 0, 'logical'
), byrow=TRUE, ncol=4)
opt <- getopt(spec)
# print help if requested
if (!is.null(opt[['help']])) {
cat(getopt(spec, usage=TRUE))
q(status=1)
}
/**
* Copyright (c) 2014 Leiden University Medical Center
*
* @author Wibowo Arindrarto
*/
package nl.lumc.sasc.biopet.pipelines.gentrap.scripts
import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.extensions.RScriptCommandLineFunction
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
/**
* Wrapper for the plot_heatmap.R script, used internally in Gentrap
*/
class PlotHeatmap(val root: Configurable) extends RScriptCommandLineFunction {
setRScript("plot_heatmap.R", "/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/")
@Input(doc = "Input table", required = true)
var input: File = null
@Output(doc = "Output plot", required = false)
var output: File = null
var tmmNormalize: Boolean = config("tmm_normalize", default = false)
def cmdLine = {
RScriptCommand +
conditional(tmmNormalize, "-T") +
required("-I", input) +
required("-O", output)
}
}
/**
* Copyright (c) 2014 Leiden University Medical Center
*
* @author Wibowo Arindrarto
*/
package nl.lumc.sasc.biopet.pipelines.gentrap.scripts
import java.io.File
import nl.lumc.sasc.biopet.core.config.Configurable
import nl.lumc.sasc.biopet.extensions.RScriptCommandLineFunction
import org.broadinstitute.gatk.utils.commandline.{ Input, Output }
/**
* Wrapper for the plot_pca.R script, used internally in Gentrap
*/
class PlotPca(val root: Configurable) extends RScriptCommandLineFunction {
setRScript("plot_pca.R", "/nl/lumc/sasc/biopet/pipelines/gentrap/scripts/")
@Input(doc = "Input table", required = true)
var input: File = null
@Output(doc = "Output plot", required = false)
var output: File = null
var tmmNormalize: Boolean = config("tmm_normalize", default = false)
def cmdLine = {
RScriptCommand +
conditional(tmmNormalize, "-T") +
required("-I", input) +
required("-O", output)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment