Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ Collate:
'annotate_spectra.R'
'benchmark_taxize_spectra.R'
'calculate_entropy.R'
'load_yaml_files.R'
'go_to_cache.R'
'create_dir.R'
'change_params_small.R'
'clean_bio.R'
'filter_high_confidence_only.R'
'columns_model.R'
Expand All @@ -102,7 +106,6 @@ Collate:
'complement_metadata_structures.R'
'copy_backbone.R'
'create_components.R'
'create_dir.R'
'create_edges.R'
'create_edges_spectra.R'
'decorate_bio.R'
Expand All @@ -117,7 +120,6 @@ Collate:
'fake_lotus.R'
'fake_sop_columns.R'
'filter_annotations.R'
'go_to_cache.R'
'get_file.R'
'get_example_sirius.R'
'get_example_files.R'
Expand All @@ -129,7 +131,6 @@ Collate:
'harmonize_names_sirius.R'
'harmonize_spectra.R'
'install.R'
'load_yaml_files.R'
'log_debug.R'
'pre_harmonize_names_sirius.R'
'select_annotations_columns.R'
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(annotate_masses)
export(annotate_spectra)
export(calculate_mass_of_m)
export(change_params_small)
export(create_components)
export(create_dir)
export(create_edges_spectra)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# tima 2.11.0

* Added convenience function to change small parameters (#177)
* Added demo files download to the app
* Better packaging
* Improved documentation
Expand Down
124 changes: 124 additions & 0 deletions R/change_params_small.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#' @title Change Params Small
#'
#' @description This function helps changing convenience parameters.
#'
#' @include create_dir.R
#' @include get_default_paths.R
#' @include go_to_cache.R
#' @include load_yaml_files.R
#'
#' @param fil_pat The pattern identifying your whole job. You can put whatever you want. STRING
#' @param fil_fea_raw The path to the file containing your features' intensities. Can be generated by mzmine3 or SLAW. STRING
#' @param fil_met_raw The path to the file containing your metadata. If your experiment contains a single taxon, you can provide it below instead. STRING
#' @param fil_sir_raw The directory containing the sirius annotations. STRING
#' @param fil_spe_raw The path to the file containing your features' spectra. Can contain MS1 and/or MS2 spectra. STRING
#' @param ms_pol The polarity used. Must be either "pos" or "neg". STRING
#' @param org_tax If your experiment contains a single taxon, its scientific name. "Homo sapiens". STRING
#' @param hig_con Filter high confidence candidates only. BOOLEAN
#' @param summarise Summarize all candidates per feature to a single row. BOOLEAN
#'
#' @export
#'
#' @return YAML file with changed parameters.
#'
#' @examples
#' \dontrun{
#' tima:::copy_backbone()
#' tima::change_params_small(
#' fil_pat = "myExamplePattern",
#' fil_fea_raw = "myExampleDir/myExampleFeatures.csv",
#' fil_met_raw = "myExampleDir2SomeWhereElse/myOptionalMetadata.tsv",
#' fil_sir_raw = "myExampleDir3/myAwesomeSiriusProject.zip",
#' fil_spe_raw = "myBeautifulSpectra.mgf",
#' ms_pol = "pos",
#' org_tax = "Gentiana lutea",
#' hig_con = TRUE,
#' summarise = FALSE
#' )
#' }
change_params_small <- function(fil_pat = NULL,
fil_fea_raw = NULL,
fil_met_raw = NULL,
fil_sir_raw = NULL,
fil_spe_raw = NULL,
ms_pol = NULL,
org_tax = NULL,
hig_con = NULL,
summarise = NULL) {
tima:::go_to_cache()
paths_data_source <- tima:::get_default_paths()$data$source$path
paths_data_interim_annotations <-
tima:::get_default_paths()$data$interim$annotations$path
tima:::create_dir(paths_data_source)
list <- tima:::load_yaml_files()

yamls_params <- list$yamls_params
yaml_files <- list$yaml_files
yaml_names <- list$yaml_names

yaml_small <- yamls_params[["params/prepare_params"]]
if (!is.null(fil_pat)) {
yaml_small$files$pattern <- fil_pat
}
if (!is.null(fil_fea_raw)) {
stopifnot("Your features' file does not exist" = file.exists(fil_fea_raw))
fil_fea_raw_rdy <- paths_data_source |>
file.path(basename(fil_fea_raw))
fs::file_copy(
path = fil_fea_raw,
new_path = fil_fea_raw_rdy,
overwrite = TRUE
)
yaml_small$files$features$raw <- fil_fea_raw_rdy
}
if (!is.null(fil_met_raw)) {
stopifnot("Your metadata file does not exist" = file.exists(fil_met_raw))
fil_met_raw_rdy <- paths_data_source |>
file.path(basename(fil_met_raw))
fs::file_copy(
path = fil_met_raw,
new_path = fil_met_raw_rdy,
overwrite = TRUE
)
yaml_small$files$metadata$raw <- fil_met_raw_rdy
}
if (!is.null(fil_sir_raw)) {
stopifnot("Your sirius directory does not exist" = file.exists(fil_sir_raw))
fil_sir_raw_rdy <- paths_data_interim_annotations |>
file.path(basename(fil_sir_raw))
fs::file_copy(
path = fil_sir_raw,
new_path = fil_sir_raw_rdy,
overwrite = TRUE
)
yaml_small$files$annotations$raw$sirius <- fil_sir_raw_rdy
}
if (!is.null(fil_spe_raw)) {
stopifnot("Your spectra file does not exist" = file.exists(fil_spe_raw))
fil_spe_raw_rdy <- paths_data_source |>
file.path(basename(fil_spe_raw))
fs::file_copy(
path = fil_spe_raw,
new_path = fil_spe_raw_rdy,
overwrite = TRUE
)
yaml_small$files$spectral$raw <- fil_spe_raw_rdy
}
if (!is.null(ms_pol)) {
yaml_small$ms$polarity <- ms_pol
}
if (!is.null(org_tax)) {
yaml_small$organisms$taxon <- org_tax
}
if (!is.null(hig_con)) {
yaml_small$options$high_confidence <- hig_con
}
if (!is.null(summarise)) {
yaml_small$options$summarise <- summarise
}

yaml::write_yaml(
x = yaml_small,
file = tima:::get_default_paths()$params$prepare_params
)
}
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
"SystemRequirements": null
},
"keywords": ["metaboliteannotation", "chemotaxonomy", "scoringsystem", "naturalproducts", "computationalmetabolomics", "taxonomicdistance", "specializedmetabolome"],
"fileSize": "4078.719KB",
"fileSize": "4086.17KB",
"citation": [
{
"@type": "SoftwareSourceCode",
Expand Down
59 changes: 59 additions & 0 deletions man/change_params_small.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/testthat/test-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,21 @@ test_that(desc = "Test functions", code = {
# tima:::.onLoad()
# tima_full()

## Change small params
get_example_files()
change_params_small()
change_params_small(
fil_pat = "myExamplePattern",
fil_fea_raw = paths$data$source$features,
fil_met_raw = paths$data$source$metadata,
fil_sir_raw = paths$data$interim$annotations$example_sirius$v6,
fil_spe_raw = paths$data$source$spectra,
ms_pol = "pos",
org_tax = "Gentiana lutea",
hig_con = TRUE,
summarise = FALSE
)

## CLI arguments check
arguments <- character()
arguments$ann_can_fin <- 0
Expand Down
16 changes: 16 additions & 0 deletions vignettes/tima.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,19 @@ If you do not even need a GUI ☠️:
```{r eval=FALSE, include=TRUE}
tima::tima_full()
```

In case you just want to change some small parameters between jobs, a convenience function is available:

```{r eval=FALSE, include=TRUE}
tima::change_params_small(
fil_pat = "myExamplePattern",
fil_fea_raw = "myExampleDir/myExampleFeatures.csv",
fil_met_raw = "myExampleDir2SomeWhereElse/myOptionalMetadata.tsv",
fil_sir_raw = "myExampleDir3/myAwesomeSiriusProject.zip",
fil_spe_raw = "myBeautifulSpectra.mgf",
ms_pol = "pos",
org_tax = "Gentiana lutea",
hig_con = TRUE,
summarise = FALSE
)
```