Snippets

Jordi Deu Singularity tutorial commands

Created by Jordi Deu last modified
##################################### LIBRARIES USED ###############################################
library(optparse)
library(cDriver)
library(devtools)
library(R.utils)

################################### PARSING COMMAND-LINE ARGUMENTS ##########################################

option_list <- list(
  make_option(c("-d", "--dire"), 
              action="store_true", 
              dest="input", 
              type="character",
              default=FALSE,
              help="Path to the input directory"),
  make_option(c("-p", "--pat"), 
              action="store_true", 
              dest="patient", 
              type="character",
              default=FALSE,
              help="Patient ID"))

opt <- parse_args(OptionParser(option_list=option_list), args = commandArgs(trailingOnly = TRUE))

###################################### RUNNING CCF FROM cDriver ###############################################

# Arguments
in_dir = opt$input
pat = opt$patient
setwd(paste(in_dir, pat,"CCF_estimation", sep='/'))

# Read and run CCF from cDriver to estimate CCF
sample <- read.csv("ccf_input.txt", header = TRUE, sep = "\t")
sample_ccf <- CCF(sample.mutations = sample, VAF = NULL, ploidy = NULL, CCF_CNV = NULL,
    purity = NULL, correct = TRUE)

# Write results
file.create('snv_ccf_cdriver.txt')
write.table(sample_ccf, file='snv_ccf_cdriver.txt', sep='\t', append=TRUE, row.names=FALSE)

# Read and run CCF from cDriver to estimate CAF
sample <- read.csv("caf_input.txt", header = TRUE, sep = "\t")
sample_ccf <- CCF(sample.mutations = sample, VAF = NULL, ploidy = NULL, CCF_CNV = NULL,
                  purity = NULL, correct = TRUE)

# Write results
file.create('snv_caf_cdriver.txt')
write.table(sample_ccf, file='snv_caf_cdriver.txt', sep='\t', append=TRUE, row.names=FALSE)
# Install
wget https://github.com/singularityware/singularity/releases/download/2.6.0/singularity-2.6.0.tar.gz
tar xvf singularity-2.6.0.tar.gz
cd singularity-2.6.0
./configure --prefix=/usr/local
make
sudo make install

# Create a sandbox image
sudo singularity build --sandbox sandbox/ docker://debian:jessie-slim

# Open a writable shell inside the image
sudo singularity shell --writable sandbox/

# Install anything as root
apt-get update
apt-get install -y r-base locales-all build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev libmpfr-dev

# Install any R package
R
install.packages("optparse")
install.packages("R.utils")
install.packages("devtools")
library(devtools)
install_version("Rmpfr", version="0.6-1")
install_github("hanasusak/cDriver")
library(cDriver)
q()

# Remove unnecessary files
apt-get autoremove
rm -rf /var/lib/apt/lists/*

# Exit the container
exit

# Create a read-only portable compress image
sudo singularity build cdriver.simg sandbox/
sudo chown $USER: cdriver.simg

# Run it from outside using 'exec'

singularity exec cdriver.simg Rscript cdriver.R -h

# Prepare to run using 'run'
sudo scp cdriver.R sandbox/
sudo nano sandbox/singularity
##nano: Rscript /cdriver.R $@
rm cdriver.simg
sudo singularity build cdriver.simg sandbox/
sudo chown $USER: cdriver.simg
singularity run cdriver.simg -h

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.