#' displayTree UI Function
#'
#' @description A shiny Module.
#'
#' @param id,input,output,session Internal parameters for {shiny}.
#'
#' @noRd
#'
#' @importFrom shiny NS tagList
mod_displayTree_ui <- function(id){
ns <- NS(id)
tagList(
)
}
#' displayTree Server Function
#'
#' @noRd
mod_displayTree_server <- function(input, output, session,
treeFileOut, geneFileCorOrUnOut, treeformat, lim, align, font, numscale, node, midP){
ns <- session$ns
#convert phylogenetic tree (midpoint or not) to tibble to join tree and genetic distance matrix
treeObject<-reactive({
tibble::as_tibble(treeFileOut())
})
#change column1, row1 to the id of label and replace - with a 0 within the file
geneObject <- reactive({
label <- . <- NULL
dplyr::rename(geneFileCorOrUnOut(), label = 1)%>%
replace(., .=="-", 0)
})
#join the treeobject and updated genetic distance file by label and convert to s4 object
gandTS4 <- reactive({
dplyr::full_join(treeObject(), geneObject(), by = "label")%>%
treeio::as.treedata()
})
treePlot <- function(inputFile){
ggtree::ggtree(inputFile, layout = treeformat())+
ggplot2::xlim(NA, lim())+
ggtree::geom_tiplab(align = align(), fontface = font(), family="Helvetica")
}
# treePlot <- reactive( {
# ggtree::ggtree(treeFileOut(), layout = treeformat())+
# ggplot2::xlim(NA, lim())+
# ggtree::geom_tiplab(align = align(), fontface = font(), family="Helvetica") +
# ggtree::geom_treescale(width = numscale())+
# ggtree::geom_text2(ggplot2::aes(label=label, subset = !is.na(as.numeric(label)) & as.numeric(label) > node()), nudge_x = 0.00025)
# })
#major plotting reactive using an S4 object called above (gandTS4) or the base midTree reactive made from import of treeFileOut and the Upload data module
makeTree <- reactive({treePlot(treeFileOut())})
return(
list(
makeTreeOut = reactive(makeTree())
))
# ## displayTree server functions
# treePlot <- function(inputFile){
# ggtree::ggtree(inputFile, layout = treeformat())+
# ggplot2::xlim(NA, lim())+
# ggtree::geom_tiplab(align = align(), fontface = font(), family="Helvetica") +
# ggtree::geom_treescale(width = numscale())+
# ggtree::geom_text2(ggplot2::aes(label=label, subset = !is.na(as.numeric(label)) & as.numeric(label) > node()), nudge_x = 0.00025)
#
# }
#
# midTree <- reactive({
# if(midP() == TRUE) {
# return(phytools::midpoint.root(treeFileOut()))
# }
# else {
# return(treeFileOut())
# }
# })
#
# #major plotting reactive using an S4 object called above (gandTS4) or the base midTree reactive made from import of treeFileOut and the Upload data module
# makeTree <- reactive({
#
# treePlot(treeFileOut())
#
# # if(midP((input$id)){ # this disconnects the need for genetic distance file to be uploaded.
# # treePlot(midTree())
# # }
# # else{
# # treePlot(gandTS4())
# # }
# })
#
# #return these reactive objects to be used in cladeAnnotator module
# return(
# list(
# geneObjectOut = reactive(geneObject()),
# makeTreeOut = reactive(makeTree())
# ))
}
## To be copied in the UI
# mod_displayTree_ui("displayTree_ui_1")
## To be copied in the server
# callModule(mod_displayTree_server, "displayTree_ui_1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.