Assuming the rest of the app works you can use the selectInput()
to change the data. It looks like the DE test is loaded at the read.table
call? If that's true you can do:
ui <-
## your code before ...
selectInput(inputId= 'DEtest', label='Pick a timepoint!', choices = c("3","7","24"...etc))
## your code after ...
server <-
## your code before ...
## make filename reactive
inputFile = reactive({
paste0("Annotated_Time", input$DEtest,"_ICL004.txt")
})
output$volcanoPlot <- renderPlotly({
## I moved these into the rednerPlotly function
differentialExpressionResults <- read.table(inputFile(), stringsAsFactors = FALSE, header = TRUE) %>%
mutate(
minusLog10Pvalue = -log10(P),
tooltip = ifelseis.na(gene_symbol), probe, paste(gene_symbol, " (", probe, ")", sep = ""))
) %>%
sample_n(16667)
plot <- differentialExpressionResults %>%
ggplot(aes(x = logFC,
y = minusLog10Pvalue,
colour = Pattern_number,
text = tooltip,
key = row.names(differentialExpressionResults))) +
geom_point() +
xlab("log fold change") +
ylab("-log10(P-value)")
plot %>%
ggplotly(tooltip = "tooltip") %>%
layout(dragmode = "select")
})
## your code after
Note I moved the read.table()
and ensuing functions into the renderPloty so they are reactive. Otherwise you have to wrap them in reactive({})
Edit: filled out function and I shouldn't have used file
as a variable name so is now inputFile
.
What does this have to do with bioinformatics, please?
I'm happy to explain, Michael. Bioinformatics is an interdisciplinary field and according to me if we're trying to solve a biological problem with a programmatic approach I consider it to be a bioinformatics problem. Since I'm working with biological data/ expression data I think it is relevant to call it a bioinformatics issue. Please let me know if you have any other concerns. Thanks!
Sorry, this was not evident from the original post.
I fixed the URL in your post here
As for your problem, its hard to know for sure without seeing an example of your data, but I would suggest adding an extra column in your dataframe for a time-point factor level (e.g.
timepoint
) for each entry, and then include faceting as described here;This should give you multiple plots side-by-side, one for each factor level.
Alternatively, you could adjust the
color
,fill
, orgroup
to use the newtimepoint
factor level, though this would be more confusing to look at since all points for alltimepoint
's would be displayed in the same plot.Thanks for your reply Steve and sorry if I was not clear asking the question. Here I include the headers of the dataframe as an example as the data is really huge.
probe gene_symbol Timepoint0_FC Timepoint0_P Timepoint3_FC Timepoint3_P Timepoint7_F Timepoint7_P
Here FC is the foldchange and P is the adj. p. value for each timepoint mentioned there ie 0, 3, 7,.., 24. I'm actually working with the second part of the code mentioned in the link and named as Plotly, where the author uses plotly and ggplot to make the interactive volcano plot (https://bioinformatics-core-shared-training.github.io/shiny-bioinformatics/interactive-plots). I kind of got the script to work with just one timepoint.
I don't intend to show all the timepoint data at once but want to implement in the control widgets as a select box feature shown in this link (https://shiny.rstudio.com/tutorial/written-tutorial/lesson3/) implemented using selectinput() where we can list out the options that the user wishes to chose. For example if the user selects timepoint_3 the plot should display FC vs P of timepoint 3 which is extracted from the dataframe above. This is my thought behind it, but I'm not sure how to implement it. Thanks for looking into it.
Here is the code that I used for just one timepoint.
Please use
ADD COMMENT/ADD REPLY
when responding to existing posts to keep threads logically organized.You can always add new information to your original/existing posts by editing.
Submit Answers
should only be used for answers for the original question.