Skip to content
Snippets Groups Projects
Commit 8b703904 authored by Brandon Chen's avatar Brandon Chen
Browse files

added download data for per cell expressions

parent 739729c8
Branches
Tags
No related merge requests found
...@@ -9,7 +9,7 @@ library(data.table) ...@@ -9,7 +9,7 @@ library(data.table)
source("./functions/SeuratObjectFunctions.R") source("./functions/SeuratObjectFunctions.R")
source("./functions/my_ui.R") source("./functions/my_ui.R")
astrocyte_flag<-T #Set to true if running on Astrocyte, else, set to false astrocyte_flag<-F #Set to true if running on Astrocyte, else, set to false
# Determines the location where data gets read from # Determines the location where data gets read from
# If it is set to FALSE, then data is read from the ./data/ folder # If it is set to FALSE, then data is read from the ./data/ folder
# If it is set to TRUE, then data is read from the rootdir provided by Astrocyte # If it is set to TRUE, then data is read from the rootdir provided by Astrocyte
...@@ -1001,6 +1001,63 @@ server <- function(input, output, session) { ...@@ -1001,6 +1001,63 @@ server <- function(input, output, session) {
list(out, all_out) list(out, all_out)
}) })
single_cell_data <- reactive({
if (length(input$clusters)==0){my_clust="none"}
else {my_clust=input$clusters}
if(length(input$samples)==0){my_samp="none"}
else{my_samp=input$samples}
if (input$subset==c("csv")){
seuratObject=subsetSeuratObject(seuratObject=samples.integrated,
cellFile=input$subset_csv$datapath)
}
if (input$subset==c("manual")){
seuratObject=subsetSeuratObject(seuratObject=samples.integrated,
selectedClusters=my_clust,
selectedSamples=my_samp)
}
if (input$subset==c("none"))
{seuratObject = subsetSeuratObject(seuratObject=samples.integrated,
selectedClusters = 'none',
selectedSamples = 'none')}
if (input$score_genes == T) {
seuratObject=seuratObject$seuratObject
if (input$log==F) {
seuratObject=NormalizeData(seuratObject,verbose=F,normalization.method='RC')
}
infoList=getInfo(seuratObject,T)
signatures<-read.csv(input$g_score$datapath,sep=',',header=T)
temp=AddModuleScore(seuratObject,signatures,search=F)
g=dim(signatures)[2]
n=dim(temp@meta.data)[2]
colnames(temp@meta.data)[(n-g+1):n]=colnames(signatures)
gene_list=input$signature
if (input$phasing == T){
temp@meta.data[,c('orig.ident','idents','Phase',gene_list)]
}
else {
temp@meta.data[,c('orig.ident','idents',gene_list)]
}
}
else {
seuratObject=seuratObject$seuratObject
if (input$log==F) {
seuratObject=NormalizeData(seuratObject,verbose=F,normalization.method='RC')
}
gene_list=input$features
temp<-seuratObject@assays$RNA$data[gene_list,] %>% as.matrix() %>% t()
if (input$phasing == T){
data.frame(seuratObject@meta.data[,c('orig.ident','idents','Phase')],temp,check.rows=F)
}
else {
data.frame(seuratObject@meta.data[,c('orig.ident','idents')],temp,check.rows=F)
}
}
})
percent_expression_table <- reactive({ percent_expression_table <- reactive({
phasing=input$phasing phasing=input$phasing
group.by=input$group group.by=input$group
...@@ -1669,6 +1726,13 @@ server <- function(input, output, session) { ...@@ -1669,6 +1726,13 @@ server <- function(input, output, session) {
} }
) )
output$download_single_cell_data <- downloadHandler(
filename = function() { paste('Single_Cell_Data', '.csv', sep='') },
content = function(file) {
write.csv(single_cell_data(),file=file)
}
)
output$download_DE <- downloadHandler( output$download_DE <- downloadHandler(
filename = function() { paste0(runDE()[[4]],"_vs_",runDE()[[5]],'_DE_Genes.zip', sep='') }, filename = function() { paste0(runDE()[[4]],"_vs_",runDE()[[5]],'_DE_Genes.zip', sep='') },
content = function(file) { content = function(file) {
......
...@@ -149,7 +149,10 @@ ui <- fluidPage( ...@@ -149,7 +149,10 @@ ui <- fluidPage(
column(12, column(12,
downloadButton("download_data_table", downloadButton("download_data_table",
"Download Expression Data") "Download Expression Data")
) ),
column(12,
downloadButton("download_single_cell_data",
"Download Single Cell Data"))
# column(12, # column(12,
# downloadButton("download_percent_expression", # downloadButton("download_percent_expression",
# "Download Percent Expression Data")) # "Download Percent Expression Data"))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment