Browse Source

Ordenar secciones.

BuiltinModules
marcelcosta 1 year ago
parent
commit
17d700e44e
1 changed files with 33 additions and 42 deletions
  1. +33
    -42
      scMonitor/app.R

+ 33
- 42
scMonitor/app.R

@ -26,18 +26,20 @@ ui <- fluidPage(
mainPanel( mainPanel(
plotOutput("umapPlot"), plotOutput("umapPlot"),
uiOutput("featPlotUI"),
uiOutput("mod_featPlotUI"),
uiOutput("featPlotUI")
) )
) )
) )
# Define server logic required to draw a histogram
# Define server logic
server <- function(input, output) { server <- function(input, output) {
## Defining reactive values
dades<-reactiveValues() dades<-reactiveValues()
dades$seu<-NULL dades$seu<-NULL
dades$mods<-NULL dades$mods<-NULL
## Conecting with file location and entering Seurat object
volumes <- c(Home = fs::path_home(), "R Installation" = R.home(), getVolumes()()) volumes <- c(Home = fs::path_home(), "R Installation" = R.home(), getVolumes()())
shinyFileChoose(input, 'file', roots=volumes) shinyFileChoose(input, 'file', roots=volumes)
@ -47,6 +49,7 @@ server <- function(input, output) {
} }
}) })
## Rendering UI depending on seu meta.data
output$groupby<-renderUI({ output$groupby<-renderUI({
if (!is.null(dades$seu)){ if (!is.null(dades$seu)){
selectInput("groupby", "GroupBy", c("Default", colnames(dades$seu@meta.data))) selectInput("groupby", "GroupBy", c("Default", colnames(dades$seu@meta.data)))
@ -59,6 +62,7 @@ server <- function(input, output) {
} }
}) })
## Render DimPlot
output$umapPlot <- renderPlot({ output$umapPlot <- renderPlot({
observeEvent(dades$seu, {}) observeEvent(dades$seu, {})
if (!is.null(dades$seu)){ if (!is.null(dades$seu)){
@ -70,11 +74,31 @@ server <- function(input, output) {
plot plot
} }
}) })
## Signature - Module Definition
observeEvent(input$modButton, {
if (input$modButton > 0){
mod_list<-strsplit(input$mod_feat, " ")[[1]]
mod_list<-mod_list[mod_list %in% rownames(dades$seu)]
dades$seu<-AddModuleScore(dades$seu,list(mod_list),
name=input$mod_name)
}
})
## FeaturePlot construction
query<-eventReactive(input$goButton,{ query<-eventReactive(input$goButton,{
dades$fet_query<-strsplit(input$features, " ")[[1]] dades$fet_query<-strsplit(input$features, " ")[[1]]
}) })
output$featPlotUI<- renderUI({
observeEvent(dades$fet_query, {})
if (!is.null(dades$seu)){
plotOutput("featPlot",
height = paste0(input$height/10,"px"))
}
})
## ModulePlot/SigPlot construction
query_mod<-eventReactive(input$goButton,{ query_mod<-eventReactive(input$goButton,{
if (length(strsplit(input$mods, " ")[[1]]) > 0){ if (length(strsplit(input$mods, " ")[[1]]) > 0){
dades$mods<-paste(strsplit(input$mods, " ")[[1]], "1", sep="") dades$mods<-paste(strsplit(input$mods, " ")[[1]], "1", sep="")
@ -83,14 +107,15 @@ server <- function(input, output) {
} }
}) })
output$featPlotUI<- renderUI({
observeEvent(dades$fet_query, {})
if (!is.null(dades$seu)){
plotOutput("featPlot",
output$modPlotUI<- renderUI({
observeEvent(dades$mod_name, {})
if (!is.null(dades$mod_name)){
plotOutput("modPlot",
height = paste0(input$height/10,"px")) height = paste0(input$height/10,"px"))
} }
}) })
## Feature/Mod plot rendering
output$featPlot<-renderPlot({ output$featPlot<-renderPlot({
observeEvent(input$goButton, {}) observeEvent(input$goButton, {})
if (!is.null(dades$seu)){ if (!is.null(dades$seu)){
@ -112,41 +137,7 @@ server <- function(input, output) {
do.call(ggarrange, c(plot, ncol=1)) do.call(ggarrange, c(plot, ncol=1))
} }
}) })
observeEvent(input$modButton, {
if (input$modButton > 0){
mod_list<-strsplit(input$mod_feat, " ")[[1]]
mod_list<-mod_list[mod_list %in% rownames(dades$seu)]
dades$seu<-AddModuleScore(dades$seu,list(mod_list),
name=input$mod_name)
}
})
# query_mod<-eventReactive(input$modButton,{
# dades$seu<-AddModuleScore(dades$seu,strsplit(input$mod_feat, " ")[[1]],
# name=input$mod_name)
# dades$mods<-if(is.null(dades$mods)){input$mod_name}else{c(dades$mods, input$mod_name)}
# print(input$mod_name)
# })
output$modPlotUI<- renderUI({
observeEvent(dades$mod_name, {})
if (!is.null(dades$mod_name)){
plotOutput("modPlot",
height = paste0(input$height/10,"px"))
}
})
output$modPlot<-renderPlot({
# observeEvent(dades$seu, {})
input$goButton
if (input$mods){
print(dades$mods)
FeaturePlot(dades$seu,
split.by=if(input$facetby != "None"){input$facetby}else{NULL},
features = dades$mods)&theme(aspect.ratio = 1)
}
})
} }

Loading…
Cancel
Save