From e6146bd4ce6256bb508dbd9f70549d15b4c3d208 Mon Sep 17 00:00:00 2001 From: Keith M Date: Tue, 2 Nov 2021 15:25:58 -0700 Subject: [PATCH] add docker - file --- Dockerfile | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 8 ++++++++ app.R | 14 ++++++++------ 3 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8135626 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +FROM r-base + +# system libraries of general use +## install debian packages +RUN apt-get update -qq && apt-get -y --no-install-recommends install \ +libxml2-dev \ +libcairo2-dev \ +libsqlite3-dev \ +libmariadbd-dev \ +libpq-dev \ +libssh2-1-dev \ +unixodbc-dev \ +libcurl4-openssl-dev \ +libssl-dev + +## update system libraries +RUN apt-get update && \ +apt-get upgrade -y && \ +apt-get clean + + +## renv.lock file +# COPY /example-app/renv.lock ./renv.lock + +# install renv & restore packages +RUN Rscript -e 'install.packages("renv")' +RUN Rscript -e 'install.packages("shiny")' +RUN Rscript -e 'install.packages("ggplot2")' +RUN Rscript -e 'install.packages("Seurat")' +RUN Rscript -e 'install.packages("ggplot2")' +RUN Rscript -e 'install.packages("dplyr")' +RUN Rscript -e 'install.packages("markdown")' +RUN Rscript -e 'install.packages("tidyr")' +RUN Rscript -e 'renv::consent(provided = TRUE)' +RUN Rscript -e 'renv::restore()' +RUN Rscript -e 'memory.limit(size=20000)' + + +# copy necessary files +## app folder +COPY app.R /app.R +COPY Keller_more_clusterings.rds /Keller_more_clusterings.rds +COPY README.md /README.md + + +# run app on container start +CMD ["Rscript", "-e", "shiny::runApp('/app.R', host = '0.0.0.0', port = 3838)"] + +# expose port +EXPOSE 3838 \ No newline at end of file diff --git a/README.md b/README.md index 9def487..6126d2e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ --- Shiny App Tutorial --- +### Local Install Directions: +1. Install docker on your computer +2. git clone +3. Move in RDS file of interest. +4. Edit the read RDS line in `app.R` file to be `/example_app/{your rds file name}` +4. `docker-compose build` +5. `docker-compose up` + ### TODO list: - fix the violin plot ordering diff --git a/app.R b/app.R index 0eebf05..83a3a38 100644 --- a/app.R +++ b/app.R @@ -8,11 +8,13 @@ library(tidyr) # Some initial setup: # this will not work if underscores are in the orig.ident (only for some views) # take in the file, get list of genes, get metadata numbers and categories, get pcs 1-9, and factors.. -aggregate <- readRDS('/Users/keithmitchell/Desktop/Repositories/haudenschild/keith_analysis_round2/HaudenschildRound2_celltype_LR_DIGEST.rds') +aggregate <- readRDS('Keller_more_clusterings.rds') genes = aggregate@assays$RNA reductions <- attributes(aggregate@reductions) meta_nums <- colnames(dplyr::select_if(aggregate@meta.data, is.numeric)) meta_cats <- c(colnames(dplyr::select_if(aggregate@meta.data, is.character)), colnames(dplyr::select_if(aggregate@meta.data, is.factor)),colnames(dplyr::select_if(aggregate@meta.data, is.logical))) +meta_cats <- meta_cats[meta_cats != "orig.ident"] +mysplitbydefault <- "Health" pcs <- list('PC_1','PC_2','PC_3','PC_4','PC_5','PC_6','PC_7','PC_8','PC_9') use.pcs <- 1:50 #agg_cats <- colnames(dplyr::select_if(aggregate@meta.data, is.factor)) @@ -258,7 +260,7 @@ server = function(input, output, session){ order <- sort(levels(aggregate)) levels(aggregate) <- order DimPlot(aggregate, reduction=input$reduction_seperated_categorical, - split.by = "orig.ident", ncol=4 + split.by = mysplitbydefault, ncol=4 ) }) @@ -268,7 +270,7 @@ server = function(input, output, session){ order <- sort(levels(aggregate)) levels(aggregate) <- order DimPlot(aggregate, reduction=input$reduction_seperated_categorical, - split.by = "orig.ident", ncol=4 + split.by = mysplitbydefault, ncol=4 ) }) @@ -328,10 +330,10 @@ server = function(input, output, session){ else{widedat <- FetchData(aggregate, marker)} widedat$Cluster <- Idents(aggregate) - widedat$orig.ident = eval(call("$", aggregate, input$identity_seperated2)) - widedat$final = paste(widedat$orig.ident, widedat$Cluster, sep="_") + widedat[[mysplitbydefault]] = eval(call("$", aggregate, input$identity_seperated2)) + widedat$final = paste(widedat[[mysplitbydefault]], widedat$Cluster, sep="_") final_object = (aggregate(widedat[, 1:2], list(widedat$final), mean)[1:2]) - lab_list = widedat$orig.ident + lab_list = widedat[[mysplitbydefault]] identities = widedat$Cluster num_list = widedat[[marker]]