Thursday, June 22, 2017

R package openxlsx for reading xlsx file

read.xlsx(xlsxFile, sheet = 1, startRow = 1, colNames = TRUE,
rowNames = FALSE, detectDates = FALSE, skipEmptyRows = TRUE,
skipEmptyCols = TRUE, rows = NULL, cols = NULL, check.names = FALSE,
namedRegion = NULL, na.strings = "NA", fillMergedCells = FALSE)

Sunday, June 11, 2017

Ubuntu locale

apt-get install locales
locale-gen --purge en_US.UTF-8

Friday, June 9, 2017

Singularity Ubuntu Image Creation and Use

#Step 1, install singularity (See http://singularity.lbl.gov/)

#Step 2, create a spec file named "Singularity" with content:
Bootstrap:docker
From:ubuntu:latest
%post
    apt-get update

    apt-get -y install openssh-server
    apt-get -y install openssh-client
    apt-get -y install build-essential
    apt-get -y install less
    apt-get -y install nano
    apt-get -y install locales
    locale-gen --purge en_US.UTF-8

    mkdir /cluster001
%environment 

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8


#The commands below %post are used to install or set up system after bootstrap.

#Step3, create an ubuntu image in folder ~/Container
singularity create ~/Container/ubuntu.img

#Step 4, run bootstrap command with sudo to ensure proper file ownership/permission
sudo singularity bootstrap ~/Container/ubuntu.img Singularity

#Content creation
#Method 1: copy a file to container
singularity copy ubuntu.img -p script1.sh /bin
#to copy with sudo and maintain proper root ownership
chmod 775 script2.sh
sudo chown root script2.sh
sudo singularity copy ubuntu.img -p script2.sh /bin

#check ownership
singularity exec ~/Container/ubuntu.img ls -l /bin/script*.sh

#Method 2, shell into image with --writable and then issue any kind of content creation, or download using wget or curl or git clone, etc.
#For example, run interactive with sudo to install R (note 1):
sudo singularity shell --writable ~/Container/ubuntu.img
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
apt-get install software-properties-common
add-apt-repository 'deb [arch=amd64] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
apt-get update
apt-get install r-base

#Run interactive shell as an user
singularity shell --writable ~/Container/ubuntu.img

#Increase container size in unit of MB if the default size is not big enough
singularity expand --size 2048 ~/Container/ubuntu.img


#Execute command through singularity image, eg run "ls -l /bin/":
singularity exec ~/ubuntu.img ls -l /bin/

Note 1: https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-16-04-2