Mercurial > repos > recetox > recetox_aplcms_compute_template
comparison utils.R @ 2:ca19ce8c2801 draft
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit 724ecb1b81ebd8a67488b8a9397177b2ff0357db
author | recetox |
---|---|
date | Wed, 24 May 2023 14:49:52 +0000 |
parents | 4ad1dd1c849b |
children | e94c0720fbf7 |
comparison
equal
deleted
inserted
replaced
1:4ad1dd1c849b | 2:ca19ce8c2801 |
---|---|
37 features <- lapply(files, arrow::read_parquet) | 37 features <- lapply(files, arrow::read_parquet) |
38 features <- lapply(features, tibble::as_tibble) | 38 features <- lapply(features, tibble::as_tibble) |
39 return(features) | 39 return(features) |
40 } | 40 } |
41 | 41 |
42 save_parquet_collection <- function(table, sample_names, subdir) { | 42 save_parquet_collection <- function(feature_tables, sample_names, subdir) { |
43 dir.create(subdir) | 43 dir.create(subdir) |
44 for (i in seq_len(length(table$feature_tables))) { | 44 for (i in seq_len(length(feature_tables))) { |
45 filename <- file.path(subdir, paste0(subdir, "_", sample_names[i], ".parquet")) | 45 filename <- file.path(subdir, paste0(subdir, "_", sample_names[i], ".parquet")) |
46 feature_table <- as.data.frame(table$feature_tables[[i]]) | 46 feature_table <- as.data.frame(feature_tables[[i]]) |
47 feature_table <- save_sample_name(feature_table, sample_names[i]) | 47 feature_table <- save_sample_name(feature_table, sample_names[i]) |
48 arrow::write_parquet(feature_table, filename) | 48 arrow::write_parquet(feature_table, filename) |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
55 | 55 |
56 save_tolerances <- function(table, tol_file) { | 56 save_tolerances <- function(table, tol_file) { |
57 mz_tolerance <- c(table$mz_tol_relative) | 57 mz_tolerance <- c(table$mz_tol_relative) |
58 rt_tolerance <- c(table$rt_tol_relative) | 58 rt_tolerance <- c(table$rt_tol_relative) |
59 arrow::write_parquet(data.frame(mz_tolerance, rt_tolerance), tol_file) | 59 arrow::write_parquet(data.frame(mz_tolerance, rt_tolerance), tol_file) |
60 } | |
61 | |
62 get_mz_tol <- function(tolerances) { | |
63 return(tolerances$mz_tolerance) | |
64 } | |
65 | |
66 get_rt_tol <- function(tolerances) { | |
67 return(tolerances$rt_tolerance) | |
68 } | 60 } |
69 | 61 |
70 save_aligned_features <- function(aligned_features, metadata_file, rt_file, intensity_file) { | 62 save_aligned_features <- function(aligned_features, metadata_file, rt_file, intensity_file) { |
71 save_data_as_parquet_file(aligned_features$metadata, metadata_file) | 63 save_data_as_parquet_file(aligned_features$metadata, metadata_file) |
72 save_data_as_parquet_file(aligned_features$rt, rt_file) | 64 save_data_as_parquet_file(aligned_features$rt, rt_file) |