annotate main.R @ 0:067a308223e3 draft

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