From e63bce757d43868d1072c4c8e9d62b93e9bc8e6f Mon Sep 17 00:00:00 2001
From: james94 <james94@mi.fu-berlin.de>
Date: Thu, 11 Mar 2021 14:39:33 +0100
Subject: [PATCH] fix X11 display error

---
 envs/merylMerq.yaml                         |  1 +
 programs/merqury-1.1/plot/plot_spectra_cn.R | 12 +++++-------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/envs/merylMerq.yaml b/envs/merylMerq.yaml
index 96c6aed..d4f79ed 100644
--- a/envs/merylMerq.yaml
+++ b/envs/merylMerq.yaml
@@ -5,6 +5,7 @@ dependencies:
   - igvtools
   - openjdk=11.0.8
   - r-base=3.6.3
+  - cairo=1.16.0
   - r-ggplot2
   - r-argparse
   - r-scales
diff --git a/programs/merqury-1.1/plot/plot_spectra_cn.R b/programs/merqury-1.1/plot/plot_spectra_cn.R
index 2dd4757..f7153e3 100755
--- a/programs/merqury-1.1/plot/plot_spectra_cn.R
+++ b/programs/merqury-1.1/plot/plot_spectra_cn.R
@@ -133,14 +133,14 @@ plot_stack <- function(dat, name, x_max, y_max, zero, cutoff) {
 }
 
 save_plot <- function(name, type, outformat, h, w) {
-  ggsave(file = paste(name, type, outformat, sep = "."), height = h, width = w)
+  ggsave(file = paste(name, type, outformat, sep = "."), type = c("cairo", "cairo-png", "Xlib", "quartz"), height = h, width = w)
 }
 
 spectra_cn_plot  <-  function(hist, name, zero="", cutoff="", w=6, h=4.5, x_max, y_max, type="all", pdf=FALSE) {
   # Read hist
   dat=read.table(hist, header=TRUE)
   dat[,1]=factor(dat[,1], levels=unique(dat[,1]), ordered=TRUE) # Lock in the order
-  
+
   # Read asm-only
   dat_0 = NULL
   if (zero != "") {
@@ -180,19 +180,19 @@ spectra_cn_plot  <-  function(hist, name, zero="", cutoff="", w=6, h=4.5, x_max,
   if (pdf) {
     outformat="pdf"
   }
-  
+
   if (type == "all" || type == "line") {
     print("## Line graph")
     plot_line(dat, name, x_max, y_max, zero = dat_0, cutoff = dat_cut)
     save_plot(name=name, type="ln", outformat, h=h, w=w)
   }
-  
+
   if (type == "all" || type == "fill") {
     print("## Area under the curve filled")
     plot_fill(dat, name, x_max, y_max, zero = dat_0, cutoff = dat_cut)
     save_plot(name=name, type="fl", outformat, h=h, w=w)
   }
-  
+
   if (type == "all" || type == "stack") {
     print("## Stacked")
     plot_stack(dat, name, x_max, y_max, zero = dat_0, cutoff = dat_cut)
@@ -201,5 +201,3 @@ spectra_cn_plot  <-  function(hist, name, zero="", cutoff="", w=6, h=4.5, x_max,
 }
 
 spectra_cn_plot(hist = args$file, name = args$output, zero = args$zero, cutoff = args$cutoff, h = args$ydim, w = args$xdim, x_max = args$xmax, y_max = args$ymax, type = args$type, pdf = args$pdf)
-
-
-- 
GitLab