Commit 3aa38291 authored by Gael  MILLOT's avatar Gael MILLOT
Browse files

tempo

parent 1a511400
docker
docs
other
README.md
.nextflow
singularity
work
\ No newline at end of file
work/
singularity/
results/
.nextflow/
.nextflow*
\ No newline at end of file
install.packages('dplyr')
install.packages('ggplot2')
install.packages('DESeq2')
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("DESeq2")
install.packages("tidyverse")
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install(version = "3.14")
install.packages('SARTools')
install.packages('sartools')
install.packages('sartool')
library(ggplot2)
ggplot2::guides(fill = FALSE, color = FALSE, alpha = FALSE)
ggplot2::guides(fill = 'none', color = 'none', alpha = 'none')
ggplot2::guides(fill = 'none', color = 'none', alpha = 'none')
setwd("~/mia/gitlab/kocchi/bin")
#! /usr/bin/Rscript
source(here::here("bin/intern_funct_check.R"))
path_function1 = "https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/raw/c1dd8832f14d76c1901a60ca2a7c87af01a82b61/cute_little_R_functions.R"
if(length(path.function1) != 1){
stop(paste0("\n\n============\n\nERROR IN SLITHERINE\npath.function1 PARAMETER MUST BE LENGTH 1: ",
paste(path.function1, collapse = " "), "\n\n============\n\n"))
}else if(grepl(x = path.function1, pattern = "^http")){
tempo.try <- try(suppressWarnings(source(path.function1, local = .GlobalEnv)), silent = TRUE)
if(any(grepl(x = tempo.try, pattern = "[Ee]rror"))){
stop(paste0("\n\n============\n\nERROR IN SLITHERINE\n
HTTP INDICATED IN THE path.function1 PARAMETER DOES NOT EXISTS: ", path.function1, "\n\n============\n\n"))
}else{
source(path.function1, local = .GlobalEnv) # source the fun_ functions used below
}
}else if( ! grepl(x = path.function1, pattern = "^http")){
if( ! file.exists(path.function1)){
stop(paste0("\n\n============\n\nERROR IN SLITHERINE\n
FILE INDICATED IN THE path.function1 PARAMETER DOES NOT EXISTS: ", path.function1, "\n\n============\n\n"))
}else{
source(path.function1, local = .GlobalEnv) # source the fun_ functions used below
}
}
adj.mean.fun <- function(x_3fun, text_3fun){
# AIM
......
......@@ -2,7 +2,6 @@
## local function: graphs of HiC Compare
source(here::here("bin/intern_funct_check.R"))
hiccompare.graphs.fun <-
function(hictable_5fun,
......
#! /usr/bin/Rscript
path_function1 = "https://gitlab.pasteur.fr/gmillot/cute_little_R_functions/-/raw/c1dd8832f14d76c1901a60ca2a7c87af01a82b61/cute_little_R_functions.R"
if (length(path.function1) != 1) {
stop(
paste0(
"\n\n============\n\nERROR IN SLITHERINE\npath.function1 PARAMETER MUST BE LENGTH 1: ",
paste(path.function1, collapse = " "),
"\n\n============\n\n"
)
)
} else if (grepl(x = path.function1, pattern = "^http")) {
tempo.try <-
try(suppressWarnings(source(path.function1, local = .GlobalEnv)), silent = TRUE)
if (any(grepl(x = tempo.try, pattern = "[Ee]rror"))) {
stop(
paste0(
"\n\n============\n\nERROR IN SLITHERINE\n
HTTP INDICATED IN THE path.function1 PARAMETER DOES NOT EXISTS: ",
path.function1,
"\n\n============\n\n"
)
)
} else{
source(path.function1, local = .GlobalEnv) # source the fun_ functions used below
}
} else if (!grepl(x = path.function1, pattern = "^http")) {
if (!file.exists(path.function1)) {
stop(
paste0(
"\n\n============\n\nERROR IN SLITHERINE\n
FILE INDICATED IN THE path.function1 PARAMETER DOES NOT EXISTS: ",
path.function1,
"\n\n============\n\n"
)
)
} else{
source(path.function1, local = .GlobalEnv) # source the fun_ functions used below
}
}
internal.function.check.fun <-
function(expect.arg.values_fun,
req.functions_fun,
function.name_fun) {
# AIM
# check the arguments of the other local functions of this script
# WARNING
# use the object of the checked function
# ARGUMENTS
# expect.arg.values_fun: a list of character strings made of the authorized values of the arguments of the checked function
# req.functions_fun: a vector of character strings made of the names of the cute little toolbox required functions. Write NULL is no functions required
# function.name_fun: a character string of the name of the parental function
# REQUIRED PACKAGES
# none
# REQUIRED FUNCTIONS FROM CUTE_LITTLE_R_FUNCTION
# non
# RETURN
# error messages
# EXAMPLES
# internal.function.check.fun(expect.arg.values_fun = list("a"), req.functions_fun = "b")
# DEBUGGING
# expect.arg.values_fun = list("a") ; req.functions_fun = "b"
# function name
function.name_intern <-
paste0(as.list(match.call(expand.dots = FALSE))[[1]], "()")
function.name_intern <-
paste0(function.name_intern, " INTERNAL FUNCTION OF SLITHERINE")
# end function name
# argument checking
if (!all(class(expect.arg.values_fun) == "list")) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_intern,
":\n
ARGUMENT expect.arg.values_fun MUST BE CLASS LIST AND NOT:\n",
paste(class(expect.arg.values_fun) , collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
} else{
for (i2 in 1:length(expect.arg.values_fun)) {
if (!all(class(expect.arg.values_fun[[i2]]) == "character")) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_intern,
":\nCOMPARTMENT ",
i2,
" OF ARGUMENT expect.arg.values_fun MUST BE A VECTOR OF CLASS CHARACTER AND NOT:\n",
paste(class(expect.arg.values_fun[[i2]]) , collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
}
}
}
if (!is.null(req.functions_fun)) {
if (!all(class(req.functions_fun) == "character")) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_intern,
":\nARGUMENT req.functions_fun MUST BE A VECTOR OF CLASS CHARACTER AND NOT:\n",
paste(class(req.functions_fun) , collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
}
}
if (!all(class(function.name_fun) == "character")) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_intern,
":\nARGUMENT function.name_fun MUST BE A VECTOR OF CLASS CHARACTER AND NOT:\n",
paste(class(function.name_fun) , collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
}
# end argument checking
# main code using the object of the function evaluated
if (!is.null(req.functions_fun)) {
for (i2 in 1:length(req.functions_fun)) {
if (length(find(req.functions_fun[i2], mode = "function")) == 0) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name,
": REQUIRED ",
req.functions_fun[i2],
" FUNCTION IS MISSING IN THE R ENVIRONMENTS\n\n================\n\n"
)
stop(tempo.cat)
}
}
}
arg.list <-
{
# this call the arguments of the parental function. To have the arguments of the current function: arg.list <- as.list(match.call(definition = sys.function(sys.parent(n = 2))))[-1] # recover the argument names with attributed values. -1 to remove the function name compartment. sys.function(sys.parent(n = 2)) to recover the agument beyond sys.function(). See also debugging_tools_for_r_dev for other kind of calling
cl <- sys.call(-1)
f <-
get(as.character(cl[[1]]), mode = "function", sys.frame(-2))
cl <- match.call(definition = f, call = cl)
as.list(cl)[-1]
}
arg.names <- names(arg.list)
arg.values <- unlist(as.character(arg.list))
default.arg.list <-
formals(fun = sys.function(sys.parent()), envir = parent.frame(n = 1)) # list of all the arguments of the parental function with their default values (not the values of the user !). Use formals(fun = sys.function(sys.parent(n = 2))) for arguments of the current function
arg.with.default.value <-
!sapply(default.arg.list, is.symbol) &
sapply(sapply(default.arg.list, as.character), identical, "") # logical indicating which of the default.arg.list have default values
if (any(arg.with.default.value) == TRUE) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_fun,
":\nARGUMENTS WITH DEFAULT VALUE NOT ALLOWED IN INTERNAL FUNCTIONS (FOR CODE SAFETY):\n",
paste(names(default.arg.list)[arg.with.default.value] , collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
}
expect.arg.names <- names(default.arg.list)
tempo.test <-
expect.arg.names[expect.arg.names %in% unlist(mapply(FUN = ls, pos = 1:10))]
if (length(tempo.test) > 0) {
# check that argument name are not in the R evironment
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_fun,
":\nARGUMENT NAME OF THIS INTERNAL FUNCTION ALSO PRESENT IN THE R ENVIRONMENT,
WHICH IS NOT ALLOWED FOR CODE SAFETY:\n",
paste(tempo.test, collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
}
if (!(
all(arg.names %in% expect.arg.names) &
length(arg.names) == length(expect.arg.names)
)) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_fun,
": ARGUMENTS OF THIS FUNCTION MUST BE LENGTH:\n",
length(expect.arg.names),
"\nAND MUST HAVE THESE NAMES:\n",
paste(expect.arg.names, collapse = "\n"),
"\n\nHERE, IT IS LENGTH:\n",
length(arg.names),
"\nWITH NAMES:\n",
paste(arg.names, collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
}
if (length(arg.values) != length(expect.arg.values_fun)) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_fun,
": ARGUMENTS OF THIS FUNCTION MUST BE LENGTH:\n",
length(expect.arg.values_fun),
"\n\nBUT HERE, IT IS LENGTH:\n",
length(arg.values),
"\n\n================\n\n"
)
stop(tempo.cat)
}
for (i1 in 1:length(expect.arg.values_fun)) {
if (!all(arg.values[i1] %in% expect.arg.values_fun[[i1]])) {
tempo.cat <-
paste0(
"\n\n================\n\nERROR IN ",
function.name_fun,
": VALUE OF ARGUMENT ",
arg.names[i1],
" MUST BE:\n",
paste(dQuote(expect.arg.values_fun[[i1]], q = FALSE), collapse = "\n"),
"\n\nBUT HERE, IT IS VALUE:\n",
paste(arg.values[i1], collapse = "\n"),
"\n\n================\n\n"
)
stop(tempo.cat)
}
}
}
......@@ -2,7 +2,6 @@
## local function: heatmap + mask plotting
source(here::here("bin/intern_funct_check.R"))
mask.plot.fun <-
function(mask_4fun,
......
This diff is collapsed.
......@@ -34,8 +34,7 @@ warn.secu <- as.logical(args[28])
serp.symmet.input <- as.logical(toupper(args[29]))
adj_mean <- args[30]
hiccompare_graph <- args[31]
intern_funct_check <- args[32]
mask_plot <- args[33]
mask_plot <- args[32]
warning.message <- NULL
ini.date <- Sys.time()
......
......@@ -22,11 +22,22 @@ matB_theo = np.loadtxt(sys.argv[4])
if len(sys.argv) == 7:
thr_tot = int(sys.argv[5])
thr_min = int(sys.argv[6])
iter_nb = int(sys.argv[7])
# binning des 2 matrices
matA_b, matB_b, mat_ratio = sp.serpentin_binning(matA, matB, thr_tot, thr_min)
matA_b, matB_b, mat_ratio = sp.serpentin_binning(
A = matA,
B = matB,
threshold = thr_tot,
minthreshold = thr_min,
iterations = iter_nb
)
matA_theo_b, matB_theo_b, mat_theo_ratio = sp.serpentin_binning(
matA_theo, matB_theo, thr_tot, thr_min
A = matA_theo,
B = matB_theo,
threshold = thr_tot,
minthreshold = thr_min,
iterations = iter_nb
)
# output
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
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