From fb5615db4f93b97bf34aed73a97a1d20f92a744f Mon Sep 17 00:00:00 2001 From: Matthias De Smet <11850640+matthdsm@users.noreply.github.com> Date: Fri, 3 Feb 2023 12:07:13 +0100 Subject: [PATCH] add seed arg for DNAcopy (#101) * add seed arg for DNAcopy * lint code with black --- wisecondorX/include/CBS.R | 4 ++++ wisecondorX/main.py | 3 +++ wisecondorX/predict_tools.py | 1 + 3 files changed, 8 insertions(+) mode change 100755 => 100644 wisecondorX/main.py diff --git a/wisecondorX/include/CBS.R b/wisecondorX/include/CBS.R index 6f4de52..fe25cf9 100644 --- a/wisecondorX/include/CBS.R +++ b/wisecondorX/include/CBS.R @@ -21,6 +21,7 @@ suppressMessages(library("jsonlite")) input <- read_json(in.file) ratio <- as.numeric(unlist(input$results_r)) weights <- as.numeric(unlist(input$results_w)) +seed <- as.numeric(input$seed) gender <- input$ref_gender alpha <- as.numeric(input$alpha) binsize <- as.numeric(input$binsize) @@ -63,6 +64,9 @@ for.cbs <- for.cbs[cbs.mask,] # CBS +if (is.na(seed) || seed == '') { + set.seed(seed) +} CNA.object <- CNA(for.cbs$y, for.cbs$chromosome, for.cbs$x, data.type = "logratio", sampleid = "X") f = file() sink(file=f) ## silence output diff --git a/wisecondorX/main.py b/wisecondorX/main.py old mode 100755 new mode 100644 index 6a1d3b9..c34f988 --- a/wisecondorX/main.py +++ b/wisecondorX/main.py @@ -474,6 +474,9 @@ def main(): action="store_true", help="Add the output name as plot title", ) + parser_test.add_argument( + "--seed", type=int, default=None, help="Seed for segmentation algorithm" + ) parser_test.set_defaults(func=tool_test) args = parser.parse_args(sys.argv[1:]) diff --git a/wisecondorX/predict_tools.py b/wisecondorX/predict_tools.py index 91a0548..5b57afe 100644 --- a/wisecondorX/predict_tools.py +++ b/wisecondorX/predict_tools.py @@ -247,6 +247,7 @@ def exec_cbs(rem_input, results): "ref_gender": str(rem_input["ref_gender"]), "alpha": str(rem_input["args"].alpha), "binsize": str(rem_input["binsize"]), + "seed": str(rem_input["args"].seed), "results_r": results["results_r"], "results_w": results["results_w"], "infile": str("{}_01.json".format(json_cbs_dir)),