Mercurial > repos > recetox > recetox_aplcms_recover_weaker_signals
annotate main.R @ 1:880dc35a48c2 draft
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 699355cdf45b2157e9eea3962a01950d469fb0ba
| author | recetox | 
|---|---|
| date | Thu, 16 Jun 2022 10:23:42 +0000 | 
| parents | f8f6095377be | 
| children | 
| rev | line source | 
|---|---|
| 0 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 1 library(recetox.aplcms) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 2 library(dplyr) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 3 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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") | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 8 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 9 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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") | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 13 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 14 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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") | 
| 
f8f6095377be
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") { | 
| 
f8f6095377be
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] | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 21 } else { | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 23 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 24 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 25 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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") | 
| 
f8f6095377be
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))) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 29 | 
| 
f8f6095377be
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))) { | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 31 subdata <- peak_table %>% | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 32 filter(sample == level) %>% | 
| 
f8f6095377be
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"))) %>% | 
| 
f8f6095377be
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") | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 36 } | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 38 return(output_table) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 39 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 40 | 
| 
f8f6095377be
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() { | 
| 
f8f6095377be
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", | 
| 
f8f6095377be
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", | 
| 
f8f6095377be
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)", | 
| 
f8f6095377be
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)") | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 46 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 47 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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() | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 51 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 52 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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()) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 55 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 56 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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")) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 59 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 60 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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)) | 
| 
f8f6095377be
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") | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 65 dir.create("extracted") | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 67 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 68 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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)) | 
| 
f8f6095377be
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") | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 73 dir.create("corrected") | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 75 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 76 | 
| 
f8f6095377be
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, ...) { | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 79 | 
| 
f8f6095377be
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, ...) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 81 | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 84 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 85 | 
| 
f8f6095377be
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, ...) { | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 88 | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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, ...) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 91 | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 94 | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 97 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 98 | 
| 
f8f6095377be
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) { | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 102 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 103 | 
| 
f8f6095377be
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, | 
| 
f8f6095377be
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, | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 106 aligned_file, | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 107 recovered_file, | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 108 out_format) { | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 111 } | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 112 | 
| 
f8f6095377be
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, ...) { | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 116 | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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, ...) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 119 | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
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) | 
| 
f8f6095377be
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 19de0924a65bc65cbbf7c1fc17e9b5348305f95c
 recetox parents: diff
changeset | 123 } | 
