Skip to content

Adding EnhancedVolcano function to the package#87

Open
lobanovav wants to merge 5 commits into
DEVfrom
DEV_EnhancedVolcano
Open

Adding EnhancedVolcano function to the package#87
lobanovav wants to merge 5 commits into
DEVfrom
DEV_EnhancedVolcano

Conversation

@lobanovav
Copy link
Copy Markdown
Member

A quick description: Enhanced Volcano is now a function into the R folder and created a unit test with synthetic data

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new Volcano_Plot() function to generate static + interactive volcano plots (via EnhancedVolcano + plotly) and adds a testthat unit test suite using synthetic DEG data.

Changes:

  • Added R/Volcano_Plot.R implementing volcano plot generation for one or multiple comparisons, returning plots plus ranked output data.
  • Added tests/testthat/test-Volcano_Plot.R covering basic execution, return structure, multiple comparisons, and a few edge cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
R/Volcano_Plot.R New exported plotting function using EnhancedVolcano with optional labeling and interactive plotly output.
tests/testthat/test-Volcano_Plot.R New tests validating Volcano_Plot() output structure and a few edge cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/Volcano_Plot.R Outdated
Comment thread R/Volcano_Plot.R
Comment thread R/Volcano_Plot.R
Comment thread R/Volcano_Plot.R
Comment thread R/Volcano_Plot.R
Comment thread R/Volcano_Plot.R
Comment on lines +74 to +82
#' @import ggplot2
#' @import dplyr
#' @import tidyr
#' @importFrom stringr str_split
#' @importFrom ggrepel geom_text_repel
#' @importFrom EnhancedVolcano EnhancedVolcano
#' @importFrom plotly ggplotly
#' @importFrom grid grid.newpage
#' @export
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

This function imports and calls EnhancedVolcano::EnhancedVolcano, but the package is not listed in DESCRIPTION (so R CMD check will fail once NAMESPACE is regenerated). Add EnhancedVolcano to Imports (or Suggests + guard usage), and ensure NAMESPACE/man/ are regenerated to include the new @export and imports.

Copilot uses AI. Check for mistakes.
Comment thread R/Volcano_Plot.R
Comment on lines +281 to +298
# Extract the data used for plotting
plot_data <- ggplot_build(p_empty)$data[[1]]

pxx <- p_empty +
xlab("Fold Change") +
ylab("Significance") +
theme_minimal() +
geom_point(aes(
text = paste("Gene:", df[[label.col]],
"<br>Log2FC:", df[[lfc_name]],
"<br>P-value:", df[[sig_name]]),
colour = as.character(plot_data$colour),
fill = as.character(plot_data$colour)
),
shape = 21,
size = 2,
stroke = 0.1) +
scale_fill_identity()
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

The interactive plot construction adds a new geom_point() layer on top of p_empty, so points are drawn twice (once from EnhancedVolcano, once from the added layer) and pointSize/other aesthetics may diverge between layers. Consider attaching the text aesthetic to the existing point layer (or modifying/replacing that layer) so the interactive plot doesn’t duplicate geometry and avoids the extra ggplot_build() work.

Suggested change
# Extract the data used for plotting
plot_data <- ggplot_build(p_empty)$data[[1]]
pxx <- p_empty +
xlab("Fold Change") +
ylab("Significance") +
theme_minimal() +
geom_point(aes(
text = paste("Gene:", df[[label.col]],
"<br>Log2FC:", df[[lfc_name]],
"<br>P-value:", df[[sig_name]]),
colour = as.character(plot_data$colour),
fill = as.character(plot_data$colour)
),
shape = 21,
size = 2,
stroke = 0.1) +
scale_fill_identity()
# Add hover text aesthetic directly to the existing plot
pxx <- p_empty +
xlab("Fold Change") +
ylab("Significance") +
theme_minimal() +
aes(
text = paste(
"Gene:", df[[label.col]],
"<br>Log2FC:", df[[lfc_name]],
"<br>P-value:", df[[sig_name]]
)
)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I need more time to check this suggestion, skipping for now

Comment thread tests/testthat/test-Volcano_Plot.R Outdated
lobanovav and others added 4 commits March 26, 2026 11:22
Putting extra check for empty labels ("Fold change", "Significance")

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Removing library call for dplyr in test

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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