Mercurial > repos > azomics > metacyto_preprocess
annotate metacyto_preprocess.R @ 0:bf6470882a15 draft default tip
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
author | azomics |
---|---|
date | Sun, 25 Jul 2021 10:36:03 +0000 |
parents | |
children |
rev | line source |
---|---|
0
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
2 ###################################################################### |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
3 # Copyright (c) 2018 Northrop Grumman. |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
4 # All rights reserved. |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
5 ###################################################################### |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
6 # |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
7 # Version 1 - January 2018 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
8 # Author: Cristel Thomas |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
9 # |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
10 # |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
11 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
12 library(flowCore) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
13 library(MetaCyto) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
14 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
15 compare_lists <- function(m1, m2) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
16 list_check <- T |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
17 if (is.na(all(m1 == m2))) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
18 mm1 <- is.na(m1) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
19 mm2 <- is.na(m2) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
20 if (all(mm1 == mm2)) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
21 if (!all(m1 == m2, na.rm = TRUE)) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
22 list_check <- F |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
23 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
24 } else { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
25 list_check <- F |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
26 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
27 } else if (!all(m1 == m2)) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
28 list_check <- F |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
29 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
30 return(list_check) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
31 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
32 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
33 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
34 run_batch_processing <- function(sampling_size = 5000, flag_default = T, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
35 to_exclude, outdir = "", outfile = "", |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
36 labels, assays, factors, fcspaths, fcsnames) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
37 # Create meta_data object |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
38 fp <- unlist(fcspaths) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
39 file_counts <- lengths(fcspaths) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
40 group_names <- rep(labels, times = file_counts) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
41 group_bs <- rep(factors, times = file_counts) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
42 group_types <- rep(assays, times = file_counts) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
43 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
44 meta_data <- data.frame(fcs_files = fp, study_id = group_names) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
45 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
46 # excluded_parameters |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
47 default_param <- c("FSC-A", "FSC-H", "FSC-W", "FSC", "SSC-A", "SSC-H", |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
48 "SSC-W", "SSC", "Time", "Cell_length", "cell_length", |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
49 "CELL_LENGTH") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
50 excluded_parameters <- if (flag_default) default_param else to_exclude |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
51 # Run preprocessing.batch |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
52 preprocessing.batch(inputMeta = meta_data, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
53 assay = group_types, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
54 b = group_bs, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
55 fileSampleSize = sampling_size, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
56 outpath = outdir, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
57 excludeTransformParameters = excluded_parameters) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
58 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
59 # deal with outputs |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
60 # output[2]: a csv file summarizing the pre-processing result. |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
61 ## -> open file to pull info and print out filenames rather than path. |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
62 tmp_csv <- file.path(outdir, "processed_sample_summary.csv") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
63 tmp <- read.csv(tmp_csv) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
64 tmp$old_index <- seq(1, length(tmp$fcs_names)) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
65 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
66 fn <- unlist(fcsnames) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
67 df <- data.frame(fcs_files = fp, filenames = fn) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
68 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
69 # merge two data frames by ID |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
70 total <- merge(tmp, df, by = "fcs_files") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
71 total2 <- total[order(total$old_index), ] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
72 to_drop <- c("fcs_names", "fcs_files", "old_index") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
73 newdf <- total2[, !(names(total2) %in% to_drop)] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
74 write.table(newdf, file = outfile, quote = F, row.names = F, col.names = T, sep = "\t") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
75 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
76 file.remove(tmp_csv) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
77 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
78 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
79 check_fcs <- function(sampling = 5000, flag_default = TRUE, to_exclude, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
80 outdir = "", outfile = "", labels, assays, factors, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
81 fcspaths, fcsnames) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
82 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
83 if (length(labels) > length(unique(labels))) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
84 # we have repeated group names, all group names need to be different |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
85 print("ERROR: repeated labels among groups, make sure that labels are all different for groups.") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
86 print("The following labels are repeated") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
87 table(labels)[table(labels) > 1] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
88 quit(save = "no", status = 13, runLast = FALSE) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
89 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
90 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
91 marker_pb <- FALSE |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
92 for (i in seq_len(length(fcspaths))) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
93 for (n in seq_len(length(fcspaths[[i]]))) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
94 marker_check <- FALSE |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
95 marker_channel <- FALSE |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
96 tryCatch({ |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
97 fcs <- read.FCS(fcspaths[[i]][[n]], transformation = FALSE) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
98 }, error = function(ex) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
99 print(paste("File is not a valid FCS file:", fnames[[i]][[n]], ex)) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
100 quit(save = "no", status = 10, runLast = FALSE) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
101 }) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
102 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
103 if (n == 1) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
104 m1 <- as.vector(pData(parameters(fcs))$desc) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
105 c1 <- colnames(fcs) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
106 } else { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
107 m2 <- as.vector(pData(parameters(fcs))$desc) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
108 c2 <- colnames(fcs) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
109 marker_check <- compare_lists(m1, m2) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
110 marker_channel <- compare_lists(c1, c2) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
111 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
112 if (n > 1 && marker_check == F) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
113 marker_pb <- TRUE |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
114 print(paste("Marker discrepancy detected in markers -- group", labels[[i]])) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
115 } else if (n > 1 && marker_channel == F) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
116 marker_pb <- TRUE |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
117 print(paste("Marker discrepancy detected in channels -- group", labels[[i]])) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
118 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
119 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
120 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
121 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
122 if (marker_pb) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
123 quit(save = "no", status = 12, runLast = FALSE) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
124 } else { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
125 run_batch_processing(sampling, flag_default, to_exclude, outdir, outfile, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
126 labels, assays, factors, fcspaths, fcsnames) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
127 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
128 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
129 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
130 ################################################################################ |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
131 ################################################################################ |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
132 args <- commandArgs(trailingOnly = TRUE) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
133 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
134 # Arg 1: sub_sampling number |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
135 # Arg 2: output dir for processed FCS files for check_fcs and run_batch_processing |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
136 # Arg 3: Main output file (text file) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
137 # Arg 4: excluded params |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
138 # Arg 5: Group 1 Name |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
139 # Arg 6: Group 1 format |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
140 # Arg 7: Group 1 Scaling factor |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
141 # Cycle through files in group 1 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
142 # Arg : file path in Galaxy |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
143 # Arg : desired real file name |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
144 # Cycle through at at least one additional group |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
145 # Arg : 'new_panel' - used as some sort of delimiter |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
146 # Arg : Group n+1 Name |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
147 # Arg : Group n+1 format |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
148 # Arg : Group n+1 Scaling factor |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
149 ## Cycle through files in that group |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
150 ## Arg : file path in Galaxy |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
151 ## Arg : desired real file path |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
152 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
153 sub_sampling <- NULL |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
154 if (as.numeric(args[1]) > 0) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
155 sub_sampling <- as.numeric(args[1]) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
156 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
157 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
158 # parameters to exclude => args[4] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
159 to_exclude <- vector() |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
160 flag_default <- FALSE |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
161 i <- 1 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
162 if (args[4] == "None" || args[4] == "") { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
163 flag_default <- TRUE |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
164 } else { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
165 excluded <- unlist(strsplit(args[4], ",")) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
166 for (channel in excluded) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
167 stripped_chan <- gsub(" ", "", channel, fixed = TRUE) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
168 if (!is.na(stripped_chan)) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
169 to_exclude[[i]] <- stripped_chan |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
170 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
171 i <- i + 1 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
172 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
173 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
174 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
175 # handle group cycle in arguments to produce iterable panels |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
176 tot_args <- length(args) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
177 tmpargs <- paste(args[5:tot_args], collapse = "=%=") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
178 tmppanels <- strsplit(tmpargs, "=%=new_panel=%=") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
179 nb_panel <- length(tmppanels[[1]]) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
180 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
181 labels <- vector(mode = "character", length = nb_panel) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
182 assay_types <- vector(mode = "character", length = nb_panel) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
183 scaling_factors <- vector(mode = "numeric", length = nb_panel) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
184 filepaths <- list() |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
185 filenames <- list() |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
186 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
187 # iterate over panels (groups of fcs files) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
188 j <- 1 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
189 for (pnl in tmppanels[[1]]) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
190 tmppanel <- strsplit(pnl, "=%=") |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
191 # number of FCS files |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
192 nb_files <- (length(tmppanel[[1]]) - 3) / 2 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
193 tmplist <- character(nb_files) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
194 tmpnames <- character(nb_files) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
195 if (tmppanel[[1]][[1]] == "None" || tmppanel[[1]][[1]] == "") { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
196 print(paste("ERROR: Empty group name/label for group ", j)) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
197 quit(save = "no", status = 11, runLast = FALSE) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
198 } else { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
199 labels[[j]] <- tmppanel[[1]][[1]] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
200 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
201 # assay type |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
202 assay_types[[j]] <- tmppanel[[1]][[2]] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
203 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
204 scaling_factors[[j]] <- 0 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
205 if (as.numeric(tmppanel[[1]][[3]]) > 0) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
206 scaling_factors[[j]] <- 1 / as.numeric(tmppanel[[1]][[3]]) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
207 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
208 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
209 k <- 1 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
210 for (m in 4:length(tmppanel[[1]])) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
211 if (!m %% 2) { |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
212 tmplist[[k]] <- tmppanel[[1]][[m]] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
213 tmpnames[[k]] <- tmppanel[[1]][[m + 1]] |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
214 k <- k + 1 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
215 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
216 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
217 filepaths[[tmppanel[[1]][1]]] <- tmplist |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
218 filenames[[tmppanel[[1]][1]]] <- tmpnames |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
219 j <- j + 1 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
220 } |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
221 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
222 check_fcs(sub_sampling, flag_default, to_exclude, args[2], args[3], labels, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
223 assay_types, scaling_factors, filepaths, filenames) |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
224 |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
225 # check_fcs <- function(sampling = 5000, flag_default = TRUE, to_exclude, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
226 # outdir = "", outfile = "", labels, assays, factors, |
bf6470882a15
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_preprocess commit c3d761b4fca140636c3f22ef0fdbb855f3ecbdb8"
azomics
parents:
diff
changeset
|
227 # fcspaths, fcsnames) |