Commit 412fbccb authored by Peter van 't Hof's avatar Peter van 't Hof
Browse files

Simplify lineplot code

parent e2f5ad58
...@@ -237,15 +237,11 @@ object BammetricsReport extends ReportBuilder { ...@@ -237,15 +237,11 @@ object BammetricsReport extends ReportBuilder {
tsvWriter.close() tsvWriter.close()
val plot = new LinePlot(null) LinePlot(tsvFile, outputDir,
plot.input = tsvFile xlabel = Some("Insert size"),
plot.output = pngFile ylabel = Some("Reads"),
plot.ylabel = Some("Reads") title = Some("Insert size"),
plot.xlabel = Some("Insert size") removeZero = true).runLocal()
plot.width = Some(1200)
plot.removeZero = true
plot.title = Some("Insert size")
plot.runLocal()
} }
/** /**
...@@ -328,15 +324,11 @@ object BammetricsReport extends ReportBuilder { ...@@ -328,15 +324,11 @@ object BammetricsReport extends ReportBuilder {
tsvWriter.close() tsvWriter.close()
val plot = new LinePlot(null) LinePlot(tsvFile, outputDir,
plot.input = tsvFile xlabel = Some("Coverage"),
plot.output = pngFile ylabel = Some("Bases"),
plot.ylabel = Some("Bases") title = Some("Whole genome coverage"),
plot.xlabel = Some("Coverage") removeZero = true).runLocal()
plot.width = Some(1200)
plot.removeZero = true
plot.title = Some("Whole genome coverage")
plot.runLocal()
} }
/** /**
...@@ -419,14 +411,10 @@ object BammetricsReport extends ReportBuilder { ...@@ -419,14 +411,10 @@ object BammetricsReport extends ReportBuilder {
tsvWriter.close() tsvWriter.close()
val plot = new LinePlot(null) LinePlot(tsvFile, outputDir,
plot.input = tsvFile xlabel = Some("Relative position"),
plot.output = pngFile ylabel = Some("Coverage"),
plot.xlabel = Some("Relative position") title = Some("Rna coverage"),
plot.ylabel = Some("Coverage") removeZero = true).runLocal()
plot.width = Some(1200)
plot.removeZero = true
plot.title = Some("Rna coverage")
plot.runLocal()
} }
} }
...@@ -49,3 +49,24 @@ class LinePlot(val root: Configurable) extends Rscript { ...@@ -49,3 +49,24 @@ class LinePlot(val root: Configurable) extends Rscript {
title.map(Seq("--title", _)).getOrElse(Seq()) ++ title.map(Seq("--title", _)).getOrElse(Seq()) ++
(if (removeZero) Seq("--removeZero", "true") else Seq()) (if (removeZero) Seq("--removeZero", "true") else Seq())
} }
object LinePlot {
def apply(inputTsv: File,
outputFile: File,
root: Configurable = null,
xlabel: Option[String] = None,
ylabel: Option[String] = None,
width: Int = 1200,
removeZero: Boolean = false,
title: Option[String] = None): LinePlot = {
val plot = new LinePlot(root)
plot.input = inputTsv
plot.output = outputFile
plot.xlabel = xlabel
plot.ylabel = ylabel
plot.width = Some(width)
plot.removeZero = removeZero
plot.title = title
plot
}
}
\ No newline at end of file
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