-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first, not tested, not working version * run_CODEXCOV.R file removed * CODEXCOV_wrapper.R file done * bugfix in CODEXCOV_wrapper.R * run_cnvcaller.R divided into functions * bugfix * changed parameters tables * bugfixes in run_cnvcaller.R * proper driver managment * coverage table name from paramaters * option for only Y chr * bugfix
- Loading branch information
Showing
5 changed files
with
168 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
library('CODEXCOV') | ||
|
||
#' Function Description | ||
#' | ||
#' Function description. | ||
#' @param mapp_thresh | ||
#' @param cov_thresh_from | ||
#' @param cov_thresh_to | ||
#' @param length_thresh_from | ||
#' @param length_thresh_to | ||
#' @param gc_thresh_from | ||
#' @param gc_thresh_to | ||
#' @param K_from | ||
#' @param K_to | ||
#' @param ds | ||
#' @param lmax | ||
#' @keywords | ||
#' @export | ||
#' @examples | ||
#' run_wrapper_CODEXCOV | ||
run_wrapper_CODEXCOV <- function(mapp_thresh, | ||
cov_thresh_from, | ||
cov_thresh_to, | ||
length_thresh_from, | ||
length_thresh_to, | ||
gc_thresh_from, | ||
gc_thresh_to, | ||
K_from, | ||
K_to, | ||
lmax, | ||
cov_table){ | ||
calls <- run_CODEXCOV(as.double(mapp_thresh), | ||
strtoi(cov_thresh_from), | ||
strtoi(cov_thresh_to), | ||
strtoi(length_thresh_from), | ||
strtoi(length_thresh_to), | ||
strtoi(gc_thresh_from), | ||
strtoi(gc_thresh_to), | ||
strtoi(K_from), | ||
strtoi(K_to), | ||
strtoi(lmax), | ||
cov_table | ||
) | ||
calls | ||
} |
139 changes: 99 additions & 40 deletions
139
R/CNVCALLER.RUNNER/inst/run_cnvcaller.R
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,107 @@ | ||
#!/usr/bin/env Rscript | ||
library(devtools) | ||
#install('CODEXCOV') | ||
library('CODEXCOV') | ||
install('CNVCALLER.RUNNER') ### zakomentować!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
library('CNVCALLER.RUNNER') | ||
library(optparse) | ||
|
||
#install.packages("RJDBC",dep=TRUE) | ||
library(RJDBC) | ||
|
||
option_list <- list( | ||
make_option("--id", default=1, | ||
help="Id of parameters [default %default]"), | ||
make_option("--mapp_thresh", default=0.9, | ||
help="Mapping threshold for quality checking. [default %default]"), | ||
make_option("--cov_thresh_from", default=20, | ||
help="Coverage threshold (begin of interval) for quality checking. [default %default]"), | ||
make_option("--cov_thresh_to", default=4000, | ||
help="Coverage threshold (end of interval) for quality checking. [default %default]"), | ||
make_option("--length_thresh_from", default=20, | ||
help="Length threshold (begin of interval) for quality checking. [default %default]"), | ||
make_option("--length_thresh_to", default=2000, | ||
help="Length threshold (end of interval) for quality checking. [default %default]"), | ||
make_option("--gc_thresh_from", default=20, | ||
help="GC threshold (begin of interval) for quality checking. [default %default]"), | ||
make_option("--gc_thresh_to", default=80, | ||
help="GC threshold (end of interval) for quality checking. [default %default]"), | ||
make_option("--K_from", default=1, | ||
help="K value (begin of interval). [default %default]"), | ||
make_option("--K_to", default=9, | ||
help="K value (end of interval). [default %default]"), | ||
make_option("--lmax", default=200, | ||
help="Maximum CNV length in number of exons returned. [default %default]"), | ||
make_option("--cov_table", default="ds", | ||
help="Coverage table. [default %default]") | ||
make_option("--tabName", default="public.test_parameters", | ||
help="Parameters table. [default %default]"), | ||
make_option("--id", default="1", | ||
help="Parameters id. [default %default]") | ||
) | ||
|
||
opt <- parse_args(OptionParser(option_list=option_list)) | ||
|
||
calls <- run_CODEXCOV(opt$mapp_thresh, | ||
opt$cov_thresh_from, | ||
opt$cov_thresh_to, | ||
opt$length_thresh_from, | ||
opt$length_thresh_to, | ||
opt$gc_thresh_from, | ||
opt$gc_thresh_to, | ||
opt$K_from, | ||
opt$K_to, | ||
opt$lmax, | ||
opt$cov_table | ||
) | ||
read_parameters <- function(tabName, id, conn){ | ||
query <- paste("Select * from ", tabName, " where id = ", id, ";", sep="") | ||
parameters <- dbGetQuery(conn, query) | ||
caller <- parameters[1,'caller'] | ||
cov_table <- parameters[1,'cov_table'] | ||
mapp_thresh <- parameters[1,'mapp_thresh'] | ||
cov_thresh_from <- parameters[1,'cov_thresh_from'] | ||
cov_thresh_to <- parameters[1,'cov_thresh_to'] | ||
length_thresh_from <- parameters[1,'length_thresh_from'] | ||
length_thresh_to <- parameters[1,'length_thresh_to'] | ||
gc_thresh_from <- parameters[1,'gc_thresh_from'] | ||
gc_thresh_to <- parameters[1,'gc_thresh_to'] | ||
K_from <- parameters[1,'k_from'] | ||
K_to <- parameters[1,'k_to'] | ||
lmax <- parameters[1,'lmax'] | ||
return(list(caller=caller, | ||
cov_table=cov_table, | ||
mapp_thresh=mapp_thresh, | ||
cov_thresh_from=cov_thresh_from, | ||
cov_thresh_to=cov_thresh_to, | ||
length_thresh_from=length_thresh_from, | ||
length_thresh_to=length_thresh_to, | ||
gc_thresh_from=gc_thresh_from, | ||
gc_thresh_to=gc_thresh_to, | ||
K_from=K_from, | ||
K_to=K_to, | ||
lmax=lmax)) | ||
} | ||
|
||
save_calls <- function(calls, conn){ | ||
if (nrow(calls) != 0) { | ||
for(i in 1:nrow(calls)) { | ||
call <- calls[i,] | ||
query <- paste("INSERT INTO TEST_CALLS (parameters_id, sample_name, chr, cnv, st_bp, ed_bp, length_kb, st_exon, ed_exon, raw_cov, norm_cov, copy_no, lratio, mBIC) VALUES ('", opt$id, "','", call[1], "','", call[2], "','", call[3], "','", call[4], "','", call[5], "','", call[6], "','", call[7], "','", call[8], "','", call[9], "','", call[10], "','", call[11], "','", call[12], "','", call[13], "');", sep="") | ||
dbSendUpdate(conn, query) | ||
} | ||
} | ||
} | ||
|
||
read_coverage_table <- function(cov_table, conn){ | ||
#query <- paste("select * from ", cov_table, sep="") | ||
query <- paste("select * from ", cov_table, " where chr='Y'", sep="") | ||
ds <- dbGetQuery(conn, query) | ||
colnames(ds) <- c("sample_name", "target_id", "chr", "pos_min", "pos_max", "cov_avg") | ||
ds | ||
} | ||
|
||
run_caller <- function(parameters, cov_table){ | ||
if (parameters$caller == "codex"){ | ||
calls <- run_wrapper_CODEXCOV(parameters$mapp_thresh, | ||
parameters$cov_thresh_from, | ||
parameters$cov_thresh_to, | ||
parameters$length_thresh_from, | ||
parameters$length_thresh_to, | ||
parameters$gc_thresh_from, | ||
parameters$gc_thresh_to, | ||
parameters$K_from, | ||
parameters$K_to, | ||
parameters$lmax, | ||
cov_table | ||
) | ||
calls | ||
} else if(parameters$caller == "xhmm") { | ||
} | ||
} | ||
|
||
if (!file.exists("zsi-bio-cdh-hive-jdbc_2.11-0.1-assembly.jar")) { | ||
download.file("http://zsibio.ii.pw.edu.pl:50007/repository/maven-releases/pl/edu/pw/ii/zsibio/zsi-bio-cdh-hive-jdbc_2.11/0.1/zsi-bio-cdh-hive-jdbc_2.11-0.1-assembly.jar",destfile="zsi-bio-cdh-hive-jdbc_2.11-0.1-assembly.jar") | ||
} | ||
drv_hive <- JDBC("com.cloudera.hiveserver2.hive.core.Hive2JDBCDriver", "./zsi-bio-cdh-hive-jdbc_2.11-0.1-assembly.jar",identifier.quote="`") | ||
conn_hive <- dbConnect(drv_hive, "jdbc:hive2://cdh01.ii.pw.edu.pl:10000", "mwiewior", "") | ||
|
||
if (!file.exists("postgresql-42.1.1.jar")) { | ||
download.file("http://zsibio.ii.pw.edu.pl:50007/repository/zsi-bio-raw/common/jdbc/postgresql-42.1.1.jar",destfile="postgresql-42.1.1.jar") | ||
} | ||
drv_psql <- JDBC("org.postgresql.Driver", "./postgresql-42.1.1.jar",identifier.quote="`") | ||
conn_psql <- dbConnect(drv_psql, "jdbc:postgresql://cdh00.ii.pw.edu.pl:15432/cnv-opt", "cnv-opt", "zsibio321") | ||
|
||
parameters <- read_parameters(opt$tabName, opt$id, conn_psql) | ||
#print(parameters) | ||
cov_table <- read_coverage_table(parameters$cov_table, conn_hive) | ||
#print(cov_table) | ||
calls <- run_caller(parameters, cov_table) | ||
#print(calls) | ||
save_calls(calls, conn_psql) | ||
|
||
dbDisconnect(conn_hive) | ||
dbUnloadDriver(drv_hive) | ||
|
||
dbDisconnect(conn_psql) | ||
dbUnloadDriver(drv_psql) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters