Skip to content

Commit

Permalink
Allow files outside data/source (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adafede committed Aug 30, 2023
1 parent d4e15e7 commit 49ec2f0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
46 changes: 29 additions & 17 deletions inst/app/R/save_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,28 @@ save_input <- function(input) {
timaR::load_yaml_files()

## Params occurring more than once
fil_fea_raw <<- shiny::isolate(input$fil_fea_raw)[[1]]
fil_spe_raw <<- shiny::isolate(input$fil_spe_raw)[[1]]
fil_tax_raw <<- shiny::isolate(input$fil_tax_raw)[[1]]
## This allows to keep files correctly placed in `data/source` clean
prefil_fea_raw <- shiny::isolate(input$fil_fea_raw)
prefil_spe_raw <- shiny::isolate(input$fil_spe_raw)
prefil_tax_raw <- shiny::isolate(input$fil_tax_raw)
prefil_fea_raw_1 <- file.path(paths_data_source,prefil_fea_raw[[1]])
prefil_spe_raw_1 <- file.path(paths_data_source,prefil_spe_raw[[1]])
prefil_tax_raw_1 <- file.path(paths_data_source,prefil_tax_raw[[1]])
if (file.exists(prefil_fea_raw_1)) {
fil_fea_raw <<- prefil_fea_raw_1
} else {
fil_fea_raw <<- prefil_fea_raw[[4]]
}
if (file.exists(prefil_spe_raw_1)) {
fil_spe_raw <<- prefil_spe_raw_1
} else {
fil_fea_raw <<- prefil_spe_raw[[4]]
}
if (file.exists(prefil_tax_raw_1)) {
fil_tax_raw <<- prefil_tax_raw_1
} else {
fil_tax_raw <<- prefil_tax_raw[[4]]
}

filename <<- shiny::isolate(input$fil_pat)
gnps_job_id <<- shiny::isolate(input$gnps_id)
Expand Down Expand Up @@ -48,14 +67,12 @@ save_input <- function(input) {
`inst/params/prepare_params`$
files$
features$
raw <-
file.path(paths_data_source, fil_fea_raw)
raw <- fil_fea_raw
yamls_params$
`inst/params/prepare_params`$
files$
spectral$
raw <-
file.path(paths_data_source, fil_spe_raw)
raw <- fil_spe_raw
yamls_params$`inst/params/prepare_params`$gnps$id <- gnps_job_id
yamls_params$
`inst/params/prepare_params`$
Expand Down Expand Up @@ -120,8 +137,7 @@ save_input <- function(input) {
yamls_params$annotate_masses$names$target <- names_target
yamls_params$annotate_masses$options$force <- forceps

yamls_params$annotate_spectra$files$spectral$raw <-
file.path(paths_data_source, fil_spe_raw)
yamls_params$annotate_spectra$files$spectral$raw <- fil_spe_raw
yamls_params$
annotate_spectra$
annotations$
Expand Down Expand Up @@ -164,8 +180,7 @@ save_input <- function(input) {
create_edges_spectra$
files$
spectral$
raw <-
file.path(paths_data_source, fil_spe_raw)
raw <- fil_spe_raw
yamls_params$
create_edges_spectra$
annotations$
Expand Down Expand Up @@ -244,8 +259,7 @@ save_input <- function(input) {
prepare_features_tables$
files$
features$
raw <-
file.path(paths_data_source, fil_fea_raw)
raw <- fil_fea_raw
yamls_params$
prepare_features_tables$
names$
Expand Down Expand Up @@ -286,10 +300,8 @@ save_input <- function(input) {
ms$
polarity <- ms_mode

yamls_params$prepare_taxa$files$features$raw <-
file.path(paths_data_source, fil_fea_raw)
yamls_params$prepare_taxa$files$taxa$raw <-
file.path(paths_data_source, fil_tax_raw)
yamls_params$prepare_taxa$files$features$raw <- fil_fea_raw
yamls_params$prepare_taxa$files$taxa$raw <- fil_tax_raw
if (!is.null(gnps_job_id)) {
yamls_params$prepare_taxa$files$taxa$raw <-
file.path(paths_data_source, paste0(gnps_job_id, "_metadata.tsv"))
Expand Down
3 changes: 2 additions & 1 deletion inst/app/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ server <- function(input, output, session) {
)
)
targets::tar_make(
names = matches("ann_pre$"),
names = matches("^ann_pre$"),
garbage_collection = TRUE,
reporter = "verbose_positives"
)
}, finally = {
Expand Down
20 changes: 10 additions & 10 deletions inst/app/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ ui <- fluidPage(
fluidPage(div(
id = "params",
navlistPanel(
widths = c(4, 4),
widths = c(4, 5),
"Parameters",
tabPanel(
title = "Files",
h3("Required files"),
h5("They MUST be located in `data/source`"),
h5("They SHOULD be located in `data/source`"),
div(
fileInput(
inputId = "fil_spe_raw",
Expand All @@ -49,7 +49,7 @@ ui <- fluidPage(
type = "inline",
content = c(
"The MGF file containing your spectra.",
"Must be located in `data/source`.",
"Should be located in `data/source`.",
"Reason therefore is to find it in the future.",
"If you have a GNPS job ID, the spectra will be stored there."
)
Expand All @@ -70,7 +70,7 @@ ui <- fluidPage(
type = "inline",
content = c(
"The csv or tsv file containing your features",
"Must be located in `data/source`.",
"Should be located in `data/source`.",
"Reason therefore is to find it in the future.",
"If you have a GNPS job ID, the spectra will be stored there."
)
Expand All @@ -91,7 +91,7 @@ ui <- fluidPage(
type = "inline",
content = c(
"The csv or tsv file containing the metadata of your experiment.",
"Must be located in `data/source`.",
"Should be located in `data/source`.",
"Reason therefore is to find it in the future.",
"If you have a GNPS job ID, the spectra will be stored there.",
"Do not forget to change the `name` in the corresponding tab."
Expand Down Expand Up @@ -136,8 +136,8 @@ ui <- fluidPage(
label = "Number of final candidates",
min = 1,
max = 500,
step = 1,
value = 3,
step = 1,
ticks = FALSE
) |>
shinyhelper::helper(
Expand Down Expand Up @@ -176,8 +176,8 @@ ui <- fluidPage(
label = "Minimal biological score to keep MS1 only annotation",
min = 0,
max = 1,
value = 0.5,
step = 0.1,
value = 0.6,
step = 0.05,
ticks = FALSE
) |>
shinyhelper::helper(
Expand All @@ -193,7 +193,7 @@ ui <- fluidPage(
label = "Minimal chemical score to keep MS1 only annotation",
min = 0,
max = 1,
value = 0.5,
value = 0.6,
step = 0.1,
ticks = FALSE
) |>
Expand Down Expand Up @@ -239,7 +239,7 @@ ui <- fluidPage(
min = 0,
max = 1,
step = 0.05,
value = 0.1,
value = 0.0,
ticks = FALSE
) |>
shinyhelper::helper(
Expand Down

0 comments on commit 49ec2f0

Please sign in to comment.