Skip to content

Commit

Permalink
Merge pull request #93 from DIncalciLab/add-plot-name
Browse files Browse the repository at this point in the history
Allow adding the plot name to the genome plots
  • Loading branch information
matthdsm authored Sep 7, 2022
2 parents 98a3678 + be82584 commit ad25dce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions wisecondorX/include/plotter.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ options(warn=-1)
args <- commandArgs(T)
in.file <- paste0(args[which(args == "--infile")+1])


# -----
# lib
# -----
Expand All @@ -29,6 +30,7 @@ gender = input$ref_gender
beta = as.numeric(input$beta)
zcutoff = as.numeric(input$zscore)
ylim = input$ylim
plot.title = input$plot_title

if (input$cairo) options(bitmaptype='cairo')

Expand Down Expand Up @@ -209,6 +211,12 @@ legend(x=0,
cex=1.3, bty="n", pch=c(16,16), col=c(color.C, color.B, "white"))
par(xpd=F)

if (!is.null(plot.title)) {
par(xpd=NA)
title(plot.title, line=1.3, adj=0.8, col.main=color.A)
par(xpd=F)
}

# plot segmentation

for (ab in input$results_c){
Expand Down Expand Up @@ -278,7 +286,7 @@ for (c in chrs){
if (any(is.na(whis))){
next
}

png(paste0(out.dir, "/", labels[c],".png"), width=14,height=10,units="in",res=256,pointsize=18)

upper.limit <- 0.6 + whis[2]
Expand All @@ -289,7 +297,7 @@ for (c in chrs){
lower.limit = ylim[1] ; upper.limit = ylim[2]
}
par(mar=c(2.5,4,1,0), mgp=c(2.4,0.5,0))

plot(1, main="", axes=F, # plots nothing -- enables segments function
xlab="", ylab="", cex=0, ylim=c(lower.limit,upper.limit), xlim=margins)

Expand Down
3 changes: 3 additions & 0 deletions wisecondorX/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ def main():
parser_test.add_argument('--cairo',
action='store_true',
help='Uses cairo bitmap type for plotting. Might be necessary for certain setups.')
parser_test.add_argument("--add-plot-title",
action="store_true",
help="Add the output name as plot title")
parser_test.set_defaults(func=tool_test)

args = parser.parse_args(sys.argv[1:])
Expand Down
6 changes: 6 additions & 0 deletions wisecondorX/predict_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def exec_write_plots(rem_input, results):
'infile': str('{}.json'.format(json_plot_dir)),
'out_dir': str('{}.plots'.format(rem_input['args'].outid)),
}

if rem_input["args"].add_plot_title:
# Strip away paths from the outid if need be
json_dict["plot_title"] = str(
os.path.basename(rem_input["args"].outid))

exec_R(json_dict)


Expand Down

0 comments on commit ad25dce

Please sign in to comment.