Skip to content

Commit

Permalink
add reordering capability for command-line implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
atc3 committed Apr 10, 2019
1 parent ab10e6f commit 7cf05d2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
15 changes: 14 additions & 1 deletion do-ms_cmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ if(!exists('.config')) {
help='Exclude raw files matching this regular expression. e.g., "SQC98[ABC]"')
parser$add_argument('--exp_names', type='character', nargs='+',
help='Rename raw files with short names. e.g., "Control 2X 4X 10X"')
parser$add_argument('--exp_order', type='integer', nargs='+',
help='Reorder raw files in plots. Files are by default ordered alphabetically, so indices refer to the original order. For example, to get A B C D --> D A C B, put "4 1 3 2"')
parser$add_argument('--pep_thresh', type='double',
help='PEP threshold for identified peptides, remove all below this threshold. e.g., "0.01"')

Expand Down Expand Up @@ -403,6 +405,17 @@ for(f in config[['load_input_files']]) {
.labels <- .labels[1:length(.levels)]
}

# apply re-ordering
.file_order <- config[['exp_order']]
if(is.null(.file_order)) {
.file_order <- c()
}

if(length(unique(.file_order)) == length(.levels) & min(.file_order) == 1 & max(.file_order) == length(.levels)) {
.levels <- .levels[.file_order]
.labels <- .labels[.file_order]
}

# recalculate file levels
data[[file$name]]$Raw.file <- factor(data[[file$name]]$Raw.file,
levels=.levels, labels=.labels)
Expand Down Expand Up @@ -430,6 +443,6 @@ f_data <- function() { data }

generate_report(input, f_data, raw_files, config[['output']], progress_bar=FALSE)

prnt(paste0('Report written to: ', config[['output']]))
# prnt(paste0('Report written to: ', config[['output']]))

prnt('Done!')
3 changes: 3 additions & 0 deletions example/config_file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ exp_names:
- '2X'
- '4X'
- '10X'

# custom order for files
exp_order: [4,2,3,1]

pep_thresh: 0.01
pif_thresh: 0.7
Expand Down
3 changes: 3 additions & 0 deletions example/config_sqc68.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ exp_names:
- '250ms IT'
- '500ms IT'
- '1000ms IT'

# custom order for files
exp_order: [1,2,3]

pep_thresh: 1
pif_thresh: 0
Expand Down
2 changes: 1 addition & 1 deletion server.R
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ shinyServer(function(input, output, session) {
# level ordering
file_order <- reactiveVal()

# recalculate file levels
# initialize file ordering
# only triggers when raw files or format has changed
observe({
.raw_files <- raw_files()
Expand Down

0 comments on commit 7cf05d2

Please sign in to comment.