Skip to content

Commit

Permalink
Merge pull request #749 from akshayarav/seurat_marker_genes
Browse files Browse the repository at this point in the history
Seurat marker genes
  • Loading branch information
joshua-d-campbell authored Apr 5, 2024
2 parents 37ffddb + 620934e commit 4b2c675
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 158 deletions.
241 changes: 91 additions & 150 deletions inst/shiny/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -1649,34 +1649,34 @@ shinyServer(function(input, output, session) {
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Dot Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Heatmap Plot")

appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "Ridge Plot",
panel(heading = "Ridge Plot",
appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "2D Embedding (Feature Plot)",
panel(heading = "Feature Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerRidgePlot")
plotOutput(outputId = "findMarkerFeaturePlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "Violin Plot",
panel(heading = "Violin Plot",
appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "Dot Plot",
panel(heading = "Dot Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerViolinPlot")
plotOutput(outputId = "findMarkerDotPlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "Feature Plot",
panel(heading = "Feature Plot",
appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "Ridge Plot",
panel(heading = "Ridge Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerFeaturePlot")
plotOutput(outputId = "findMarkerRidgePlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "Dot Plot",
panel(heading = "Dot Plot",
appendTab(inputId = "seuratFindMarkerPlotTabset", tabPanel(title = "Violin Plot",
panel(heading = "Violin Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerDotPlot")
plotOutput(outputId = "findMarkerViolinPlot")
)
)
)
Expand Down Expand Up @@ -8252,6 +8252,72 @@ shinyServer(function(input, output, session) {
shinyjs::enable(
selector = "#SeuratUI > div[value='Find Markers']")

shinyjs::enable(selector = "#SeuratUI > div[value='Marker Gene Plots']")

#MARKER SETTINGS
geneChoices <- rowData(vals$counts)$Symbol_TENx
updateSelectizeInput(session, "selectGenesMarkerPlots",
choices = geneChoices)

shinyjs::enable(selector = "#SeuratUI > div[value='Clustering']")

removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Ridge Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Violin Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "2D Embedding (Feature Plot)")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Dot Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Heatmap Plot")


appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "2D Embedding (Feature Plot)",
panel(heading = "Feature Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerFeaturePlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Dot Plot",
panel(heading = "Dot Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerDotPlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Ridge Plot",
panel(heading = "Ridge Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerRidgePlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Violin Plot",
panel(heading = "Violin Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerViolinPlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Heatmap Plot",
panel(heading = "Heatmap Plot",
fluidRow(
column(12, align = "center",
panel(
plotOutput(outputId = "findMarkerHeatmapPlot")
)
)
)
)
)
)
updateTabsetPanel(session = session, inputId = "seuratFindMarkerPlotTabset", selected = "2D Embedding (Feature Plot)")
#update colData names
updateColDataNames()

Expand Down Expand Up @@ -8350,78 +8416,6 @@ shinyServer(function(input, output, session) {
shinyjs::show(selector = ".seurat_findmarker_jointHeatmap")
shinyjs::show(selector = ".seurat_findmarker_plots")

removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Ridge Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Violin Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Feature Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Dot Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Heatmap Plot")

appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Ridge Plot",
panel(heading = "Ridge Plot",
fluidRow(
column(12, align = "center",
panel(
HTML(paste("<span style='color:red'>Select genes from the above table to plot!</span>"))
)
)
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Violin Plot",
panel(heading = "Violin Plot",
fluidRow(
column(12, align = "center",
panel(
HTML(paste("<span style='color:red'>Select genes from the above table to plot!</span>"))
)
)
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Feature Plot",
panel(heading = "Feature Plot",
fluidRow(
column(12, align = "center",
panel(
HTML(paste("<span style='color:red'>Select genes from the above table to plot!</span>"))
)
)
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Dot Plot",
panel(heading = "Dot Plot",
fluidRow(
column(12, align = "center",
panel(
HTML(paste("<span style='color:red'>Select genes from the above table to plot!</span>"))
)
)
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Heatmap Plot",
panel(heading = "Heatmap Plot",
fluidRow(
column(12, align = "center",
panel(
HTML(paste("<span style='color:red'>Select genes from the above table to plot!</span>"))
)
)
)
)
)
)

#df <- metadata(vals$counts)$seuratMarkers[which(metadata(vals$counts)$seuratMarkers$p_val_adj < 0.05, arr.ind = TRUE),]
df <- metadata(vals$counts)$seuratMarkers
seuratObject <- convertSCEToSeurat(vals$counts, normAssay = "seuratNormData")
Expand Down Expand Up @@ -8450,7 +8444,6 @@ shinyServer(function(input, output, session) {
}

showTab(inputId = "seuratFindMarkerPlotTabset", target = "Joint Heatmap Plot")
updateTabsetPanel(session = session, inputId = "seuratFindMarkerPlotTabset", selected = "Ridge Plot")
shinyjs::show(selector = ".seurat_findmarker_plots")

# Output the heatmap
Expand Down Expand Up @@ -8485,62 +8478,6 @@ shinyServer(function(input, output, session) {

updateCollapse(session = session, "SeuratUI", style = list("Downstream Analysis" = "info"))

removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Ridge Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Violin Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Feature Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Dot Plot")
removeTab(inputId = "seuratFindMarkerPlotTabset", target = "Heatmap Plot")

appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Ridge Plot",
panel(heading = "Ridge Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerRidgePlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Violin Plot",
panel(heading = "Violin Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerViolinPlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Feature Plot",
panel(heading = "Feature Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerFeaturePlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Dot Plot",
panel(heading = "Dot Plot",
shinyjqui::jqui_resizable(
plotOutput(outputId = "findMarkerDotPlot")
)
)
)
)
appendTab(inputId = "seuratFindMarkerPlotTabset",
tabPanel(title = "Heatmap Plot",
panel(heading = "Heatmap Plot",
fluidRow(
column(12, align = "center",
panel(
plotOutput(outputId = "findMarkerHeatmapPlot")
)
)
)
)
)
)

#singleCellTK:::.exportMetaSlot(vals$counts, "seuratMarkers")

orderByLFCMarkers <- metadata(vals$counts)$seuratMarkers
Expand All @@ -8554,6 +8491,10 @@ shinyServer(function(input, output, session) {
defaultFilterValues = c("0.05"),
topText = "You can view the marker genes in the table below and apply custom filters to filter the table accordingly. A joint heatmap for all the marker genes available in the table is plotted underneath the table. Additional visualizations are plotted for select genes which can be selected by clicking on the rows of the table."
)

shinyjs::enable(selector = "#SeuratUI > div[value='Clustering']")


# vals$fts <- callModule(
# module = filterTableServer,
# id = "filterSeuratFindMarker",
Expand Down Expand Up @@ -8609,14 +8550,12 @@ shinyServer(function(input, output, session) {
}))

observe({
req(vals$fts$data)
req(vals$fts$selectedRows)
df <- vals$fts$data[vals$fts$selectedRows, ]
req(input$selectGenesMarkerPlots)
output$findMarkerRidgePlot <- renderPlot({
plotSeuratGenes(
inSCE = vals$counts,
plotType = "ridge",
features = df$gene_id,
features = input$selectGenesMarkerPlots,
groupVariable = input$seuratFindMarkerSelectPhenotype,
ncol = 2,
combine = TRUE
Expand All @@ -8626,7 +8565,7 @@ shinyServer(function(input, output, session) {
plotSeuratGenes(
inSCE = vals$counts,
plotType = "violin",
features = df$gene_id,
features = input$selectGenesMarkerPlots,
groupVariable = input$seuratFindMarkerSelectPhenotype,
ncol = 2,
combine = TRUE
Expand All @@ -8636,7 +8575,7 @@ shinyServer(function(input, output, session) {
plotSeuratGenes(
inSCE = vals$counts,
plotType = "feature",
features = df$gene_id,
features = input$selectGenesMarkerPlots,
groupVariable = input$seuratFindMarkerSelectPhenotype,
ncol = 2,
combine = TRUE,
Expand All @@ -8647,15 +8586,15 @@ shinyServer(function(input, output, session) {
plotSeuratGenes(
inSCE = vals$counts,
plotType = "dot",
features = df$gene_id,
features = input$selectGenesMarkerPlots,
groupVariable = input$seuratFindMarkerSelectPhenotype
)
})
output$findMarkerHeatmapPlot <- renderPlot({
plotSeuratGenes(
inSCE = vals$counts,
plotType = "heatmap",
features = df$gene_id,
features = input$selectGenesMarkerPlots,
groupVariable = input$seuratFindMarkerSelectPhenotype
)
})
Expand Down Expand Up @@ -8723,7 +8662,6 @@ shinyServer(function(input, output, session) {
})
})
updateCollapse(session = session, "SeuratUI", style = list("2D-Embedding" = "success"))
shinyjs::enable(selector = "#SeuratUI > div[value='Clustering']")
S4Vectors::metadata(vals$counts)$seuratMarkers <- NULL
shinyjs::hide(
selector = "div[value='Downstream Analysis']")
Expand Down Expand Up @@ -9013,6 +8951,9 @@ shinyServer(function(input, output, session) {
shinyjs::disable(
selector = "#ScanpyUI > div[value='Clustering']")

shinyjs::disable(
selector = "#SeuratUI > div[value='Marker Gene Plots']")

shinyjs::disable(
selector = "#SeuratUI > div[value='Scale Data']")
shinyjs::disable(
Expand Down
29 changes: 21 additions & 8 deletions inst/shiny/ui_09_2_seuratWorkflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,27 @@ shinyPanelSeurat <- fluidPage(
)
),
style = "primary"),
bsCollapsePanel("Marker Gene Plots",
fluidRow(
column(12,
fluidRow(
column(12,
panel(heading = "Options",
selectizeInput("selectGenesMarkerPlots", "Select a gene:", choices = NULL, multiple = TRUE, options = list('plugins' = list('remove_button'), server = TRUE)),
)
)
)
),
column(12,
tags$div(class = "seurat_findmarker_plots",
panel(heading = "",
HTML("<center><h5><span style='color:red; font-weight:bold; text-align:center;'>Select marker genes above to plot them below!</span></h5></br></center>"),
tabsetPanel(id = "seuratFindMarkerPlotTabset", type = "tabs"))
)
)
),
style = "primary"
),
bsCollapsePanel("Find Markers",
fluidRow(
column(4,
Expand Down Expand Up @@ -378,14 +399,6 @@ shinyPanelSeurat <- fluidPage(
)
)
),
br(),
hidden(
tags$div(class = "seurat_findmarker_plots",
panel(heading = "Marker Gene Plots",
HTML("<center><h5><span style='color:red; font-weight:bold; text-align:center;'>Click on the rows of the table above to plot the selected marker genes below!</span></h5></br></center>"),
tabsetPanel(id = "seuratFindMarkerPlotTabset", type = "tabs"))
)
)
)

)
Expand Down

0 comments on commit 4b2c675

Please sign in to comment.