diff utils.R @ 1:2c6fa447f6a0 draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox-xmsannotator commit 8547c5323747595eabbeed29039a1b2363491243
author recetox
date Thu, 20 Jul 2023 06:29:06 +0000
parents cfd2e19f00a9
children 6b5dec818827
line wrap: on
line diff
--- a/utils.R	Mon Jun 26 13:55:56 2023 +0000
+++ b/utils.R	Thu Jul 20 06:29:06 2023 +0000
@@ -2,36 +2,36 @@
 library(dplyr)
 
 load_table <- function(filename, filetype) {
-    if (filename == "None") {
-        return(NULL)
-    }
-    if (filetype == "csv") {
-        return(as.data.frame(read.csv(filename)))
-    } else {
-        return(as.data.frame(arrow::read_parquet(filename)))
-    }
+  if (filename == "None") {
+    return(NULL)
+  }
+  if (filetype == "csv") {
+    return(as.data.frame(read.csv(filename)))
+  } else {
+    return(as.data.frame(arrow::read_parquet(filename)))
+  }
 }
 
 save_table <- function(table, filename, filetype) {
-    if (filetype == "csv") {
-        write.csv(table, filename, row.names = FALSE)
-    } else {
-        arrow::write_parquet(table, filename)
-    }
+  if (filetype == "csv") {
+    write.csv(table, filename, row.names = FALSE)
+  } else {
+    arrow::write_parquet(table, filename)
+  }
 }
 
 create_filter_by_adducts <- function(comma_separated_values) {
-    if (comma_separated_values == "None") {
-        return(NA)
-    }
-    filter_by <- strsplit(trimws(comma_separated_values), ",")[[1]]
-    return(filter_by)
+  if (comma_separated_values == "None") {
+    return(NA)
+  }
+  filter_by <- strsplit(trimws(comma_separated_values), ",")[[1]]
+  return(filter_by)
 }
 
 create_peak_table <- function(metadata_table, intensity_table) {
-    metadata_table <- select(metadata_table, id, mz, rt)
-    peak_table <- inner_join(metadata_table, intensity_table, by = "id")
-    peak_table <- rename(peak_table, peak = id)
-    peak_table$peak <- as.integer(peak_table$peak)
-    return(peak_table)
+  metadata_table <- select(metadata_table, id, mz, rt)
+  peak_table <- inner_join(metadata_table, intensity_table, by = "id")
+  peak_table <- rename(peak_table, peak = id)
+  peak_table$peak <- as.integer(peak_table$peak)
+  return(peak_table)
 }