Skip to content

Commit

Permalink
hotfix 2 - yaml support for integration into PANOPLY
Browse files Browse the repository at this point in the history
  • Loading branch information
Karsten Krug committed Aug 7, 2020
1 parent 6f0b5ee commit fdcb519
Show file tree
Hide file tree
Showing 7 changed files with 1,084 additions and 1,065 deletions.
1,106 changes: 553 additions & 553 deletions Readme.html

Large diffs are not rendered by default.

250 changes: 125 additions & 125 deletions Readme.md

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions d2utmpT1ueMX
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
License

ssGSEA2.0 is distributed under the following BSD-style license:

Copyright © 2018 – 2020 The Broad Institute, Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the names of the copyright holders nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED “AS IS.” THE COPYRIGHT HOLDERS MAKE NO EXPRESS OR IMPLIED REPRESENTATIONS OR WARRANTIES OF ANY KIND REGARDING THE SOFTWARE AND COPYRIGHT, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, CONFORMITY WITH ANY DOCUMENTATION, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF, HAVE REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF SUCH DAMAGE.

If, by operation of law or otherwise, any of the aforementioned warranty disclaimers are determined inapplicable, your sole remedy, regardless of the form of action, including, but not limited to, negligence and strict liability, shall be replacement of the software with an updated version if one exists.

Development of ssGSEA2.0 was supported by grant U24CA210979 from the National Cancer Institute Clinical Proteomic Tumor Analysis Consortium (CPTAC). In addition, ssGSEA2.0 is distributed, in part, under and subject to the provisions of license(s) for: cmap / cmapR, © 2017 Connectivity Map (CMap) at the Broad Institute, Inc. (https://github.com/cmap/cmapR/blob/master/LICENSE, BSD 3-Clause License). All rights reserved.
26 changes: 13 additions & 13 deletions ssGSEA2.0.Rproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

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

RnwWeave: Sweave
LaTeX: pdfLaTeX
144 changes: 72 additions & 72 deletions ssgsea-cli.R
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
#!/usr/bin/env Rscript
options( warn = -1 )

suppressPackageStartupMessages( if(!require("pacman")) install.packages ("pacman") )
suppressPackageStartupMessages(p_load("optparse"))

# parse the directory this file is located
script.dir <- commandArgs()[4]
script.dir <- sub('^(.*(/|\\\\)).*', '\\1', sub('.*?\\=','', script.dir))
# this doesn't seem to be reliably working on Windows OS
# if called from the directory is 'ssgsea-cli.R' resides in
# the line belwo should fix this
script.dir <- ifelse(dir.exists(script.dir), script.dir, '.')

# specify command line arguments
option_list <- list(
make_option( c("-i", "--input"), action='store', type='character', dest='input_ds', help='Path to input GCT file.'),
make_option( c("-o", "--ouptut"), action='store', type='character', dest='output_prefix', help='File prefix for output files.', default='out'),
make_option( c("-d", "--db"), action='store', type='character', dest='gene_set_databases', help='Path to gene set database (GMT format).'),
make_option( c("-n", "--norm"), action='store', type='character', dest='sample_norm_type', help='Sample normalization: "rank", "log", "log.rank" or "none".', default = 'rank'),
make_option( c("-w", "--weight"), action='store', type='character', dest='weight', help='When weight==0, all genes have the same weight; if weight>0 actual values matter and can change the resulting score.', default = 0.75),
make_option( c("-c", "--correl"), action='store', type='character', dest='correl_type', help='Correlation type: "rank", "z.score", "symm.rank".', default = 'z.score'),
make_option( c("-t", "--test"), action='store', type='character', dest='statistic', help='Test statistic: "area.under.RES", "Kolmogorov-Smirnov"', default = 'area.under.RES'),
make_option( c("-s", "--score"), action='store', type='character', dest='output_score_type', help='Score type: "ES" - enrichment score, "NES" - normalized ES', default = 'NES'),
make_option( c("-p", "--perm"), action='store', type='character', dest='nperm', help='Number of permutations', default = 1000),
make_option( c("-m", "--minoverlap"), action='store', type='character', dest='min_overlap', help='Minimal overlap between signature and data set.', default = 10),
make_option( c("-x", "--extendedoutput"), action='store', type='character', dest='extended_output', help='If TRUE additional stats on signature coverage etc. will be included as row annotations in the GCT results files.', default = TRUE),
make_option( c("-e", "--export"), action='store', type='character', dest='export_signat_gct', help='For each signature export expression GCT files.', default = TRUE),
make_option( c("-g", "--globalfdr"), action='store', type='character', dest='global_fdr', help='If TRUE global FDR across all data columns is calculated.', default = FALSE),
make_option( c("-l", "--lightspeed"), action='store', type='character', dest='multi_core', help='If TRUE processing will be parallized across gene sets. (I ran out of single letters to define parameters...)', default = TRUE),
make_option( c("-y", "--yaml"), action='store', type='character', dest='yaml_file', help='Paramater file (.yaml)', default = NA)
)

## #####################################
## source the actual script
source(file.path(script.dir, 'src', 'ssGSEA2.0.R'))
source(file.path(script.dir, 'src','parse_yaml_ssgsea.R'))

# parse command line parameters
opt <- parse_param_ssgsea(option_list)

# hard-coded parameters
spare.cores <- 0 # use all available cpus
log.file <- paste(opt$output.prefix, '_ssgsea.log.txt', sep='')


## ######################################################################################################
##
## run ssGSEA
##
## ######################################################################################################
res <- ssGSEA2(
input.ds=opt$input_ds,
output.prefix=opt$output_prefix,
gene.set.databases=opt$gene_set_databases,
sample.norm.type=opt$sample_norm_type,
weight=opt$weight,
statistic=opt$statistic,
output.score.type=opt$output_score_type,
nperm=opt$nperm,
min.overlap=opt$min_overlap,
correl.type=opt$correl_type,
export.signat.gct=opt$export_signat_gct,
extended.output=opt$extended_output,
global.fdr=opt$global_fdr,
par=opt$multi_core,
spare.cores=spare.cores,
log.file=log.file
)



#!/usr/bin/env Rscript
options( warn = -1 )

suppressPackageStartupMessages( if(!require("pacman")) install.packages ("pacman") )
suppressPackageStartupMessages(p_load("optparse"))

# parse the directory this file is located
script.dir <- commandArgs()[4]
script.dir <- sub('^(.*(/|\\\\)).*', '\\1', sub('.*?\\=','', script.dir))
# this doesn't seem to be reliably working on Windows OS
# if called from the directory is 'ssgsea-cli.R' resides in
# the line below attempts to fix this
script.dir <- ifelse(dir.exists(script.dir), script.dir, '.')

# specify command line arguments
option_list <- list(
make_option( c("-i", "--input"), action='store', type='character', dest='input_ds', help='Path to input GCT file.'),
make_option( c("-o", "--ouptut"), action='store', type='character', dest='output_prefix', help='File prefix for output files.', default='out'),
make_option( c("-d", "--db"), action='store', type='character', dest='gene_set_databases', help='Path to gene set database (GMT format).'),
make_option( c("-n", "--norm"), action='store', type='character', dest='sample_norm_type', help='Sample normalization: "rank", "log", "log.rank" or "none".', default = 'rank'),
make_option( c("-w", "--weight"), action='store', type='character', dest='weight', help='When weight==0, all genes have the same weight; if weight>0 actual values matter and can change the resulting score.', default = 0.75),
make_option( c("-c", "--correl"), action='store', type='character', dest='correl_type', help='Correlation type: "rank", "z.score", "symm.rank".', default = 'z.score'),
make_option( c("-t", "--test"), action='store', type='character', dest='statistic', help='Test statistic: "area.under.RES", "Kolmogorov-Smirnov"', default = 'area.under.RES'),
make_option( c("-s", "--score"), action='store', type='character', dest='output_score_type', help='Score type: "ES" - enrichment score, "NES" - normalized ES', default = 'NES'),
make_option( c("-p", "--perm"), action='store', type='character', dest='nperm', help='Number of permutations', default = 1000),
make_option( c("-m", "--minoverlap"), action='store', type='character', dest='min_overlap', help='Minimal overlap between signature and data set.', default = 10),
make_option( c("-x", "--extendedoutput"), action='store', type='character', dest='extended_output', help='If TRUE additional stats on signature coverage etc. will be included as row annotations in the GCT results files.', default = TRUE),
make_option( c("-e", "--export"), action='store', type='character', dest='export_signat_gct', help='For each signature export expression GCT files.', default = TRUE),
make_option( c("-g", "--globalfdr"), action='store', type='character', dest='global_fdr', help='If TRUE global FDR across all data columns is calculated.', default = FALSE),
make_option( c("-l", "--lightspeed"), action='store', type='character', dest='multi_core', help='If TRUE processing will be parallized across gene sets. (I ran out of single letters to define parameters...)', default = TRUE),
make_option( c("-y", "--yaml"), action='store', type='character', dest='yaml_file', help='Parameter file (.yaml)', default = NA)
)

## #####################################
## source the actual script
source(file.path(script.dir, 'src', 'ssGSEA2.0.R'))
source(file.path(script.dir, 'src','parse_yaml_ssgsea.R'))

# parse command line parameters
opt <- parse_param_ssgsea(option_list)

# hard-coded parameters
spare.cores <- 0 # use all available cpus
log.file <- paste(opt$output.prefix, '_ssgsea.log.txt', sep='')


## ######################################################################################################
##
## run ssGSEA
##
## ######################################################################################################
res <- ssGSEA2(
input.ds=opt$input_ds,
output.prefix=opt$output_prefix,
gene.set.databases=opt$gene_set_databases,
sample.norm.type=opt$sample_norm_type,
weight=opt$weight,
statistic=opt$statistic,
output.score.type=opt$output_score_type,
nperm=opt$nperm,
min.overlap=opt$min_overlap,
correl.type=opt$correl_type,
export.signat.gct=opt$export_signat_gct,
extended.output=opt$extended_output,
global.fdr=opt$global_fdr,
par=opt$multi_core,
spare.cores=spare.cores,
log.file=log.file
)



Loading

0 comments on commit fdcb519

Please sign in to comment.