Soporte para Modulos (Signaturas).
This commit is contained in:
+71
-9
@@ -15,13 +15,19 @@ 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(
|
||||||
plotOutput("umapPlot"),
|
plotOutput("umapPlot"),
|
||||||
uiOutput("featPlotUI")
|
uiOutput("featPlotUI"),
|
||||||
|
uiOutput("mod_featPlotUI"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -30,6 +36,7 @@ ui <- fluidPage(
|
|||||||
server <- function(input, output) {
|
server <- function(input, output) {
|
||||||
dades<-reactiveValues()
|
dades<-reactiveValues()
|
||||||
dades$seu<-NULL
|
dades$seu<-NULL
|
||||||
|
dades$mods<-NULL
|
||||||
|
|
||||||
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)
|
||||||
@@ -52,10 +59,6 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
query<-eventReactive(input$goButton,{
|
|
||||||
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 +71,18 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
query<-eventReactive(input$goButton,{
|
||||||
|
dades$fet_query<-strsplit(input$features, " ")[[1]]
|
||||||
|
})
|
||||||
|
|
||||||
|
query_mod<-eventReactive(input$goButton,{
|
||||||
|
if (length(strsplit(input$mods, " ")[[1]]) > 0){
|
||||||
|
dades$mods<-paste(strsplit(input$mods, " ")[[1]], "1", sep="")
|
||||||
|
}else{
|
||||||
|
dades$mods<-NULL
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
output$featPlotUI<- renderUI({
|
output$featPlotUI<- renderUI({
|
||||||
observeEvent(dades$fet_query, {})
|
observeEvent(dades$fet_query, {})
|
||||||
if (!is.null(dades$seu)){
|
if (!is.null(dades$seu)){
|
||||||
@@ -77,15 +92,62 @@ server <- function(input, output) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
output$featPlot<-renderPlot({
|
output$featPlot<-renderPlot({
|
||||||
observeEvent(dades$seu, {})
|
observeEvent(input$goButton, {})
|
||||||
if (!is.null(dades$seu)){
|
if (!is.null(dades$seu)){
|
||||||
query()
|
query()
|
||||||
|
plot<-list()
|
||||||
FeaturePlot(dades$seu,
|
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},
|
split.by=if(input$facetby != "None"){input$facetby}else{NULL},
|
||||||
features = dades$fet_query)&theme(aspect.ratio = 1)
|
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))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
|
|||||||
Reference in New Issue
Block a user