Hello,
I have a dataset that lists Gene 1, Gene 2, and their correlation value. Using Shiny DT, I'm able to call this data and it looks like this :
The code to generate it :
library(shiny)
library(DT)
# Define UI for application that creates a datatables
ui <- fluidPage(fluidRow(selectInput("TheFile", "Select Cohort",
choices = c("Test_Dataset1.csv", "Test_Dataset2.csv", "Test_Dataset3.csv.csv"))),
fluidRow(column(12, div(dataTableOutput("dataTable")))),
# Application title
titlePanel("Download Datatable")
# Show a plot of the generated distribution
, mainPanel(
DT::dataTableOutput("fancyTable")
) # end of main panel
) # end of fluid page
# Define server logic required to create datatable
server <- function(input, output, session) {
myCSV <- reactive({
read.csv(input$TheFile)
})
output$fancyTable <- DT::renderDataTable(
datatable( data = myCSV()
, extensions = 'Buttons'
, options = list(
dom = "Blfrtip"
, buttons =
list("copy", list(
extend = "collection"
, buttons = c("csv", "excel", "pdf")
, text = "Download"
) ) # end of buttons customization
# customize the length menu
, lengthMenu = list( c(10, 20, -1) # declare values
, c(10, 20, "All") # declare titles
) # end of lengthMenu customization
, pageLength = 10
) # end of options
) # end of datatables
)
} # end of server
# Run the application
shinyApp(ui = ui, server = server)
Next I have another dataset called "Expression". For every Gene it has expression values, several samples for every gene.
If I reference the Expression dataset, I can use ggplot2 to make a scatterplot.
Which was made with by manually typing in the names of Gene1 and Gene 2 like this:
ggplot(Expression, aes(x=Gene1, y=Gene2)) + geom_point(size=2) + geom_smooth(method=lm, size=2) + geom_rug(col="darkred", size=0.9, sides="bl", alpha = 0.3)
My question :
How can I have a user select an entry (pair of genes) from the first data table and then have R lookup those two genes on the Expression table (in the background) , then use the code I've listed with ggplot2 to make a corresponding scatterplot?
Any help towards the right direction in much appreciated!