Commit 5eb5c846 authored by Lena Hersemann's avatar Lena Hersemann

replaced radioButton() by selectInput(); now all cluster information will be...

replaced radioButton() by selectInput(); now all cluster information will be converted to factor and are also available to explore quality metrics per cluster
parent 43782cdc
......@@ -41,6 +41,9 @@ infos <- if(file.exists(file.path(dataPath, "scater_quality_metrics.txt"))) {
read_tsv(file.path(dataPath, "cell_infos.txt"))
}
# convert any clustering information to factor
infos[, which(str_detect(colnames(infos), "cluster"))] <- lapply(infos[, which(str_detect(colnames(infos), "cluster"))], factor)
# extract information on numeric values for the violin plots
infos_num <- infos %>% column_to_rownames("cell_id") %>% select_if(is.numeric) %>% mutate(cell_id = rownames(.)) %>%
push_left("cell_id") %>% gather(feature, value, -cell_id) %>% mutate(type = "numeric") %>% na.omit()
......@@ -53,12 +56,8 @@ infos <- rbind(infos_num, infos_char)
# select metrics suitable for subsetting and prepare radioButtons choices
info_groups <- infos %>% filter(type == "non_numeric") %>% select(-cell_id) %>% group_by(feature) %>% unique() %>% summarize(count = n()) %>% filter(between(count, 2,5)) %$% feature
radio_choices <- lapply(setNames(info_groups, info_groups), function(x) {
which(info_groups == x)
})
radio_choices <- list.append(radio_choices, "no subsetting" = length(radio_choices) + 1)
radio_choices <- infos %>% filter(type == "non_numeric") %>% select(-cell_id) %>% group_by(feature) %>% unique() %>% summarize(count = n()) %>% filter(count > 2) %$% feature
radio_choices <- c("no subsetting", radio_choices)
select_choices <- infos %>% filter(type == "numeric")
......@@ -81,9 +80,9 @@ app <- shinyApp(
multiple = TRUE, selectize=TRUE),
br(),
br(),
radioButtons("choosen_subsetting", label = "Choose data subsetting",
selectInput("choosen_subsetting", label = "Choose data subsetting",
choices = radio_choices,
selected = length(radio_choices)),
selected = radio_choices[1], multiple = F),
br(),
tableOutput(outputId = "subset_summary")
),
......@@ -133,11 +132,11 @@ app <- shinyApp(
infos_features <- infos %>% filter(feature %in% input$choosen_metric & type == "numeric")
# infos_features <- infos %>% filter(feature %in% c("nUMI", "nGene"))
if (input$choosen_subsetting == length(radio_choices)) {
if (input$choosen_subsetting == radio_choices[1]) {
vp <- infos_features %>% ggplot(aes(feature, as.numeric(value))) + geom_violin() +
xlab("") + facet_wrap(~feature, scale = "free", ncol = 2)
} else {
subset_var <- radio_choices[as.numeric(input$choosen_subsetting)] %>% names()
subset_var <- input$choosen_subsetting
infos_subset <- infos %>% filter(feature == subset_var) %>% select(cell_id, value)
# infos_subset <- infos %>% filter(feature == "phase") %>% select(cell_id, value)
colnames(infos_subset) <- c("cell_id", "subsets")
......@@ -159,8 +158,9 @@ app <- shinyApp(
}, height = function(){400*ceiling(length(input$choosen_metric)/2)})
output$subset_summary <- renderTable({
if (input$choosen_subsetting != length(radio_choices)){
if (input$choosen_subsetting != radio_choices[1]){
subset_var <- radio_choices[as.numeric(input$choosen_subsetting)] %>% names()
subset_var <- input$choosen_subsetting
# subset_var <- radio_choices[as.numeric("2")] %>% names()
infos_sum <- infos %>% filter(feature == subset_var) %>% count(value)
colnames(infos_sum) <- c(subset_var, "count")
......
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