Skip to content

Conversation

@ALuesink
Copy link
Contributor

@ALuesink ALuesink commented Dec 15, 2025

  • Removed SST mix and positive controls from the plots in the Excel files.
  • Moved code to functions
  • Added unit tests for new functions

@ALuesink ALuesink changed the title Feature/dims excel plots Feature/DIMS_Excel_plots Dec 15, 2025
@ALuesink ALuesink marked this pull request as ready for review December 19, 2025 08:08
@rernst rernst self-requested a review January 13, 2026 08:31
Copy link
Member

@rernst rernst left a comment

Choose a reason for hiding this comment

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

Ziet er goed uit, ik denk dat je naamgeving soms wat duidelijker/simpeler kan maken. Verder zit er nog een stukje code duplicatie in wat je volgens mij bij de create_boxplot_excel functie kan toevoegen.

sorted_control_intensities <- sort(as.numeric(control_intensities))
trimmed_control_intensities <- sorted_control_intensities[(nr_to_remove + 1) :
trimmed_control_intensities <- sorted_control_intensities[(nr_to_remove + 1):
(length(sorted_control_intensities) - nr_to_remove)]
Copy link
Member

Choose a reason for hiding this comment

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

Formatting een beetje vreemd?

#' @param intensities_plots_df: a dataframe with HMDB_key column and intensities for all samples
#'
#' @returns intensities_plots_df_long: a dataframe with on each row a sample and their intensity
transform_ints_df_plots <- function(intensities_plots_df, row_index) {
Copy link
Member

Choose a reason for hiding this comment

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

Ik zou het woord 'plots' uit de functie naam halen, functie maakt namelijk geen plots.

Gezien je docstring header zou ik de functie noemen:
transform_intensities_df_to_long_format of intensities_df_to_long_format.

Interne variable intensities_plots_df zou ik dan ook intensities_df noemen en intensities_df_long.

#' @param hmdb_id: HMDB ID of the selected metabolite
#'
#' @returns boxplot_excel: ggplot2 object containing the plot of intensities
create_boxplot_excel <- function(intensities_plots_df_long, hmdb_id) {
Copy link
Member

Choose a reason for hiding this comment

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

Ook hier zo ik van maken: create_boxplot. Excel toevoegingen zijn niet echt nodig omdat het een functie is van de generate_excel_functions.R. Eventueel zou je hem 'private' kunnen maken. In python zou je dan doen: _create_boxplot -> dat geeft aan dat het niet de bedoeling is om de functie buiten de context van deze file te gebruiken. Weet niet of dat een ding is in de R 'wereld'?

# get HMDB ID
hmdb_name <- rownames(outlist[row_index, ])
# Get intensity columns for controls and patients
intensities_plots_df <- outlist %>% select(HMDB_key, matches("^C|^P[0-9]"), -ends_with("_Zscore"))
Copy link
Member

Choose a reason for hiding this comment

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

Ook hier intensities_plots_df -> intensities_df het is immers een df van intensities niet een df van intensities plots.

Comment on lines +168 to +175
plot.new()
tmp_png_helix <- paste0("plots/plot_helix_", hmdb_id, ".png")
png(filename = tmp_png_helix, width = plot_width, height = 300)

boxplot_excel_helix <- create_boxplot_excel(intensities_plots_df_long, hmdb_id)

print(boxplot_excel_helix)
dev.off()
Copy link
Member

Choose a reason for hiding this comment

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

Zou dit ook niet in de 'create_boxplot_excel' functie passen? Het lijkt er nu op de het maken van de boxplot feitelijk nog hier gebeurd, create boxplot genereerd nu enkel de ggplot config?

Comment on lines +197 to 200
boxplot_excel <- create_boxplot_excel(intensities_plots_df_long, hmdb_id)

print(boxplot_excel)
dev.off()
Copy link
Member

Choose a reason for hiding this comment

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

Hier wordt de code van hierboven vrijwel hetzelfde nog een keer gebruikt?

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.

3 participants