Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 17d700e44e | |||
| e185aa2935 |
+67
-14
@@ -15,8 +15,13 @@ ui <- fluidPage(
|
|||||||
uiOutput('groupby'),
|
uiOutput('groupby'),
|
||||||
uiOutput('facetby'),
|
uiOutput('facetby'),
|
||||||
textInput('features', label = "Genes"),
|
textInput('features', label = "Genes"),
|
||||||
|
textInput('mods', label = "Signatures"),
|
||||||
actionButton("goButton", "Query"),
|
actionButton("goButton", "Query"),
|
||||||
sliderInput("height", "Altura", min=1000, max=20000, step=1000, value=6000)
|
sliderInput("height", "Altura", min=1000, max=20000, step=1000, value=6000),
|
||||||
|
h3("Add Signature"),
|
||||||
|
textInput('mod_name', label = "Name"),
|
||||||
|
textInput('mod_feat', label = "Genes"),
|
||||||
|
actionButton("modButton", "Add Signature")
|
||||||
),
|
),
|
||||||
|
|
||||||
mainPanel(
|
mainPanel(
|
||||||
@@ -26,11 +31,15 @@ ui <- fluidPage(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
## 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)
|
||||||
|
|
||||||
@@ -40,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)))
|
||||||
@@ -52,10 +62,7 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
query<-eventReactive(input$goButton,{
|
## Render DimPlot
|
||||||
dades$fet_query<-strsplit(input$features, " ")[[1]]
|
|
||||||
})
|
|
||||||
|
|
||||||
output$umapPlot <- renderPlot({
|
output$umapPlot <- renderPlot({
|
||||||
observeEvent(dades$seu, {})
|
observeEvent(dades$seu, {})
|
||||||
if (!is.null(dades$seu)){
|
if (!is.null(dades$seu)){
|
||||||
@@ -68,6 +75,21 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
## 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,{
|
||||||
|
dades$fet_query<-strsplit(input$features, " ")[[1]]
|
||||||
|
})
|
||||||
|
|
||||||
output$featPlotUI<- renderUI({
|
output$featPlotUI<- renderUI({
|
||||||
observeEvent(dades$fet_query, {})
|
observeEvent(dades$fet_query, {})
|
||||||
if (!is.null(dades$seu)){
|
if (!is.null(dades$seu)){
|
||||||
@@ -76,16 +98,47 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
output$featPlot<-renderPlot({
|
## ModulePlot/SigPlot construction
|
||||||
observeEvent(dades$seu, {})
|
query_mod<-eventReactive(input$goButton,{
|
||||||
if (!is.null(dades$seu)){
|
if (length(strsplit(input$mods, " ")[[1]]) > 0){
|
||||||
query()
|
dades$mods<-paste(strsplit(input$mods, " ")[[1]], "1", sep="")
|
||||||
|
}else{
|
||||||
FeaturePlot(dades$seu,
|
dades$mods<-NULL
|
||||||
split.by=if(input$facetby != "None"){input$facetby}else{NULL},
|
|
||||||
features = dades$fet_query)&theme(aspect.ratio = 1)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
output$modPlotUI<- renderUI({
|
||||||
|
observeEvent(dades$mod_name, {})
|
||||||
|
if (!is.null(dades$mod_name)){
|
||||||
|
plotOutput("modPlot",
|
||||||
|
height = paste0(input$height/10,"px"))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
## Feature/Mod plot rendering
|
||||||
|
output$featPlot<-renderPlot({
|
||||||
|
observeEvent(input$goButton, {})
|
||||||
|
if (!is.null(dades$seu)){
|
||||||
|
query()
|
||||||
|
plot<-list()
|
||||||
|
print(dades$fet_query)
|
||||||
|
if (length(dades$fet_query) > 0){
|
||||||
|
plot[["Genes"]]<-FeaturePlot(dades$seu,
|
||||||
|
split.by=if(input$facetby != "None"){input$facetby}else{NULL},
|
||||||
|
features = dades$fet_query)&theme(aspect.ratio = 1)
|
||||||
|
}
|
||||||
|
query_mod()
|
||||||
|
print(dades$mods)
|
||||||
|
if (length(dades$mods) > 0){
|
||||||
|
plot[["Mods"]]<-FeaturePlot(dades$seu,
|
||||||
|
split.by=if(input$facetby != "None"){input$facetby}else{NULL},
|
||||||
|
features = dades$mods)&theme(aspect.ratio = 1)&scale_color_viridis_c()
|
||||||
|
}
|
||||||
|
do.call(ggarrange, c(plot, ncol=1))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
|
|||||||
Reference in New Issue
Block a user