Skip to content

Commit

Permalink
Update to docker-based system.
Browse files Browse the repository at this point in the history
  • Loading branch information
aprice committed Oct 3, 2024
1 parent 535458a commit 6016f0a
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 25,045 deletions.
74 changes: 74 additions & 0 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
FROM rocker/tidyverse:3.6.3-ubuntu18.04

LABEL maintainer="Adam Price ([email protected])" \
contributor="Anne Marie Noronha ([email protected])" \
contributor="Yixiao Gong ([email protected])" \
contributor="Nikhil Kumar ([email protected])" \
contributor="Philip Jonsson ([email protected])" \
version.image="0.0.1-rebuild" \
version.facets_suite="2.0.8" \
version.facets="0.5.14" \
version.alpine="3.8" \
version.pctGCdata="0.2.0" \
source.facets="https://github.com/mskcc/facets/archive/v0.5.14.tar.gz"

ENV FACETS_SUITE_VERSION 2.0.8
ENV FACETS_VERSION 0.5.14
ENV FACETS_PREVIEW_VERSION 2.1.4
ENV PCTGCDATA 0.2.0

RUN sed -i '/jessie-updates/d' /etc/apt/sources.list

# Requirements
RUN apt-get -y update && apt-get upgrade -y && apt-get install -y --fix-missing apt-utils nano wget\
g++ \
tar \
bzip2 \
libbz2-dev \
libc6-dev \
libxt-dev \
liblzma-dev \
libgtk2.0-dev \
libcairo2-dev \
xvfb \
xauth \
xfonts-base
RUN apt-get install -y xdg-utils --fix-missing
RUN apt-get install -y inotify-tools

RUN R -e "install.packages(c('Cairo','argparse','gridExtra', 'binom', 'BiocManager', 'diptest', 'egg','shinyWidgets', 'shinyjs', 'rhandsontable', 'doParallel', 'configr', 'R.utils'), repos='http://cran.us.r-project.org')" \
&& R -e "BiocManager::install('rtracklayer')"

# Install FACETS, pctGCdata and facets-suite
RUN cd /tmp \
&& wget https://github.com/mskcc/facets-suite/archive/${FACETS_SUITE_VERSION}.tar.gz -O facets-suite-${FACETS_SUITE_VERSION}.tar.gz \
&& wget https://github.com/mskcc/facets/archive/v${FACETS_VERSION}.tar.gz -O facets-v${FACETS_VERSION}.tar.gz \
&& wget https://github.com/mskcc/pctGCdata/archive/v${PCTGCDATA}.tar.gz \
&& git clone --single-branch --branch main https://github.com/mskcc/fp-docker.git facets-preview-master \
&& tar xvzf facets-v${FACETS_VERSION}.tar.gz \
&& tar xvzf v${PCTGCDATA}.tar.gz \
&& tar xvzf facets-suite-${FACETS_SUITE_VERSION}.tar.gz \
&& cd /tmp/pctGCdata-${PCTGCDATA} \
&& R CMD INSTALL . \
&& cd /tmp/facets-${FACETS_VERSION} \
&& R CMD INSTALL . \
&& cd /tmp/facets-suite-${FACETS_SUITE_VERSION} \
&& R CMD INSTALL . \
# correct shebang line
&& sed -i "s/opt\/common\/CentOS_6-dev\/R\/R-3.2.2\//usr\//g" *.R \
# copy execs to /usr/bin/facets-suite
&& mkdir -p /usr/bin/facets-suite/ \
&& cp -r /tmp/facets-suite-${FACETS_SUITE_VERSION}/* /usr/bin/facets-suite/ \
&& cd /tmp/facets-preview-master \
&& R CMD INSTALL . \
&& mkdir -p /usr/bin/facets-preview/ \
&& cp -r /tmp/facets-preview-master/* /usr/bin/facets-preview/ \
# clean up
&& rm -rf /var/cache/apk/* /tmp/* # update to using release version when 2.1.5+ is released.

ENV PYTHONNOUSERSITE set
ENV FACETS_OVERRIDE_EXITCODE set

COPY fp_config.json /usr/bin/facets-preview/
RUN chmod 744 /usr/bin/facets-preview/fp_config.json
EXPOSE 3838
22 changes: 22 additions & 0 deletions Docker/fp_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"repo": [
{
"name": "Tempo",
"manifest_file": "/Users/noronhaa/Documents/facets_img_test/manifest.txt.gz",
"tumor_id_format": "",
"counts_file_format": "{sample_id}.snp_pileup.gz"
}
],
"watcher_dir": "/Users/aprice/mskcc/pipelines/fp-docker/Docker/watcher_dir",
"facets_lib": [
{
"version": "0.5.14",
"lib_path": "/usr/local/lib/R/site-library/"
}
],
"verify_sshfs_mount" : "",
"r_script_path" : "/usr/local/bin/Rscript",
"facets_suite_lib": "/usr/local/lib/R/site-library/",
"facets_suite_run_wrapper": "/usr/bin/facets-suite/run-facets-wrapper.R",
"facets_qc_script": "/usr/bin/facets-preview/facets_qc/v1.0/facets_fit_qc.R"
}
22 changes: 22 additions & 0 deletions Docker/impact_juno_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"repo": [
{
"name": "Clinical series IMPACT",
"manifest_file": "/juno/work/ccs/shared/resources/impact/facets/manifests/impact_facets_manifest_latest.txt.gz",
"tumor_id_format": "^P-\\d{7}-T\\d+-IM\\d(,P-\\d{7}-T\\d+-IM\\d)*$",
"counts_file_format": "countsMerged____{sample_id}.dat.gz"
}
],
"watcher_dir": "/juno/work/ccs/shared/software/refit_watcher/",
"facets_lib": [
{
"version": "0.5.14",
"lib_path": "/usr/local/lib/R/site-library/facets/"
}
],
"verify_sshfs_mount" : "",
"r_script_path" : "/usr/local/bin/Rscript",
"facets_suite_lib": "/usr/local/lib/R/site-library/",
"facets_suite_run_wrapper": "/usr/bin/facets-suite/run-facets-wrapper.R",
"facets_qc_script": "/usr/bin/facets-preview/facets_qc/v1.0/facets_fit_qc.R"
}
10 changes: 4 additions & 6 deletions R/compile_cohort_annotations.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@ compile_cohort_annotations <- function(samples_to_annotate, output_prefix, ncore
return(fit_to_use)
}

print(sample_path)

## read from facets_qc.txt
qc_file = paste0(sample_path, '/facets_qc.txt')
review_file = paste0(sample_path, '/facets_review.manifest')

review_file = paste0(sample_path, '/facets_review.manifest')
if (!file.exists(qc_file)| !file.exists(review_file)) { return() }

qc_runs = fread(qc_file) %>% filter(fit_name != 'Not selected')
Expand Down Expand Up @@ -102,7 +100,7 @@ compile_cohort_annotations <- function(samples_to_annotate, output_prefix, ncore
cncf_file = ifelse(!is.na(use_only_purity_run) & use_only_purity_run,
paste0(pfx, '_purity.cncf.txt'), paste0(pfx, '_hisens.cncf.txt')),
seg_file = ifelse(!is.na(use_only_purity_run) & use_only_purity_run,
paste0(pfx, '_purity_diplogR.adjusted.seg'), paste0(pfx, '_hisens_diplogR.adjusted.seg'))) %>%
paste0(pfx, '_purity.seg'), paste0(pfx, '_hisens.seg'))) %>%
mutate(arm_level_file_exists = file.exists(arm_level_file),
gene_level_file_exists = file.exists(gene_level_file),
ccf_file_exists = file.exists(ccf_file),
Expand Down Expand Up @@ -151,7 +149,7 @@ compile_cohort_annotations <- function(samples_to_annotate, output_prefix, ncore
simplify = F,
USE.NAMES=F),
fill = T)
write.table(seg_calls, file=paste0(output_prefix, '_diplogR.adjusted.seg'), quote=F, row.names=F, sep='\t')
write.table(seg_calls, file=paste0(output_prefix, '.seg'), quote=F, row.names=F, sep='\t')

cncf_calls = rbindlist(parSapply(cl,
(samples_annotated %>% filter(cncf_file_exists))$cncf_file,
Expand Down
13 changes: 0 additions & 13 deletions R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ load_repo_samples <- function(tumor_ids, manifest_file, progress) {
metadata <- rbind(metadata, as.data.frame.list(sample_meta, stringsAsFactors = F))
progress$inc(1/length(repo), detail = paste(" ", i, "/", length(repo)))
}
print("METADATA PRINT--")
print(metadata)
print("REPO PRINT--")
print(repo)
metadata
}

Expand Down Expand Up @@ -575,15 +571,6 @@ launch_application <- function() {
#' @return launches app
#' @export launch_application_browser
launch_application_browser <- function() {
require(bit64)
require(Cairo)
require(ggplot2)
require(grid)
require(gridExtra)
require(plyr)
require(data.table)
require(dplyr)

shiny::runApp(appDir = system.file("application", package = "facetsPreview"), launch.browser = TRUE)
}

Expand Down
35 changes: 31 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
## NOTE: This is a fork from the main facets-preview repo at taylor-lab/facets-preview/.
## This was created to handle modifications for the OnDemand facets preview service by Adam Price.

# facets-preview
`facets-preview` is an R shiny based desktop app that enables loading, reviewing and annotating fits as well as function to generate downstream genomic calls. For documentation, go to: https://bandla-chai.gitbook.io/facets-preview/
# Facets Preview
`facets-preview` is an R shiny based desktop app that enables loading, reviewing and annotating fits as well as function to generate downstream genomic calls. This repository represents the build used for the docker container at price0416/fp_docker.

# FAQs
* Please check our [FAQ section](faq.md) for information on commonly asked FACETS-related issues.

# Setup Instructions

## Setup Docker on your local computer.
* [Mac Install](https://docs.docker.com/desktop/install/mac-install/)

## Pull the Docker Image to your local computer.
* Open a terminal and pull the docker image with `docker pull price0416/fp_docker`

## Prepare access to your FACETS data from remote sources.
* If you want to access FACETS data on a remote machine (i.e. pyr/juno), setup [macFUSE](https://osxfuse.github.io/).
* Make a local drive to host your mount, i.e. `mkdir ~/mskcc/juno/impact/facets`
* Add a mount command to your ~/.bash_profile on your local computer. For example, to mount pyr, `alias mountfacetspyr='sudo umount -f ~/mskcc/juno/impact/facets || sshfs [email protected]:/rtsess01/compute/juno/cmo/juno/work/ccs/shared/resources/impact/facets ~/mskcc/juno/impact/facets -o auto_cache -o defer_permissions -o local -o IdentityFile=/Users/yourUser/.ssh/id_rsa -o reconnect -o transform_symlinks -o follow_symlinks'`
* Run your bash_profile. `source ~/.bash_profile`
* Mount the remote location. `mountfacetspyr`. This will create a remote mount of the drive to your local drive, in this example at `~/mskcc/juno/impact/facets`. Note that you may need to execute this command twice, as the first execution attempt will sometimes ask for your local adminstrator password, and the second attempt will ask for your remote login credentials.
* Navigate to the mounted directory. `cd ~/mskcc/juno/impact/facets`

## Run the Docker Image
* Run the docker image. `docker run -v $PWD:$PWD --workdir $PWD -p 3838:3838 --name test --rm -i -t price0416/fp_docker /bin/bash`. You will notice the prompt on your terminal now shows `root@randomNumberString`. At this point you are inside the running container. If you ever need to exit the container, use CTRL+D.
* Start FACETS Preview with the following command from inside the running container. `Rscript -e "facets_preview_config_file = '/usr/bin/facets-preview/fp_config.json' ; options(shiny.port = 3838, shiny.host = '0.0.0.0', shiny.launch.browser = FALSE) ; library(facetsPreview); facetsPreview::launch_application()"`
* Open a browser and navigate to [http://0.0.0.0:3838/](http://0.0.0.0:3838/)
* FACETS Preview should load.

## Loading a Sample
* Note that in this version of FACETS Preview that samples can only be loaded using the "Paste facets run directories" box at the bottom of the load screen.
* Provide full paths to the samples you want to load in this box. If they are not found or do not load properly, be sure to confirm that you started your docker image after navigating to the target facets data location before starting the container. i.e. `cd ~/mskcc/juno/impact/facets`
2 changes: 1 addition & 1 deletion arranging_facets.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ facets_cm_files=list.files(facets_dir,pattern="*.dat.gz$",full.names=TRUE)
facets_txt_files=list.files(facets_dir,pattern="*.txt",full.names=TRUE)
facets_png_files=list.files(facets_dir,pattern="*.png",full.names=TRUE)
facets_out_files=list.files(facets_dir,pattern="*.out",full.names=TRUE)
facets_seg_files=list.files(facets_dir,pattern="*.adjusted.seg",full.names=TRUE)
facets_seg_files=list.files(facets_dir,pattern="*.seg",full.names=TRUE)
facets_Rdata_files=list.files(facets_dir,pattern="*.Rdata",full.names=TRUE)

output_dir = '/ifs/res/taylorlab/chavans/roslin_2.4_deliveries/all_facets/'
Expand Down
5 changes: 5 additions & 0 deletions facetsPreview.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ SaveWorkspace: No
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

Expand Down
Loading

0 comments on commit 6016f0a

Please sign in to comment.