Mercurial > repos > recetox > recetox_aplcms_two_step_hybrid
annotate main.R @ 1:87b669bdb51a draft default tip
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
author | recetox |
---|---|
date | Fri, 10 Jun 2022 10:15:47 +0000 |
parents | c67f0eb6a909 |
children |
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 |
1
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
82 save_all_features(res, sample_files) |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
83 save_all_feature_tables(res$aligned_feature_sample_table, res$recovered_feature_sample_table, aligned_file, recovered_file, out_format) |
0
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 |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
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, ...) { |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff
changeset
|
87 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
|
88 |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff
changeset
|
89 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
|
90 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
|
91 |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff
changeset
|
92 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
|
93 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
|
94 |
1
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
95 save_all_features(res, sample_files) |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
96 save_all_feature_tables(res$aligned_feature_sample_table, res$recovered_feature_sample_table, aligned_file, recovered_file, out_format) |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
97 } |
0
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff
changeset
|
98 |
1
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
99 save_all_features <- function(result, sample_files) { |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
100 save_all_extracted_features(result$extracted_features, sample_files) |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
101 save_all_corrected_features(result$corrected_features, sample_files) |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
102 } |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
103 |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
104 save_all_feature_tables <- function(aligned_feature_sample_table, |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
105 recovered_feature_sample_table, |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
106 aligned_file, |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
107 recovered_file, |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
108 out_format) { |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
109 save_aligned_feature_table(aligned_feature_sample_table, aligned_file) |
87b669bdb51a
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
recetox
parents:
0
diff
changeset
|
110 save_recovered_feature_table(recovered_feature_sample_table, recovered_file, out_format) |
0
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 |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
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, ...) { |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff
changeset
|
114 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
|
115 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
|
116 |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff
changeset
|
117 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
|
118 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
|
119 |
c67f0eb6a909
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit b3e0c34f12c9c38fb34bf48197974620d60b50c5
recetox
parents:
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 } |