Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggiraph functionality in volcano and PCA plots #154

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

OlaCaster
Copy link
Contributor

Note: This is a draft only. This is a POC to demonstrate how we could add plot interactivity (tooltip, hover, and select) using ggiraph.

Documentation is only updated to a bare minimum (i.e., new arguments are described). No tests have been added.

Some example code (note that you obviously need ggiraph installed - if not, you will be prompted):

# Volcano plot
library(dplyr)
npx_df <- npx_data1 %>% filter(!grepl('control',SampleID, ignore.case = TRUE))
ttest_results <- olink_ttest(df=npx_df,
                             variable = 'Treatment',
                             alternative = 'two.sided') %>%
  mutate(tool = paste0("OlinkID: ", OlinkID, "\nAssay: ", Assay, "\nUniProt: ", UniProt))
ggiraph::girafe(ggobj = olink_volcano_plot(ttest_results, tooltip_variable = "tool", data_id_variable = "OlinkID"))

# Single PCA
# Tooltip per Sample, hover effect per Subject
library(dplyr)
npx_data <- npx_data1 %>%
  mutate(SampleID = paste(SampleID, "_", Index, sep = ""))
ggiraph::girafe(ggobj = olink_pca_plot(df=npx_data %>% dplyr::mutate(tool=paste0("Subject: ",Subject,"\nSampleID: ",SampleID)),
                                       color_g = "QC_Warning", tooltip_variable="tool", data_id_variable = "Subject", quiet=TRUE)[[1L]])

# Multiple linked PCAs
# Tooltip and hover per Sample ID - the two plots are linked by data_id
library(dplyr)
library(patchwork)
npx_data <- npx_data1 %>%
  mutate(SampleID = paste(SampleID, "_", Index, sep = ""))
g <- olink_pca_plot(df=npx_data, color_g = "QC_Warning", tooltip_variable="SampleID", data_id_variable = "SampleID",
                    quiet=TRUE, byPanel=TRUE)
ggiraph::girafe(code = print(g[[1L]] + g[[2L]]), width_svg=10,
                options=list(
                  ggiraph::opts_tooltip(opacity=0.7),
                  ggiraph::opts_hover(    css="fill:darkgreen; stroke:darkgreen; r:4pt;"),
                  ggiraph::opts_hover_inv(css="opacity:0.3;")
                ))

@OlaCaster OlaCaster changed the title Ggiraph support volcano and pca plots ggiraph functionality in volcano and PCA plots Jun 16, 2022
Base automatically changed from develop to main November 14, 2022 15:50
@AskPascal AskPascal changed the base branch from main to develop March 8, 2023 13:30
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.

None yet

1 participant