Commit 3b6785e1 authored by joerg.buescher's avatar joerg.buescher
Browse files

fix model_path in initialize_prm.R

parent 07b26dd9
File deleted
evaluate_peaks_rf <- function(msd, prm){
# Function to evaluate peaks based on final random forest model
# In Training mode: all peak candidates are reported
# Quantiles of RF scores for each batch calculated
# Final random forest model predicts peak scores based on each peaks QS + rf score quantiles
# Updates msd:
# - new label with report flag 'rep'
# - new variable per sample*metabolite 'report' with score probability
print(' ')
trainingflag <- (substr(prm$ml_type,1,7) == 'mltrain') # only compute once for speed
if ((prm$verbose >=2) && trainingflag ) {
cat('\r', 'evaluate_peaks: Setting default values (report <- TRUE) in training mode')
}
for (im in 1:prm$nmet){
# calculate quantiles for each batch
rf_quantile <- quantile(sapply(msd[[im]], '[[', 'qs'))
names(rf_quantile) <- paste0("RF",seq(0,100,25))
for (id in 1:prm$nsmpl){
# Set report flag to default if in ml training mode
if (trainingflag) {
msd[[im]][[id]]$report <- TRUE
next
}
if (prm$verbose >=2) {
cat('\r', paste('evaluate_peaks: metab', im, 'sample', id, ' '))
}
nowrfquantile <- c(data.frame('Output_H' = msd[[im]][[id]]$qs), rf_quantile)
# predict final peak score
final_data <- as.data.frame(c(msd[[im]][[id]]$qs_list, nowrfquantile))
final_data_prep <- predict(prm$train_preprocessing_final,final_data)
final_pred <- predict(prm$model_rf_final,final_data_prep,type="prob")$H
#update plotdata label
quantile_label <- paste0(names(rf_quantile),": ",rf_quantile,collapse=" ")
new_label <- paste0(paste("rep: ",final_pred),"\n",quantile_label)
msd[[im]][[id]]$label2 <- paste(msd[[im]][[id]]$label2, new_label)
nowchecksum <- sum(msd[[im]][[id]]$foundchrom)
# Set report variable and report value
msd[[im]][[id]]$report <- ((final_pred >= 0.5) && (nowchecksum > 1))
}
}
# Return updated data
msd
}# endfunction
......@@ -62,8 +62,8 @@ initialize_prm <- function() {
prm$polarities = list('Positive'= '+','Negative'= '-','-'='Negative','+'='Positive')
# Paths and columns
prm$model_rf_path <- paste0(prm$pathprefix, 'data/helperfiles/testdata/LC_machine_learning/model_pcand.Rdata')
prm$model_rf_final_path <- paste0(prm$pathprefix, 'data/helperfiles/testdata/LC_machine_learning/model_finalp.Rdata')
prm$model_path <- paste0(prm$pathprefix, 'data/helperfiles/testdata/LC_machine_learning/model_pcand.Rdata')
prm$model_final_path <- paste0(prm$pathprefix, 'data/helperfiles/testdata/LC_machine_learning/model_finalp.Rdata')
#Rouse?
prm$train_path <- "" #must be set until intermediate pipeline is replaced
......
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