From 0ab9d7478ae97a879226d157f85416a4ad74104e Mon Sep 17 00:00:00 2001 From: erzakiev Date: Thu, 2 Nov 2023 11:20:14 +0100 Subject: [PATCH] Adding the cerebro exporting functionality --- src/Shiva/Export_module.R | 48 +++++++++++++++++++++++++++++++++++++-- src/Shiva/global.R | 1 + src/dockerfile | 1 + 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/Shiva/Export_module.R b/src/Shiva/Export_module.R index 9b19fee..07d66b3 100644 --- a/src/Shiva/Export_module.R +++ b/src/Shiva/Export_module.R @@ -12,7 +12,7 @@ ExportUI <- function(id) { width = 6, height = NULL, solidHeader = TRUE, status = "primary", radioButtons(ns("type_export"), label = "Choose the Type of Data to Export", - c("Seurat Object RDS File" = "seurat", "List of Genes" = "genes", "List of Cells" = "cells"), inline = T), + c("Seurat Object RDS File" = "seurat", "Cerebro .crb file" = "Cerebro", "List of Genes" = "genes", "List of Cells" = "cells"), inline = T), uiOutput(ns("select_export")), uiOutput(ns("button_export")) #Asif @@ -64,6 +64,18 @@ Export <- function(input, output, session, rval) { }) + getCerebro <- reactive({ + + if(length(rval$seurat_list) > 0){ + + seu <- rval$seurat_list + + return(seu) + + } + + }) + @@ -131,6 +143,11 @@ Export <- function(input, output, session, rval) { selectInput(ns("select"), "Select", getCellsList(), selected = tail(getCellsList(),1), multiple = F, selectize = T) + }else if(input$type_export == "Cerebro"){ + + selectInput(ns("select"), "Select", getCerebro(), selected = tail(getCerebro(),1), + multiple = F, selectize = T) + } } @@ -164,7 +181,9 @@ Export <- function(input, output, session, rval) { if(input$type_export == "seurat"){ paste(input$select, ".rds", sep = "") - }else{ + } else if (input$type_export == "Cerebro") { + paste(input$select, ".crb", sep = "") + } else{ paste(input$select, ".csv", sep = "") } @@ -239,6 +258,31 @@ Export <- function(input, output, session, rval) { # Close modal progress when csv is saved remove_modal_spinner() + } else if(input$type_export == "Cerebro"){ + + # Create modal progress during csv creation and saving + show_modal_spinner(text = 'Creating a Cerebro file... Please wait...', spin = 'circle') + + if(input$select == rval$seurat_selected){ + + exportFromSeurat(object = rval$seurat, groups = c('orig.ident', 'seurat_clusters'), nUMI = "nCount_RNA", nGene = "nFeature_RNA", experiment_name = "exportFromShIVA", organism = "mouse", file = "CerebroExportFromShiva.crb") + + }else{ + + for(seu in rval$seurat_list){ + + if(seu == input$select){ + + saveRDS(readRDS(paste0(rval$output,"/",seu,".rds")), file) + + } + + } + + } + + # Close modal progress when csv is saved + } } ) diff --git a/src/Shiva/global.R b/src/Shiva/global.R index 854dbf2..d2f6614 100644 --- a/src/Shiva/global.R +++ b/src/Shiva/global.R @@ -26,6 +26,7 @@ library(kableExtra) library(org.Mm.eg.db) library(clusterProfiler) library(org.Hs.eg.db) +library(cerebroApp) options(shiny.maxRequestSize = 1000 * 1024^10) diff --git a/src/dockerfile b/src/dockerfile index 39fe37f..4205201 100644 --- a/src/dockerfile +++ b/src/dockerfile @@ -67,6 +67,7 @@ RUN R -e 'install.packages( "viridis")' RUN R -e 'library(devtools);devtools::install_github("JinmiaoChenLab/Rphenograph")' RUN R -e 'library(devtools);devtools::install_github("JinmiaoChenLab/ClusterX")' +RUN R -e 'library(devtools);devtools::install_github("romanhaa/cerebroApp")' RUN R -e 'BiocManager::install("flowCore")' RUN R -e 'BiocManager::install("openCyto")'