Commit 94e88239 authored by Lena Hersemann's avatar Lena Hersemann

added violin plot to visualize gene expression of the individual clusters; cosmetics

parent b9755a53
......@@ -152,6 +152,7 @@ app <- shinyApp(
tabPanel("TSNE",
radioButtons("vis_method", label = "", choiceNames = c("expression", "cluster"), choiceValues = c("expression", "cluster"), inline = TRUE, selected = "expression"),
plotOutput(outputId = "tsne", height = "auto")),
tabPanel("Violin plot", plotOutput(outputId = "violin", height = "auto")),
tabPanel("Heatmap", plotOutput(outputId = "heatmap", height = 800))
)
)
......@@ -307,6 +308,27 @@ app <- shinyApp(
plotting_violin <- function(data) {
plot_rows <- if (length(selected_samples()) > 1) { floor(length( selected_samples() )/2) } else { as.numeric(1) }
lapply(append(selected_samples(), "legend"), function(x){
data %>%
filter(str_detect(cluster_name, x)) %>%
ggplot(aes(as.factor(cluster_num), score, fill = as.factor(cluster_num))) +
geom_violin() +
theme(legend.position="none") +
xlab("") +
ggtitle(paste(x))
}) %>% grid.arrange(grobs = ., nrow = plot_rows)
}
output$violin <- renderPlot({ plotting_violin(outHeatmapData()) },
height = function(){400* if (length(selected_samples()) > 1) { floor(length( selected_samples() )/2) } else { as.numeric(1.5) }})
plotting_tsne <- function(data, vis_mode){
plot_rows <- if (length(selected_samples()) > 1) { floor(length( selected_samples() )/2) } else { as.numeric(1) }
......@@ -319,7 +341,8 @@ app <- shinyApp(
geom_point(size = 0.2) +
guides(colour = guide_legend(override.aes = list(size=5), title="cluster")) +
coord_fixed() +
ggtitle(x)
ggtitle(x) #+
#geom_encircle(aes(x = tSNE_1, y = tSNE_2), subset_data, expand = 0.01)
}else if (vis_mode == "expression"){
data[ which(data$cluster_name == x),] %>%
......@@ -335,9 +358,9 @@ app <- shinyApp(
}
output$tsne <- renderPlot({
ph <-
plot_to_draw <- plotting_tsne(outHeatmapData(), input$vis_method)
plot_to_draw
plotting_tsne(outHeatmapData(), input$vis_method)
# plot_to_draw <- plotting_tsne(outHeatmapData(), input$vis_method)
# plot_to_draw
}, height = function(){400* if (length(selected_samples()) > 1) { floor(length( selected_samples() )/2) } else { as.numeric(1.5) }})
......
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