Commit 048044cf authored by Midoux Cedric's avatar Midoux Cedric
Browse files

deseq detail in comment

parent 4ce63864
......@@ -81,60 +81,44 @@ results <- metaReactive2({
if (class(get_variable(data, input$deseqContrastVar)) == "numeric") {
# First case: regression against a continuous variable
metaExpr({
DESeq2::results(object = ..(dds()),
name = ..(input$deseqContrastVar),
tidy = TRUE) %>%
r <- DESeq2::results(object = ..(dds()),
name = ..(input$deseqContrastVar),
tidy = TRUE) %>%
as_tibble() %>%
rename(OTU = row) %>%
inner_join(tax_table(data) %>% as("matrix") %>% as_tibble(rownames = "OTU"), by = "OTU")
})
comment(r) <- ..(paste0("You compare low and high values of the continuous variable ", input$deseqContrastVar, ".\nA positive log2FoldChange means more abundant for high values of ", input$deseqContrastVar, "."))
r
}, bindToReturn = TRUE)
} else {
validate(need(length(input$deseqContrastMod) == 2, "Invalid input."))
if (length(levels(get_variable(data, input$deseqContrastVar))) == 2) {
# Second case: regression against a binary variable
metaExpr({
DESeq2::results(object = ..(dds()),
name = ..(DESeq2::resultsNames(..(dds()))[-1]),
tidy = TRUE) %>%
r <- DESeq2::results(object = ..(dds()),
name = ..(DESeq2::resultsNames(..(dds()))[-1]),
tidy = TRUE) %>%
as_tibble() %>% rename(OTU = row) %>%
inner_join(tax_table(data) %>% as("matrix") %>% as_tibble(rownames = "OTU"), by = "OTU")
})
comment(r) <- ..(paste0("You compare ", input$deseqContrastMod[1], " to ", input$deseqContrastMod[2], " for the variable ", input$deseqContrastVar, ".\nA positive log2FoldChange means more abundant in ", input$deseqContrastMod[2], " than in ", input$deseqContrastMod[1], "."))
r
}, bindToReturn = TRUE)
} else {
# Third case: regression against a qualiative variable with three or more levels
metaExpr({
DESeq2::results(object = ..(dds()),
contrast = ..(c(input$deseqContrastVar, input$deseqContrastMod[1], input$deseqContrastMod[2])),
tidy = TRUE) %>%
r <- DESeq2::results(object = ..(dds()),
contrast = ..(c(input$deseqContrastVar, input$deseqContrastMod[1], input$deseqContrastMod[2])),
tidy = TRUE) %>%
as_tibble() %>% rename(OTU = row) %>%
inner_join(tax_table(data) %>% as("matrix") %>% as_tibble(rownames = "OTU"), by = "OTU")
})
comment(r) <- ..(paste0("You choose to compare ", input$deseqContrastMod[1], " to ", input$deseqContrastMod[2], " for the variable", input$deseqContrastVar, ".\nA positive log2FoldChange means more abundant in ", input$deseqContrastMod[1], " than in ", input$deseqContrastMod[2], "."))
r
}, bindToReturn = TRUE)
}
}
})
detail <-metaReactive2({
data <- physeq()
if (class(get_variable(data, input$deseqContrastVar)) == "numeric") {
# First case
metaExpr({
..(paste0("You compare low and high values of the continuous variable ", input$deseqContrastVar, ".\nA positive log2FoldChange means more abundant for high values of ", input$deseqContrastVar, "."))
})
} else {
if (length(levels(get_variable(data, input$deseqContrastVar))) == 2) {
# Second case
metaExpr({
..(paste0("You compare ", input$deseqContrastMod[1], " to ", input$deseqContrastMod[2], " for the variable ", input$deseqContrastVar, ".\nA positive log2FoldChange means more abundant in ", input$deseqContrastMod[2], " than in ", input$deseqContrastMod[1], "."))
})
} else {
# Third case
metaExpr({
..(paste0("You choose to compare ", input$deseqContrastMod[1], " to ", input$deseqContrastMod[2], " for the variable", input$deseqContrastVar, ".\nA positive log2FoldChange means more abundant in ", input$deseqContrastMod[1], " than in ", input$deseqContrastMod[2], "."))
})
}
}
})
output$deseq <- metaRender2(renderPlot, {
validate(
......@@ -157,7 +141,7 @@ output$deseq <- metaRender2(renderPlot, {
theme_bw(base_size = 16) + # clean up theme
theme(legend.position = "none", # remove legend
plot.subtitle = element_text(size = 12)) + # add subtitle
ggtitle(label = ..(input$deseqTitle), subtitle = ..(detail())) + # add informative title
ggtitle(label = ..(input$deseqTitle), subtitle = comment(..(results()))) + # add informative title
xlab(expression(log[2]("FoldChange"))) + # x-axis label
ylab(expression(-log[10]("adjusted p-value"))) + # y-axis label
geom_vline(xintercept = 0, colour = "grey80", linetype = 2) + # add line at 0
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment