Skip to content

Feature/DIMS_previous_runs - #131

Open
mraves2 wants to merge 9 commits into
developfrom
feature/DIMS_previous_runs
Open

Feature/DIMS_previous_runs#131
mraves2 wants to merge 9 commits into
developfrom
feature/DIMS_previous_runs

Conversation

@mraves2

@mraves2 mraves2 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Added rectangles in the violin plots to indicate the 5-95% range of results for patients for each metabolite in previous runs.
image

Extra file is imported in GenerateViolinPlots and generate_violin_plots_functions has new function add_previous_runs. Unit test for new function has been added.

Comment thread DIMS/export/generate_violin_plots_functions.R
Comment thread DIMS/export/generate_violin_plots_functions.R
Comment thread DIMS/export/generate_violin_plots_functions.R
Comment thread DIMS/export/generate_violin_plots_functions.R Outdated
#' @param explanation: text that explains the violin plots and the pipeline version (string)
create_pdf_violin_plots <- function(pdf_dir, patient_id, metab_perpage, top_metab_pt, explanation) {
#' @param data_previous_runs: data from previous DIMS runs, not used for dIEM plots (matrix)
create_pdf_violin_plots <- function(pdf_dir, patient_id, metab_perpage, top_metab_pt, explanation, data_previous_runs = NULL) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, create_pdf_violin_plots is quite long (large number of lines). Adding additional code to it, makes me wonder if it could be split into multiple methods.

For example:

  • A method that determines the PDF filename.
  • Any edits to the data itself. (filter/select, mutates etc)
  • Create a list (or something similar) with all plots.
  • Create the page layout with tableGrob + gridarrange etc using the plot list.
  • Write to PDF. (Or, combine with determining the PDF filename)

Would like to hear your opinion. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The part that determines the pdf file name could easily be made into a separate function. Creating a list of plots would not be my preference, I would prefer to keep each type of plot as a separate unit.
This code has been refactored previously and will remain as is for v3.5.

Comment thread DIMS/tests/testthat/test_generate_violin_plots.R
file.remove("missing_probability_scores.txt")
})

testthat::test_that("add_previous_runs: Information for metabolites from previous runs is correctly added", {

@ellendejong ellendejong Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a 'negative' test also relevant? Aka In case no match with common_name, or no data present.
Are there any other edge cases to cover? (edit, for example is file is provided, but doesnot exist etc.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of no match with common_name there will be no error, just an empty rectangle in de violin plot. I don't think this need to be tested. If the file is not present, there will be an error in the main script.

Comment thread DIMS/GenerateViolinPlots.R
Comment thread DIMS/export/generate_violin_plots_functions.R

@ellendejong ellendejong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All review comments are resolved or discussed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants