Añadido plot para expresión de genes.
This commit is contained in:
+54
-11
@@ -68,12 +68,16 @@ ui <- fluidPage(
|
||||
sidebarPanel(
|
||||
textInput("sqlquery", label = "sqlquery", value = ""),
|
||||
uiOutput("PATID"),
|
||||
checkboxInput("cd45_chk", "Purificación CD45")
|
||||
checkboxInput("sct_sel", "Mostrar filtrados"),
|
||||
checkboxInput("cd45_chk", "Purificación CD45"),
|
||||
textInput("genes", label="genes", value = "")
|
||||
),
|
||||
mainPanel(
|
||||
tabsetPanel(
|
||||
tabPanel("Table", tableOutput("sc_table")),
|
||||
tabPanel("Plots", plotOutput("sc_plot"))
|
||||
tabPanel("Plots",
|
||||
plotOutput("sc_plot", height = "1000px"),
|
||||
plotOutput("sc_expr"), height = "600px")
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -701,20 +705,25 @@ server <- function(input, output) {
|
||||
})
|
||||
|
||||
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)
|
||||
if (input$sct_sel){
|
||||
if (input$sqlquery != ""){
|
||||
print(input$sqlquery)
|
||||
sqlQuery(dta, input$sqlquery)
|
||||
}else{
|
||||
sqlFetch(dta, "CNAG")
|
||||
if (!is.null(input$sc_cod)){
|
||||
sqlFetch(dta, "CNAG") %>% filter(CODIGO %in% input$sc_cod)
|
||||
}else{
|
||||
sqlFetch(dta, "CNAG")
|
||||
}
|
||||
}
|
||||
}else{
|
||||
sqlFetch(dta, "CNAG")
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
output$sc_plot <-renderPlot({
|
||||
meta<-readRDS(paste0(scRNAseqRoute,"metadata_full_object.rds"))
|
||||
meta<<-readRDS(paste0(scRNAseqRoute,"metadata_full_object.rds"))
|
||||
|
||||
if (input$sqlquery != ""){
|
||||
sc_codigos<-sqlQuery(dta, input$sqlquery) %>% pull(CNAG_NAME)
|
||||
@@ -742,8 +751,42 @@ server <- function(input, output) {
|
||||
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)
|
||||
})
|
||||
|
||||
output$sc_expr <-renderPlot({
|
||||
if (input$genes != ""){
|
||||
expr<-readRDS(paste0(scRNAseqRoute,"expression_full_object.rds"))
|
||||
genes<-strsplit(input$genes, ",")[[1]]
|
||||
|
||||
if (length(genes) > 1){
|
||||
df.expr<-as.data.frame(as.matrix(expr[genes,]))
|
||||
df.expr["Gene"]<-rownames(df.expr)
|
||||
mdf.expr<-melt(df.expr)
|
||||
}else{
|
||||
df.expr<-as.data.frame(t(as.matrix(expr[genes[1],])))
|
||||
df.expr["Gene"]<-genes[1]
|
||||
mdf.expr<-melt(df.expr)
|
||||
}
|
||||
|
||||
alldata<-merge(meta, mdf.expr, by.x="barcode", by.y = "variable")
|
||||
|
||||
}
|
||||
|
||||
# order <- clustsort(alldata %>% spread(Gene, value) %>% select(predicted.id, all_of(genes)) %>%
|
||||
# group_by(predicted.id) %>% summarise(across(all_of(genes), mean)) %>% as.data.frame)
|
||||
#
|
||||
# g1<-ggplot(alldata, aes(predicted.id, value, fill=predicted.id))+
|
||||
# geom_violin(scale = "width")+
|
||||
# geom_jitter(width=0.2, size=0.1, alpha=0.3)+
|
||||
# scale_x_discrete(limits=order$x)+
|
||||
# guides(fill=F)+
|
||||
# facet_wrap(.~Gene)+
|
||||
# theme_bw()+
|
||||
# theme(axis.text.x = element_text(angle=90, hjust=1, vjust = 0.5))
|
||||
g2<-ggheatmap(alldata, x="predicted.id",y="Gene",value="value", color="grey")+coord_equal()
|
||||
# ggpubr::ggarrange(g1,g2, ncol=1)
|
||||
g2
|
||||
})
|
||||
}
|
||||
|
||||
# Run the application
|
||||
|
||||
Reference in New Issue
Block a user