diff --git a/R-Shiny-App-Practice-master/.gitignore b/R-Shiny-App-Practice-master/.gitignore new file mode 100644 index 0000000..fae8299 --- /dev/null +++ b/R-Shiny-App-Practice-master/.gitignore @@ -0,0 +1,39 @@ +# History files +.Rhistory +.Rapp.history + +# Session Data files +.RData + +# User-specific files +.Ruserdata + +# Example code in package build process +*-Ex.R + +# Output files from R CMD build +/*.tar.gz + +# Output files from R CMD check +/*.Rcheck/ + +# RStudio files +.Rproj.user/ + +# produced vignettes +vignettes/*.html +vignettes/*.pdf + +# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 +.httr-oauth + +# knitr and R markdown default cache directories +*_cache/ +/cache/ + +# Temporary files created by R markdown +*.utf8.md +*.knit.md + +# R Environment Variables +.Renviron diff --git a/README.md b/README.md index 2bb854e..9b09b2c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# clustifyr-web-app -An R Shiny App to help with scRNA-seq benchmarking and analysis with Clustifyr +# R-Shiny-App-Practice +A repository to prepare myself for writing an R shiny app for the scRNA-seq atlas web tool diff --git a/data/cbmc_m.rda b/data/cbmc_m.rda new file mode 100644 index 0000000..fc512d1 Binary files /dev/null and b/data/cbmc_m.rda differ diff --git a/data/cbmc_ref.rda b/data/cbmc_ref.rda new file mode 100644 index 0000000..a1e05c6 Binary files /dev/null and b/data/cbmc_ref.rda differ diff --git a/data/pbmc_markers.rda b/data/pbmc_markers.rda new file mode 100644 index 0000000..389989e Binary files /dev/null and b/data/pbmc_markers.rda differ diff --git a/data/pbmc_markers_M3Drop.rda b/data/pbmc_markers_M3Drop.rda new file mode 100644 index 0000000..2c80be6 Binary files /dev/null and b/data/pbmc_markers_M3Drop.rda differ diff --git a/data/pbmc_matrix_small.rda b/data/pbmc_matrix_small.rda new file mode 100644 index 0000000..59d03d4 Binary files /dev/null and b/data/pbmc_matrix_small.rda differ diff --git a/data/pbmc_meta.rda b/data/pbmc_meta.rda new file mode 100644 index 0000000..b01da84 Binary files /dev/null and b/data/pbmc_meta.rda differ diff --git a/data/pbmc_vargenes.rda b/data/pbmc_vargenes.rda new file mode 100644 index 0000000..fdff024 Binary files /dev/null and b/data/pbmc_vargenes.rda differ diff --git a/rsconnect/shinyapps.io/sidhantpuntambekar/scRNA-seq-atlas.dcf b/rsconnect/shinyapps.io/sidhantpuntambekar/scRNA-seq-atlas.dcf new file mode 100644 index 0000000..ae565e0 --- /dev/null +++ b/rsconnect/shinyapps.io/sidhantpuntambekar/scRNA-seq-atlas.dcf @@ -0,0 +1,12 @@ +name: scRNA-seq-atlas +title: scRNA-seq-atlas +username: +account: sidhantpuntambekar +server: shinyapps.io +hostUrl: https://api.shinyapps.io/v1 +appId: 2890325 +bundleId: 3671701 +url: https://sidhantpuntambekar.shinyapps.io/scRNA-seq-atlas/ +when: 1601067752.08105 +asMultiple: FALSE +asStatic: FALSE diff --git a/scRNA-seq-atlas/app.R b/scRNA-seq-atlas/app.R new file mode 100644 index 0000000..6358b5a --- /dev/null +++ b/scRNA-seq-atlas/app.R @@ -0,0 +1,171 @@ +library(shiny) +library(dplyr) +library(readr) +library(tools) +library(clustifyr) +library(rsconnect) +options(shiny.maxRequestSize = 1500*1024^2) +options(repos = BiocManager::repositories()) +options(shiny.reactlog = TRUE) + +# Define UI for data upload app ---- +ui <- fluidPage( + + # App title ---- + titlePanel("Clustifyr Reference Matrix Generation"), + + # Sidebar layout with input and output definitions ---- + sidebarLayout( + + # Sidebar panel for inputs ---- + sidebarPanel( + + # Input: Select a file ---- + fileInput("file1", "Choose Matrix File", + multiple = TRUE, + accept = c("text/csv", + "text/comma-separated-values,text/plain", + ".csv", + '.xlsx', + ".tsv", + ".rds", + ".rda"), + ), + fileInput("file2", "Choose Metadata File", + multiple = FALSE, + accept = c("text/csv", + "text/comma-separated-values,text/plain", + ".csv", + '.xlsx', + ".tsv", + ".rds", + ".rda"), + ), + + tags$hr(), + + # Input: Checkbox if file has header ---- + checkboxInput("header", "Header", TRUE), + + + # Horizontal line ---- + tags$hr(), + + # Input: Select separator ---- + radioButtons("sep", "Separator", + choices = c(Tab = "\t"), + selected = ","), + + # Input: Select number of rows to display ---- + radioButtons("disp", "Display", + choices = c(Head = "head", + All = "all"), + selected = "head") + + ), + + # Main panel for displaying outputs ---- + mainPanel( + + # Output: Data file ---- + tableOutput("contents") + + ) + + ) +) + +# Define server logic to read selected file ---- +server <- function(input, output) { + + output$contents <- renderTable({ + + # input$file1 will be NULL initially. After the user selects + # and uploads a file, head of that data file by default, + # or all rows if selected, will be shown. + file <- input$file1 + fileTypeFile1 <- tools::file_ext(file$datapath) + req(file) + # when reading semicolon separated files, + # having a comma separator causes `read.csv` to error + if (fileTypeFile1 == "csv") + { + df1 <- read.csv(file$datapath, + header = input$header, + sep = input$sep, + quote = input$quote) + } + else if (fileTypeFile1 == "tsv") + { + df1 <- read_tsv(file$datapath, + header = input$header, + quote = input$quote) + } + else + { + df1 <- load(file$datapath) + } + + #file 1 + if(input$disp == "head") { + return(head(df1)) + } + else { + return(df1) + } + } + ) + + output$file2Contents <- renderTable({ + file <- input$file2 + fileTypeFile2 <- tools::file_ext(file$datapath) + req(file) + if (fileTypeFile2 == "csv") + { + df2 <- read.csv(file$datapath, + header = input$header, + sep = input$sep, + quote = input$quote) + } + else if (fileTypeFile2 == "tsv") + { + df2 <- read_tsv(file$datapath, + header = input$header, + quote = input$quote) + } + else + { + df2 <- load(file$datapath) + } + + #file 2 + if(input$disp == "head") { + return(head(df2)) + } + else { + return(df2) + } + } +) + + output$reference <- renderTable({ + req(input$file1) + req(input$file2) + fileTypeFile1 <- file_ext(input$file1) + fileTypeFile2 <- file_ext(input$file2) + df1 <- read.csv(input$file1$datapath, + header = input$header, + sep = input$sep, + quote = input$quote) + df2 <- read.csv(input$file2$datapath, + header = input$header, + sep = input$sep, + quote = input$quote) + reference_matrix <- average_clusters(mat = df1, metadata = df2$cellCol, if_log = TRUE) + head(reference_matrix) + }) + +} + +# Create Shiny app ---- +shinyApp(ui, server) \ No newline at end of file