annotate main.R @ 0:c67f0eb6a909 draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
author recetox
date Thu, 26 May 2022 16:47:09 +0000
parents
children 87b669bdb51a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
1 library(recetox.aplcms)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
2 library(dplyr)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
3
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
4 save_extracted_features <- function(df, filename) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
5 df <- as.data.frame(df)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
6 columns <- c("mz", "pos", "sd1", "sd2", "area")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
7 arrow::write_parquet(df[columns], filename)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
8 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
9
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
10 save_aligned_feature_table <- function(df, filename) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
11 columns <- c("feature", "mz", "rt", "sample", "sample_rt", "sample_intensity")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
12 arrow::write_parquet(df[columns], filename)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
13 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
14
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
15 save_recovered_feature_table <- function(df, filename, out_format) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
16 columns <- c("feature", "mz", "rt", "sample", "sample_rt", "sample_intensity")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
17 if (out_format == "recetox") {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
18 peak_table <- df[columns]
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
19 recetox_peak_table <- rcx_aplcms_to_rcx_xmsannotator(peak_table)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
20 arrow::write_parquet(recetox_peak_table, filename)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
21 } else {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
22 arrow::write_parquet(df[columns], filename)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
23 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
24 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
25
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
26 rcx_aplcms_to_rcx_xmsannotator <- function(peak_table) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
27 col_base <- c("feature", "mz", "rt")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
28 output_table <- peak_table %>% distinct(across(any_of(col_base)))
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
29
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
30 for (level in levels(factor(peak_table$sample))) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
31 subdata <- peak_table %>%
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
32 filter(sample == level) %>%
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
33 select(any_of(c(col_base, "sample_intensity"))) %>%
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
34 rename(!!level := "sample_intensity")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
35 output_table <- inner_join(output_table, subdata, by = col_base)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
36 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
37 output_table <- output_table %>% rename(peak = feature)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
38 return(output_table)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
39 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
40
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
41 known_table_columns <- function() {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
42 c("chemical_formula", "HMDB_ID", "KEGG_compound_ID", "mass", "ion.type",
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
43 "m.z", "Number_profiles_processed", "Percent_found", "mz_min", "mz_max",
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
44 "RT_mean", "RT_sd", "RT_min", "RT_max", "int_mean(log)", "int_sd(log)",
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
45 "int_min(log)", "int_max(log)")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
46 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
47
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
48 save_known_table <- function(df, filename) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
49 columns <- known_table_columns()
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
50 arrow::write_parquet(df[columns], filename)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
51 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
52
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
53 read_known_table <- function(filename) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
54 arrow::read_parquet(filename, col_select = known_table_columns())
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
55 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
56
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
57 save_pairing <- function(df, filename) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
58 write.table(df, filename, row.names = FALSE, col.names = c("new", "old"))
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
59 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
60
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
61 save_all_extracted_features <- function(dfs, filenames) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
62 filenames <- tools::file_path_sans_ext(basename(filenames))
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
63 filenames <- paste0(filenames, ".parquet")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
64 filenames <- file.path("extracted", filenames)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
65 dir.create("extracted")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
66 mapply(save_extracted_features, dfs, filenames)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
67 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
68
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
69 save_all_corrected_features <- function(dfs, filenames) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
70 filenames <- tools::file_path_sans_ext(basename(filenames))
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
71 filenames <- paste0(filenames, ".parquet")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
72 filenames <- file.path("corrected", filenames)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
73 dir.create("corrected")
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
74 mapply(save_extracted_features, dfs, filenames)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
75 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
76
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
77 unsupervised_main <- function(sample_files, aligned_file, recovered_file, out_format, ...) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
78 sample_files <- sort_samples_by_acquisition_number(sample_files)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
79
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
80 res <- unsupervised(filenames = sample_files, ...)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
81
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
82 save_all_extracted_features(res$extracted_features, sample_files)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
83 save_all_corrected_features(res$corrected_features, sample_files)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
84
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
85 save_aligned_feature_table(res$aligned_feature_sample_table, aligned_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
86 save_recovered_feature_table(res$recovered_feature_sample_table, recovered_file, out_format)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
87 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
88
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
89 hybrid_main <- function(sample_files, known_table_file, updated_known_table_file, pairing_file, aligned_file, recovered_file, out_format, ...) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
90 sample_files <- sort_samples_by_acquisition_number(sample_files)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
91
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
92 known <- read_known_table(known_table_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
93 res <- hybrid(filenames = sample_files, known_table = known, ...)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
94
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
95 save_known_table(res$updated_known_table, updated_known_table_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
96 save_pairing(res$features_known_table_pairing, pairing_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
97
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
98 save_all_extracted_features(res$extracted_features, sample_files)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
99 save_all_corrected_features(res$corrected_features, sample_files)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
100
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
101 save_aligned_feature_table(res$aligned_feature_sample_table, aligned_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
102 save_recovered_feature_table(res$recovered_feature_sample_table, recovered_file, out_format)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
103 }
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
104
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
105 two_step_hybrid_main <- function(sample_files, known_table_file, updated_known_table_file, recovered_file, aligned_file, out_format, metadata, ...) {
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
106 sample_files <- sort_samples_by_acquisition_number(sample_files)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
107 metadata <- read.table(metadata, sep = ",", header = TRUE)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
108
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
109 known_table <- read_known_table(known_table_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
110 res <- two.step.hybrid(filenames = sample_files, known.table = known_table, work_dir = getwd(), metadata = metadata, ...)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
111
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
112 save_known_table(res$known_table, updated_known_table_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
113 save_aligned_feature_table(res$aligned_features, aligned_file)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
114 save_recovered_feature_table(res$final_features, recovered_file, out_format)
c67f0eb6a909 planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff changeset
115 }