Skip to content

Commit 16c48a6

Browse files
Single-metabolite table now includes compound name in header.
1 parent 46d1369 commit 16c48a6

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: MetaBridgeShiny
22
Title: Map Metabolites for Omics Integration
3-
Version: 1.7.63
3+
Version: 1.7.64
44
Authors@R:
55
c(person(given = "Travis",
66
family = "Blimkie",

app.R

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ metabridgeServer <- function(input, output, session) {
450450
mappingSummary <- reactiveValues(table = NULL, dbChosen = NULL)
451451
mappedMetaboliteTable <- reactiveVal()
452452
databaseChosen <- reactiveVal()
453-
selectedMetab <- reactiveVal()
453+
selectedMetabIndex <- reactiveVal()
454+
selectedMetabName <- reactiveVal()
454455
idTypeChosen <- reactiveVal()
455456
columnPicked <- reactiveVal()
456457

@@ -689,25 +690,34 @@ metabridgeServer <- function(input, output, session) {
689690
} else {
690691
return(
691692
tagList(
692-
h3(paste0("Mapping summary: ", databaseChosen())),
693+
h3(paste0(databaseChosen(), " mapping summary")),
693694
DT::dataTableOutput("mappingSummaryTable")
694695
)
695696
)
696697
}
697698
})
698699

699700
observeEvent(
700-
input$mappingSummaryTable_rows_selected,
701-
selectedMetab(input$mappingSummaryTable_rows_selected)
701+
input$mappingSummaryTable_rows_selected, {
702+
selectedMetabIndex(input$mappingSummaryTable_rows_selected)
703+
selectedMetabName(
704+
mappingSummary$table[input$mappingSummaryTable_rows_selected, 1]
705+
)
706+
}
702707
)
703708

704-
observeEvent(input$mapButton, selectedMetab(NULL))
709+
observeEvent(
710+
input$mapButton, {
711+
selectedMetabIndex(NULL)
712+
selectedMetabName(NULL)
713+
}
714+
)
705715

706716

707717
# Single-metabolite table -----------------------------------------------
708718

709719
observeEvent({
710-
selectedMetab()
720+
selectedMetabIndex()
711721
input$mapButton
712722
}, {
713723
if (mappingObject()$status %in% c("error", "empty")) {
@@ -720,7 +730,7 @@ metabridgeServer <- function(input, output, session) {
720730
generateKEGGMetabTable(
721731
mappingObject(),
722732
mappingSummary$table,
723-
selectedMetab(),
733+
selectedMetabIndex(),
724734
idTypeChosen()
725735
) %>% mappedMetaboliteTable()
726736
}
@@ -732,7 +742,7 @@ metabridgeServer <- function(input, output, session) {
732742
generateMetaCycMetabTable(
733743
mappingObject(),
734744
mappingSummary$table,
735-
selectedMetab(),
745+
selectedMetabIndex(),
736746
idTypeChosen()
737747
) %>% mappedMetaboliteTable()
738748
}
@@ -741,7 +751,7 @@ metabridgeServer <- function(input, output, session) {
741751

742752
output$mappedMetaboliteTable <- DT::renderDataTable(
743753
{
744-
if (is.null(mappingObject()) | is.null(selectedMetab())) {
754+
if (is.null(mappingObject()) | is.null(selectedMetabIndex())) {
745755
return(data.frame())
746756

747757
} else if (mappingObject()$status == "success") {
@@ -763,14 +773,20 @@ metabridgeServer <- function(input, output, session) {
763773

764774
output$mappedMetabolitePanel <- renderUI({
765775
div(
766-
if (is.null(mappingObject())) {
776+
if ( any(is.null(mappingObject()), is.null(selectedMetabIndex())) ) {
767777
return(NULL)
768778
} else if (mappingObject()$status %in% c("error", "empty")) {
769-
tags$h3("Intermediate Results")
779+
tagList(
780+
tags$hr(),
781+
tags$h3("Intermediate Results")
782+
)
770783
} else {
771784
tagList(
772785
tags$hr(),
773-
tags$h3("Per-metabolite results")
786+
tags$h3(paste0(
787+
"Per-metabolite results for ",
788+
stringr::str_to_title(selectedMetabName())
789+
))
774790
)
775791
},
776792
DT::dataTableOutput("mappedMetaboliteTable")
@@ -845,7 +861,7 @@ metabridgeServer <- function(input, output, session) {
845861
"Select a metabolite from the top table, then click the button ",
846862
"below to see the pathways it's involved in.</p>"
847863
),
848-
if (databaseChosen() == "KEGG" & !is.null(selectedMetab())) {
864+
if (databaseChosen() == "KEGG" & !is.null(selectedMetabIndex())) {
849865
actionButton(
850866
inputId = "visualizeButton",
851867
class = "btn-primary",
@@ -890,7 +906,7 @@ metabridgeServer <- function(input, output, session) {
890906
observeEvent(input$mappingSummaryTable_rows_selected, {
891907
pathwayMappingAttrs <- mapPathways(
892908
idType = "KEGG",
893-
selectedRow = selectedMetab(),
909+
selectedRow = selectedMetabIndex(),
894910
summaryTable = mappingSummary$table,
895911
fullTable = mappingObject()$data
896912
)
@@ -1017,7 +1033,7 @@ metabridgeServer <- function(input, output, session) {
10171033
"You must map via KEGG to visualize your results with pathview!"
10181034
)
10191035
)
1020-
} else if (is.null(selectedMetab())) {
1036+
} else if (is.null(selectedMetabIndex())) {
10211037
tagList(
10221038
h3(class = "mb-4", "Pathway view"),
10231039
div(

0 commit comments

Comments
 (0)