Visor scRNAseq.
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
library(shiny)
|
library(shiny)
|
||||||
library(rhandsontable)
|
library(rhandsontable)
|
||||||
|
library(tidyverse)
|
||||||
|
library(reshape2)
|
||||||
|
library(Matrix)
|
||||||
|
library(CitFuns)
|
||||||
|
|
||||||
print(getwd())
|
print(getwd())
|
||||||
source("../sqlFunctions.R", encoding = "UTF-8")
|
source("../sqlFunctions.R", encoding = "UTF-8")
|
||||||
@@ -59,6 +63,19 @@ ui <- fluidPage(
|
|||||||
h3("Nitrogen"),
|
h3("Nitrogen"),
|
||||||
tableOutput("nitrogen")
|
tableOutput("nitrogen")
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
tabPanel("scRNAseq",
|
||||||
|
sidebarPanel(
|
||||||
|
textInput("sqlquery", label = "sqlquery", value = ""),
|
||||||
|
uiOutput("PATID"),
|
||||||
|
checkboxInput("cd45_chk", "Purificación CD45")
|
||||||
|
),
|
||||||
|
mainPanel(
|
||||||
|
tabsetPanel(
|
||||||
|
tabPanel("Table", tableOutput("sc_table")),
|
||||||
|
tabPanel("Plots", plotOutput("sc_plot"))
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -677,6 +694,56 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
## scRNAseq
|
## scRNAseq
|
||||||
|
|
||||||
|
output$PATID = renderUI({
|
||||||
|
observeEvent(input$goButton, {})
|
||||||
|
sc_cod<-sqlFetch(dta, "CNAG") %>% pull(CODIGO)
|
||||||
|
selectizeInput("sc_cod", "CÓDIGO", sc_cod, multiple = T)
|
||||||
|
})
|
||||||
|
|
||||||
|
output$sc_table<-renderTable({
|
||||||
|
if (input$sqlquery != ""){
|
||||||
|
print(input$sqlquery)
|
||||||
|
sqlQuery(dta, input$sqlquery)
|
||||||
|
}else{
|
||||||
|
if (!is.null(input$sc_cod)){
|
||||||
|
sqlFetch(dta, "CNAG") %>% filter(CODIGO %in% input$sc_cod)
|
||||||
|
}else{
|
||||||
|
sqlFetch(dta, "CNAG")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
output$sc_plot <-renderPlot({
|
||||||
|
meta<-readRDS(paste0(scRNAseqRoute,"metadata_full_object.rds"))
|
||||||
|
|
||||||
|
if (input$sqlquery != ""){
|
||||||
|
sc_codigos<-sqlQuery(dta, input$sqlquery) %>% pull(CNAG_NAME)
|
||||||
|
}else{
|
||||||
|
if (!is.null(input$sc_cod)){
|
||||||
|
sc_codigos<-sqlFetch(dta, "CNAG") %>% filter(CODIGO %in% input$sc_cod) %>% pull(CNAG_NAME)
|
||||||
|
}else{
|
||||||
|
sc_codigos<-sqlFetch(dta, "CNAG") %>% pull(CNAG_NAME)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sc_codigos<-gsub(" _","_", sc_codigos )
|
||||||
|
sc_codigos<-gsub("_ ","_", sc_codigos )
|
||||||
|
sc_codigos<-gsub(" ","_", sc_codigos )
|
||||||
|
|
||||||
|
meta<-meta %>% mutate(sample2=gsub("_CD45", "", sample)) %>% filter(sample2 %in% sc_codigos)
|
||||||
|
if (isFALSE(input$cd45_chk)){ meta<-meta %>% filter(!grepl("_CD45", sample))}
|
||||||
|
|
||||||
|
g1<-ggplot(meta, aes(coord_x, coord_y, color=predicted.id))+
|
||||||
|
geom_point(size=0.2)+
|
||||||
|
guides(colour = guide_legend(override.aes = list(size=2)))+
|
||||||
|
theme_bw()+
|
||||||
|
theme(aspect.ratio = 1)
|
||||||
|
|
||||||
|
meta_perc<-meta %>% group_by(sample, predicted.id) %>% summarise(N=n()) %>% mutate(N=perc(N)) %>%
|
||||||
|
spread(predicted.id, N) %>% gather("predicted.id","N",-sample) %>% mutate(N=case_when(is.na(N)~0,TRUE~N))
|
||||||
|
g2<-ggheatmap(meta_perc, "sample","predicted.id", "N", color = "grey50")
|
||||||
|
ggpubr::ggarrange(g1,g2, ncol=1, heights = c(0.3, 0.7))
|
||||||
|
}, height = 1000)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
|
|||||||
Reference in New Issue
Block a user