Skip to content

Commit

Permalink
Don't render any output in seqLogoApp until the loading is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
csoneson committed Dec 11, 2024
1 parent 436524e commit b763329
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions R/seqLogoApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,30 @@ seqLogoApp <- function(seqTableCsv,
"xlsx files containing the retained rows of the table.\n\n"))

seqlogo <- shiny::reactive({
## Replace ggseqlogo (removed from CRAN) with motifStack
seqs <- df[input$seqtable_rows_all, "seqWindow"]
pfm <- motifStack::pcm2pfm(Biostrings::consensusMatrix(
Biostrings::AAStringSet(seqs)))
pfm <- new("pfm", mat = pfm, name = "",
color = motifStack::colorset(alphabet = "AA",
colorScheme = "chemistry"))
pfm
# ggseqlogo::ggseqlogo(df[input$seqtable_rows_all, "seqWindow"],
# seq_type = "aa") +
# ggseqlogo::theme_logo(base_size = 15)
if (is.null(input$seqtable_rows_all)) {
NULL
} else {
## Replace ggseqlogo (removed from CRAN) with motifStack
seqs <- df[input$seqtable_rows_all, "seqWindow"]
pfm <- motifStack::pcm2pfm(Biostrings::consensusMatrix(
Biostrings::AAStringSet(seqs)))
pfm <- new("pfm", mat = pfm, name = "",
color = motifStack::colorset(alphabet = "AA",
colorScheme = "chemistry"))
pfm
# ggseqlogo::ggseqlogo(df[input$seqtable_rows_all, "seqWindow"],
# seq_type = "aa") +
# ggseqlogo::theme_logo(base_size = 15)
}
})
output$seqlogo <- shiny::renderPlot({
motifStack::plotMotifLogo(seqlogo(), font = "sans", fontface = "plain")
## With ggseqlogo
# seqlogo()
if (!is(seqlogo(), "pfm")) {
NULL
} else {
motifStack::plotMotifLogo(seqlogo(), font = "sans", fontface = "plain")
## With ggseqlogo
# seqlogo()
}
})

output$dl <- shiny::downloadHandler(
Expand Down

0 comments on commit b763329

Please sign in to comment.