Dear Gitlab users, due to maintenance reasons, Gitlab will not be available on Thursday 30.09.2021 from 5:00 pm to approximately 5:30 pm.

Commit e7d8e096 authored by daniel.eilertz's avatar daniel.eilertz
Browse files

Merge branch 'eilertz' into 'dev'

Eilertz

See merge request !7
parents 0f2d719d d7349fe4
.Rproj.user
.Rhistory
......@@ -17,7 +17,7 @@ License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.0
RoxygenNote: 7.1.1
Imports:
caret (>= 6.0-86),
e1071 (>= 1.7-3),
......@@ -27,4 +27,4 @@ Imports:
openxlsx (>= 4.1.4),
randomForest (>= 4.6-14),
robustbase(>= 0.93-6),
zoo (>= 1.8-7)
\ No newline at end of file
zoo (>= 1.8-7)
......@@ -61,9 +61,6 @@ initialize_prm <- function() {
prm$model_rf_path <- paste0(prm$pathprefix, 'data/helperfiles/testdata/LC_machine_learning/rf_model_pcand.Rdata')
prm$model_rf_final_path <- paste0(prm$pathprefix, 'data/helperfiles/testdata/LC_machine_learning/rf_model_finalp.Rdata')
#Rouse?
prm$train_path <- "" #must be set until intermdiate pipeline is replaced
#?
prm$sum12c <- FALSE # sum 12c qual and quant area/height #
......
......@@ -4,13 +4,10 @@ plot_peaks <- function(metab, smpl, msd, prm) {
# adds quality scores to labels (more qs in expertmode)
cat('Creating peakoverview.pdf ', file=prm$log_con)
print(' ')
cat(' ')
pdf_file <- "peakoverview.pdf"
if(prm$train_path != ""){
pdf_file <- paste0("peakoverview_", prm$train_path, ".pdf")
}else{
pdf_file <- "peakoverview.pdf"
}
pdf(file = file.path(prm$batchdir, pdf_file), height = 2*prm$nsmpl, width = 5* prm$nmet, family = "Helvetica")
par(mai = c(0.5, 0.5, 0.8, 0.5))
layout(matrix(c(1:(prm$nmet*prm$nsmpl)), prm$nsmpl, prm$nmet, byrow = TRUE)) # initiate subplots
......
......@@ -10,7 +10,7 @@
#' @return msd list metabolites of samples with processed data
#'
#' @export
process_batch <- function(nowfolder = "", parameters = list()) {
process_batch <- function(nowfolder = "", parameters = list(), return_msd=FALSE) {
# Initialize analysis ------------------------------
ptm <- proc.time()
......@@ -78,31 +78,31 @@ process_batch <- function(nowfolder = "", parameters = list()) {
}
# Log git info ------------------------------
tryCatch({
cat(paste(timestamp(), '\n Now running process_batch.R',
'\n\n Current user: ', Sys.info()[["user"]], '\n \n'), file=prm$log_con)
scriptgithash <- automrmgithash <- helperfilesgithash <- ''
if (dir.exists('~/data/helperfiles')) {
helperfilesgithash <- system(paste0("git --git-dir=", prm$pathprefix, "data/helperfiles/.git/ describe --always"), intern=TRUE)
cat(paste('\n\n Gitlab repository for helperfiles: https://gitlab.gwdg.de/joerg.buescher/helperfiles
Commit hash: ', helperfilesgithash), file=prm$log_con)
}
if (dir.exists('~/data/automRm')) {
automrmgithash <- system(paste0("git --git-dir=", prm$pathprefix, "data/automRm/.git/ describe --always"), intern=TRUE)
cat(paste('\n\n Gitlab repository for automRm: https://gitlab.gwdg.de/joerg.buescher/automrm
Commit hash: ', automrmgithash,
), file=prm$log_con)
}
if (dir.exists('~/code/R_analysis')) {
scriptgithash <- system(paste0("git --git-dir=", prm$pathprefix, "code/R_analysis/.git/ describe --always"), intern=TRUE)
cat(paste('\n\n Gitlab repository for processing script: https://gitlab.gwdg.de/daniel.eilertz/ms-web
Commit hash: ', scriptgithash), file=prm$log_con)
}
rm('helperfilesgithash', 'scriptgithash', 'automrmgithash')
}, error = function(err) {
# not in docker container used for development, do nothing
})
# tryCatch({
# cat(paste(timestamp(), '\n Now running process_batch.R',
# '\n\n Current user: ', Sys.info()[["user"]], '\n \n'), file=prm$log_con)
# scriptgithash <- automrmgithash <- helperfilesgithash <- ''
#
# if (dir.exists('~/data/helperfiles')) {
# helperfilesgithash <- system(paste0("git --git-dir=", prm$pathprefix, "data/helperfiles/.git describe --always"), intern=TRUE)
# cat(paste('\n\n Gitlab repository for helperfiles: https://gitlab.gwdg.de/joerg.buescher/helperfiles
# Commit hash: ', helperfilesgithash), file=prm$log_con)
# }
# if (dir.exists('~/data/automRm')) {
# automrmgithash <- system(paste0("git --git-dir=", prm$pathprefix, "data/automRm/.git describe --always"), intern=TRUE)
# cat(paste('\n\n Gitlab repository for automRm: https://gitlab.gwdg.de/joerg.buescher/automrm
# Commit hash: ', automrmgithash,
# ), file=prm$log_con)
# }
# if (dir.exists('~/code/R_analysis')) {
# scriptgithash <- system(paste0("git --git-dir=", prm$pathprefix, "code/R_analysis/.git describe --always"), intern=TRUE)
# cat(paste('\n\n Gitlab repository for processing script: https://gitlab.gwdg.de/daniel.eilertz/ms-web
# Commit hash: ', scriptgithash), file=prm$log_con)
# }
# rm('helperfilesgithash', 'scriptgithash', 'automrmgithash')
# }, error = function(err) {
# # not in docker container used for development, do nothing
# })
# load random forest models and add to parameter list
if (prm$ml_type %in% c('mlprod', 'mltrain_pcand') ) { #(!(prm$ml_train && (prm$ml_type == 'initial'))) {
......@@ -197,28 +197,38 @@ process_batch <- function(nowfolder = "", parameters = list()) {
# for documentation purposes append session info to log. do this at the end because it's a messy read.
cat(as.character(sessionInfo()), file=prm$log_con)
cat('qqq_auto_integrate complete.')
tryCatch({
# Call sample postprocessing if in pipeline mode
if (!(as.character(Sys.info()[["user"]]) == 'rstudio') && !prm$runninglocal ){
rm(list = ls()) # empty workspace to avoid out of memory options
gc()
# system("chmod 777 overviewheatmap.pdf", intern=FALSE, wait=FALSE)
system("python3 /code/msweb/metabolomics/help/sample_postprocessing.py", intern=FALSE, wait=FALSE)
}
# cat('\nSettings overview: \n')
# cat(as.character(prm),file=prm$log_con)
print ('qqq_auto_integrate complete.')
# Reset par to default
par(pardefault)
# tidy up
# setwd(originalwd)
par(pardefault)
# Return msd object if argument is set
if(return_msd){
msd
}
}, error = function(err) {
# if tidying up doesn't work, well too bad.
})
msd
# tryCatch({
# # Call sample postprocessing if in pipeline mode
# if (!(as.character(Sys.info()[["user"]]) == 'rstudio') && !prm$runninglocal ){
# rm(list = ls()) # empty workspace to avoid out of memory options
# gc()
# # system("chmod 777 overviewheatmap.pdf", intern=FALSE, wait=FALSE)
# system("python3 /code/msweb/metabolomics/help/sample_postprocessing.py", intern=FALSE, wait=FALSE)
# }
# # cat('\nSettings overview: \n')
# # cat(as.character(prm),file=prm$log_con)
# print ('qqq_auto_integrate complete.')
#
# # tidy up
# # setwd(originalwd)
# par(pardefault)
#
# }, error = function(err) {
# # if tidying up doesn't work, well too bad.
# })
#
# msd
} # endfunction
......
......@@ -121,5 +121,5 @@ write_peakinfo <- function(metab, smpl, msd, prm){
openxlsx::saveWorkbook(wb, file.path(prm$batchdir, "Peakinfo.xlsx"), overwrite = TRUE)
cat('...done.\n\n', file=prm$log_con)
system("chmod 777 Peakinfo.xlsx", intern=FALSE, wait=FALSE)
system(paste0("chmod ", "777 ", prm$batchdir, "/Peakinfo.xlsx"), intern=FALSE, wait=FALSE)
}
Markdown is supported
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