Skip to content

Commit

Permalink
add dynamic heatmap function
Browse files Browse the repository at this point in the history
  • Loading branch information
mengchen18 committed Jun 13, 2024
1 parent d6bd4ab commit a5d6a5a
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: omicsViewer
Title: Interactive and explorative visualization of SummarizedExperssionSet or ExpressionSet using omicsViewer
Version: 1.9.0
Version: 1.9.1
Authors@R: person("Chen", "Meng", email = "mengchen18@gmail.com",
role = c("aut", "cre"))
Description: omicsViewer visualizes ExpressionSet (or SummarizedExperiment) in an interactive way. The omicsViewer has a separate back- and front-end. In the back-end, users need to prepare an ExpressionSet that contains all the necessary information for the downstream data interpretation. Some extra requirements on the headers of phenotype data or feature data are imposed so that the provided information can be clearly recognized by the front-end, at the same time, keep a minimum modification on the existing ExpressionSet object. The pure dependency on R/Bioconductor guarantees maximum flexibility in the statistical analysis in the back-end. Once the ExpressionSet is prepared, it can be visualized using the front-end, implemented by shiny and plotly. Both features and samples could be selected from (data) tables or graphs (scatter plot/heatmap). Different types of analyses, such as enrichment analysis (using Bioconductor package fgsea or fisher's exact test) and STRING network analysis, will be performed on the fly and the results are visualized simultaneously. When a subset of samples and a phenotype variable is selected, a significance test on means (t-test or ranked based test; when phenotype variable is quantitative) or test of independence (chi-square or fisher’s exact test; when phenotype data is categorical) will be performed to test the association between the phenotype of interest with the selected samples. Additionally, other analyses can be easily added as extra shiny modules. Therefore, omicsViewer will greatly facilitate data exploration, many different hypotheses can be explored in a short time without the need for knowledge of R. In addition, the resulting data could be easily shared using a shiny server. Otherwise, a standalone version of omicsViewer together with designated omics data could be easily created by integrating it with portable R, which can be shared with collaborators or submitted as supplementary data together with a manuscript.
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes in version 1.10
new features:
- dynamic heatmap - zoomed in heatmap upon subsetting features and observations

Changes in version 1.7 (2024-03-08)
new functions added:
Expand Down
75 changes: 75 additions & 0 deletions R/L1_module_data_space.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,33 @@ L1_data_space_ui <- function(id, activeTab = "Feature") {
)
)
),
tabPanel(
"Dynamic heatmap",
fluidRow(
column(
6,
dropdown(
inputId = "mydropdown3",
label = "Controls",
circle = FALSE, status = "default", icon = icon("cog"),
width = 700,
tooltip = tooltipOptions(title = "Click to update heatmap and check legend!"),
margin = "10px",
tabsetPanel(
tabPanel("Parameters", iheatmapInput(id = ns("dynheatmapViewer"))),
tabPanel("Legend", iheatmapLegend(id = ns("dynheatmapViewer")))
)
)
),
column(
6, align = "right",
iheatmapClear(id = ns("dynheatmapViewer"))
),
column(
12, iheatmapOutput(id = ns("dynheatmapViewer"))
)
)
),
tabPanel("Expression", dataTable_ui(ns("tab_expr"))),
tabPanel("GSList", gslist_ui(ns("gsList")))
)
Expand Down Expand Up @@ -301,11 +328,59 @@ L1_data_space_module <- function(
selectedFeatures( status()$eset_selected_features )
})

############## dynamic heatmap function start ##################

hdmat <- reactive({

req(e0 <- expr())
req(fd <- fdata())
req(pd <- pdata())

if (length(tab_rows_fdata()) > 2) {
fd <- fd[tab_rows_fdata(), ]
e0 <- e0[tab_rows_fdata(), ]
}

if (length(tab_rows_pdata()) > 2) {
pd <- pd[tab_rows_pdata(), ]
e0 <- e0[, tab_rows_pdata()]
}

list(expr = e0, fd = fd, pd = pd)
})

s_dyn_heatmap <- callModule(
iheatmapModule, 'dynheatmapViewer',
mat = reactive(hdmat()$expr), pd = reactive(hdmat()$pd), fd = reactive(hdmat()$fd),
status = reactive(status()$eset_dyn_heatmap), fill.NA = FALSE
)

observeEvent(s_dyn_heatmap(), {

if (!is.null(s_dyn_heatmap()$brushed$row)) {
selectedFeatures(s_dyn_heatmap()$brushed$row)
} else if (!is.null(s_dyn_heatmap()$clicked)) {
selectedFeatures(s_dyn_heatmap()$clicked["row"]) # ?? else set to character(0)
} else
selectedFeatures(character(0))

if (!is.null(s_dyn_heatmap()$brushed$col)) {
selectedSamples(s_dyn_heatmap()$brushed$col)
} else if (!is.null(s_dyn_heatmap()$clicked)) {
selectedSamples(s_dyn_heatmap()$clicked["col"]) # ?? else set to character(0)
} else
selectedSamples(character(0))
})

############## dynamic heatmap function end ##################

reactive({

l <- list(
feature = selectedFeatures(),
sample = selectedSamples()
)

sta <- list(
eset_active_tab = input$eset,
eset_pdata_tab = attr(tab_pd(), "status"), # -> pdata_tab
Expand Down

0 comments on commit a5d6a5a

Please sign in to comment.