Commit 18a44662 authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Added a scatter plot

parent 00d79a41
library(reshape2)
library(ggplot2)
library(argparse)
parser <- ArgumentParser(description='Process some integers')
parser$add_argument('--input', dest='input', type='character', help='Input tsv file', required=TRUE)
parser$add_argument('--output', dest='output', type='character', help='Output png file', required=TRUE)
parser$add_argument('--width', dest='width', type='integer', default = 500)
parser$add_argument('--height', dest='height', type='integer', default = 500)
parser$add_argument('--xlabel', dest='xlabel', type='character')
parser$add_argument('--ylabel', dest='ylabel', type='character', required=TRUE)
parser$add_argument('--llabel', dest='llabel', type='character')
parser$add_argument('--title', dest='title', type='character')
parser$add_argument('--removeZero', dest='removeZero', type='character', default="false")
arguments <- parser$parse_args()
png(filename = arguments$output, width = arguments$width, height = arguments$height)
DF <- read.table(arguments$input, header=TRUE)
if (is.null(arguments$xlabel)) xlab <- colnames(DF)[1] else xlab <- arguments$xlabel
colnames(DF)[1] <- "Rank"
DF1 <- melt(DF, id.var="Rank")
if (arguments$removeZero == "true") DF1 <- DF1[DF1$value > 0, ]
if (arguments$removeZero == "true") print("Removed 0 values")
ggplot(DF1, aes(x = Rank, y = value, group = variable, color = variable)) +
xlab(xlab) +
ylab(arguments$ylabel) +
guides(fill=guide_legend(title=arguments$llabel)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 8)) +
ggtitle(arguments$title) +
theme_bw() +
geom_point()
dev.off()
/**
* Biopet is built on top of GATK Queue for building bioinformatic
* pipelines. It is mainly intended to support LUMC SHARK cluster which is running
* SGE. But other types of HPC that are supported by GATK Queue (such as PBS)
* should also be able to execute Biopet tools and pipelines.
*
* Copyright 2014 Sequencing Analysis Support Core - Leiden University Medical Center
*
* Contact us at: sasc@lumc.nl
*
* A dual licensing mode is applied. The source code within this project that are
* not part of GATK Queue is freely available for non-commercial use under an AGPL
* license; For commercial users or users who do not want to follow the AGPL
* license, please contact us to obtain a separate license.
*/
package nl.lumc.sasc.biopet.extensions.rscript
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}
/**
* Extension for en general line plot with R
*
* Created by pjvan_thof on 4/29/15.
*/
class ScatterPlot(val root: Configurable) extends RscriptCommandLineFunction {
protected var script: File = config("script", default = "plotScatter.R")
@Input
var input: File = _
@Output
var output: File = _
var width: Option[Int] = config("width")
var height: Option[Int] = config("height")
var xlabel: Option[String] = config("xlabel")
var ylabel: Option[String] = config("ylabel")
var llabel: Option[String] = config("llabel")
var title: Option[String] = config("title")
var removeZero: Boolean = config("removeZero", default = false)
override def cmdLine: String = super.cmdLine +
required("--input", input) +
required("--output", output) +
optional("--width", width) +
optional("--height", height) +
optional("--xlabel", xlabel) +
required("--ylabel", ylabel) +
optional("--llabel", llabel) +
optional("--title", title) +
optional("--removeZero", removeZero)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment