Skip to content

Commit

Permalink
routine sync
Browse files Browse the repository at this point in the history
  • Loading branch information
igordot committed Aug 23, 2017
1 parent 8406dae commit 8b5d1ba
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 28 deletions.
9 changes: 4 additions & 5 deletions routes/rna-star-groups-dge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ sleep 3
#########################


echo -e "\n ========== test R ========== \n"
echo -e "\n ========== test R environment ========== \n"

# load relevant modules
module unload java
Expand All @@ -154,10 +154,9 @@ echo " * Rscript: $(readlink -f $(which Rscript)) "
echo " * Rscript version: $(Rscript --version 2>&1) "
echo

# test R installation and setting
bash_cmd="Rscript --vanilla ${code_dir}/scripts/test-packages.R"
echo "CMD: $bash_cmd"
($bash_cmd)
Rscript --vanilla ${code_dir}/scripts/test-package.R optparse
Rscript --vanilla ${code_dir}/scripts/test-package.R mnormt
Rscript --vanilla ${code_dir}/scripts/test-package.R limma

sleep 3

Expand Down
3 changes: 3 additions & 0 deletions scripts/dge-deseq2.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ genes_gtf = args[1]
counts_table_file = args[2]
groups_table_file = args[3]

# check for arguments
if (length(args) < 3) stop("not enough arguments provided")

# check that input files exist
if (!file.exists(counts_table_file)) stop("file does not exist: ", counts_table_file)
if (!file.exists(groups_table_file)) stop("file does not exist: ", groups_table_file)
Expand Down
19 changes: 3 additions & 16 deletions scripts/load-install-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,17 @@ load_install_packages = function(package_list) {
# create local user library path (not present by default)
dir.create(path = Sys.getenv("R_LIBS_USER"), showWarnings = FALSE, recursive = TRUE)

# try to install from CRAN if package is not already installed
# try to install using biocLite() (installs both Bioconductor and CRAN packages)
# use require() instead of installed.packages() to check that package is both installed and usable

# biocLite can install CRAN as well
# if (!require(p, character.only = TRUE, quietly = TRUE)) {
# message("try installing package from CRAN: ", p)
# # install to local user library path (destination needs to be specified the first time)
# install.packages(p, lib = Sys.getenv("R_LIBS_USER"), repos = "https://cran.rstudio.com/", quiet = TRUE)
# }

# try to install from Bioconductor if package is not already installed
# biocLite() installs Bioconductor and CRAN packages
if (!require(p, character.only = TRUE, quietly = TRUE)) {
# message("package not available on CRAN: ", p)
# message("try installing package from Bioconductor: ", p)
message("try installing package: ", p)
message("installing package: ", p)
source("https://bioconductor.org/biocLite.R")
biocLite(p, suppressUpdates = TRUE, lib = Sys.getenv("R_LIBS_USER"))
}

# package still not available (after CRAN and Bioconductor)
if (!require(p, character.only = TRUE, quietly = TRUE)) {
# message("package not available on Bioconductor: ", p)
message("package not available: ", p)
message("package not available on CRAN or Bioconductor: ", p)
}

# load package
Expand Down
28 changes: 28 additions & 0 deletions scripts/test-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env Rscript


##
## Try loading an R package. Install to local user library if not present.
##
## usage: Rscript --vanilla test-package.R package
##


# get scripts directory (directory of this file) and load relevant functions
args_all = commandArgs(trailingOnly = FALSE)
scripts_dir = normalizePath(dirname(sub("^--file=", "", args_all[grep("^--file=", args_all)])))
source(paste0(scripts_dir, "/load-install-packages.R"))

# relevent arguments
args = commandArgs(trailingOnly = TRUE)
package_name = args[1]

# check for arguments
if (length(args) < 1) stop("not enough arguments provided")

# load relevant packages
load_install_packages(package_name)



# end
4 changes: 2 additions & 2 deletions scripts/test-packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


##
## Try loading (installing if not available) a few R packages.
## Try loading some common R packages. Install to local user library if not present.
##
## usage: Rscript --vanilla test-packages.R
##
Expand All @@ -13,7 +13,7 @@ args_all = commandArgs(trailingOnly = FALSE)
scripts_dir = normalizePath(dirname(sub("^--file=", "", args_all[grep("^--file=", args_all)])))
source(paste0(scripts_dir, "/load-install-packages.R"))

# load some packages (some will probably need to be installed)
# load some packages (some are rare and will probably need to be installed)
# used by GATK: ggplot2, gplots, reshape, gsalib
test_packages = c("optparse", "bitops", "mnormt", "reshape", "gplots", "ggplot2", "gsalib", "dplyr", "limma")
load_install_packages(test_packages)
Expand Down
15 changes: 11 additions & 4 deletions segments/annot-annovar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ echo "total muts: $total_muts"
coding_muts=$(cat "$annovar_combined" | grep -v 'refGene' | grep 'exon' | wc -l)
echo "coding muts: $coding_muts"

nonsyn_muts=$(cat "$annovar_combined" | grep -v 'refGene' | grep -E 'nonsynonymous|stopgain|frameshift' | wc -l)
nonsyn_muts=$(cat "$annovar_combined" | grep -v 'refGene' | grep -E 'nonsynonymous|stopgain|stoploss|frameshift' | wc -l)
echo "nonsynonymous muts: $coding_muts"

# header for summary file
Expand All @@ -329,7 +329,10 @@ cat ${summary_dir}/*.${segment_name}.csv | LC_ALL=C sort -t ',' -k1,1 | uniq > "

# all mutations
combine_all_cmd="
cat ${annovar_dir}/*.combined.txt | LC_ALL=C sort -k1,1 -k2,2 | uniq > ${annovar_dir}.all.txt
cat ${annovar_dir}/*.combined.txt \
| LC_ALL=C sort -k1,1 -k2,2 \
| uniq \
> ${annovar_dir}.all.txt
"
echo -e "\n CMD: $combine_all_cmd \n"
eval "$combine_all_cmd"
Expand All @@ -338,7 +341,9 @@ sleep 1

# coding mutations
combine_coding_cmd="
cat ${annovar_dir}.all.txt | grep -E 'refGene|exon|splicing' > ${annovar_dir}.coding.txt
cat ${annovar_dir}.all.txt \
| grep -E 'refGene|exon|splicing' \
> ${annovar_dir}.coding.txt
"
echo -e "\n CMD: $combine_coding_cmd \n"
eval "$combine_coding_cmd"
Expand All @@ -347,7 +352,9 @@ sleep 1

# consequence mutations
combine_nonsyn_cmd="
cat ${annovar_dir}.all.txt | grep -E 'refGene|nonsynonymous|stopgain|splicing|frameshift' > ${annovar_dir}.nonsyn.txt
cat ${annovar_dir}.all.txt \
| grep -E 'refGene|splicing|nonsynonymous|stopgain|stoploss|frameshift' \
> ${annovar_dir}.nonsyn.txt
"
echo -e "\n CMD: $combine_nonsyn_cmd \n"
eval "$combine_nonsyn_cmd"
Expand Down
2 changes: 1 addition & 1 deletion segments/fastq-clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo -e "\n ========== SEGMENT: $segment_name ========== \n" >&2
# check for correct number of arguments
if [ ! $# == 2 ] ; then
echo -e "\n $script_name ERROR: WRONG NUMBER OF ARGUMENTS SUPPLIED \n" >&2
echo -e "\n USAGE: $script_name [project dir] [sample name] \n" >&2
echo -e "\n USAGE: $script_name project_dir sample_name \n" >&2
exit 1
fi

Expand Down

0 comments on commit 8b5d1ba

Please sign in to comment.