- Column name reconstruction
- Loading of the packages and the source functions
- Fine grain tuning of the Random Forest model
- Access to all generated models
- Access to the best model
- Model evaluation on Training and Validation set
- Importance of the chosen parameters inside the model
- SHAP summary
- SHAP dependences
RMI2_Random_Forest.Rmd 3.45 KiB
params:
Cells:
label: 'Cell type'
value: 'Lymphocytes'
input: select
choices: ['Lymphocytes']
Activations:
label: 'Activation'
value: 'Resting'
input: select
choices: ['Resting', 'Activated']
Score:
label: 'mRNA degradation index'
value: 'Total Degradation'
input: select
choices: ['Total Degradation', 'Translation Independent Degradation', 'Translation Dependent Degradation']
title: "RMI2 Random Forest for Translation Dependent Degradation \n`r params$Cells` `r params$Activations`\n`r params$Score`"
output:
pdf_document:
toc: true
toc_depth: 4
header-includes:
- \usepackage{titling}
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhf{}
- \lhead{`r format(Sys.time(), '%Y/%m/%d %H:%M:%S')` \newline `r params$Cells` `r params$Activations`}
- \chead{`r params$Score`}
- \rhead{
\includegraphics[width=2cm]{Logos/Logo-ens.jpg}
\includegraphics[width=1cm]{Logos/Logo-LBMC.jpg}
\includegraphics[width=1cm]{Logos/logo-rmi2-lab-version-2.png}
}
- \cfoot{\thepage}
- \lfoot{Written by Labaronne Emmanuel and Cluet David \newline current version 2023/12/06}
- \renewcommand{\footrulewidth}{0.4pt}
- \pretitle{\begin{center}
\includegraphics[width=2cm,height=2cm]{Logos/logo-rmi2-lab-version-2.png}\LARGE\\}
- \posttitle{\end{center}}
knitr::opts_chunk$set(echo = TRUE)
\newpage
Column name reconstruction
# Generate the score column name from the explicit GUI elements
if (params$Cells == 'Lymphocytes') {
cells <- 'Lympho_'
}
if (params$Score == 'Total Degradation') {
score <- 'DegFold.'
suffix <- '.Trip.Ref_Trip_0h.3h'
} else if (params$Score == 'Translation Independent Degradation') {
score <- 'Abs.NonTDD..'
suffix <- '.Trip_CHX.Ref_Trip_0h.3h'
} else if (params$Score == 'Translation Dependent Degradation') {
score <- 'Abs.TDD..'
suffix <- '.Trip_CHX.Ref_Trip_0h.3h'
}
# Concatenate all sub-parameters to generate the true column name
x <- paste0(score, cells, params$Activations, suffix)
x_explicit <- paste0(params$Cells, '_', params$Activations, '_', params$Score)
# The following code is an optimisation of Emmanuel Labaronne original script
\newpage
Loading of the packages and the source functions
# Load functions
source("src/randomForest.R")
\newpage
Fine grain tuning of the Random Forest model
# Perform the random forest
model <- makeRandomForest(x = x,
explicit_x = x_explicit)
\newpage
Access to all generated models
# Access to all models
model[["model"]]
\newpage
Access to the best model
# Get the fine tuned model
model[["model"]]$finalModel
\newpage
Model evaluation on Training and Validation set
suppressWarnings(grid.arrange(model[["training_set"]], model[["valid_set"]], ncol = 1))
\newpage
Importance of the chosen parameters inside the model
suppressWarnings(model[["ImpVar"]])
\newpage
SHAP summary
suppressWarnings(model[["shap_summary"]])
\newpage
SHAP dependences
suppressWarnings(gridExtra::grid.arrange(grobs = model[["shap_dep1"]], ncol = 3))
\newpage
suppressWarnings(gridExtra::grid.arrange(grobs = model[["shap_dep2"]], ncol = 3))