Mercurial > repos > azomics > metacyto_search_cl
annotate metacyto_search_clr.R @ 0:94ac403d134a draft default tip
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
author | azomics |
---|---|
date | Wed, 28 Jul 2021 22:02:38 +0000 |
parents | |
children |
rev | line source |
---|---|
0
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
2 ###################################################################### |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
3 # Copyright (c) 2018 Northrop Grumman. |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
4 # All rights reserved. |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
5 ###################################################################### |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
6 # |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
7 # Version 1 - January 2018 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
8 # Author: Cristel Thomas |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
9 # |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
10 # |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
11 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
12 library(flowCore) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
13 library(MetaCyto) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
14 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
15 check_cluster_def <- function(cl_def) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
16 if (cl_def == "" || cl_def == "None") { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
17 quit(save = "no", status = 14, runLast = FALSE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
18 } else { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
19 tmp <- gsub(" ", "", cl_def, fixed = TRUE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
20 clean_def <- gsub(",", "|", tmp, fixed = TRUE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
21 return(toupper(clean_def)) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
22 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
23 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
24 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
25 path_to_group_file <- function(path_to_result) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
26 grp <- basename(dirname(path_to_result)) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
27 return(paste(grp, "fcs", sep = ".", collapse = NULL)) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
28 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
29 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
30 group_file_to_group_name <- function(result_file) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
31 return(strsplit(result_file, ".", fixed = TRUE)[[1]][1]) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
32 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
33 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
34 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
35 search_cluster_panels <- function(df, fcspaths, fcsnames, outdir="", uc="", |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
36 clusters=vector()) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
37 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
38 working_dir <- "tmp_metacyto" |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
39 working_out <- "tmp_metacyto_out" |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
40 dir.create(working_dir) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
41 dir.create(outdir) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
42 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
43 # reformat summary -- expects csv + 'fcs_names' && 'fcs_files' |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
44 new_df <- file.path(working_dir, "processed_sample_summary.csv") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
45 df$fcs_names <- df$filenames |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
46 df$fcs_files <- df$filenames |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
47 write.csv(df, file = new_df, row.names = F) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
48 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
49 # move && rename FCS files to same directory |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
50 for (i in seq_len(length(fcspaths))) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
51 new_file <- file.path(working_dir, fcsnames[[i]]) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
52 file.copy(fcspaths[[i]], new_file) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
53 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
54 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
55 searchCluster.batch(preprocessOutputFolder = working_dir, |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
56 outpath = working_out, |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
57 clusterLabel = clusters) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
58 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
59 result_files <- list.files(working_out, |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
60 pattern = "cluster_stats_in_each_sample", |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
61 recursive = T, |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
62 full.names = T) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
63 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
64 nb_groups <- length(fcsnames) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
65 no_results <- vector() |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
66 if (length(result_files) != nb_groups) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
67 groups_with_results <- sapply(result_files, path_to_group_file) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
68 ## one or more groups with no results, figure out which |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
69 no_results <- setdiff(fcsnames, groups_with_results) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
70 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
71 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
72 if (length(no_results) == nb_groups) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
73 sink(uc) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
74 cat("No clusters were found in none of the groups.") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
75 sink() |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
76 } else { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
77 unused_clrs <- list() |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
78 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
79 if (length(no_results > 0)) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
80 grp_no_results <- sapply(no_results, group_file_to_group_name) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
81 unused_clrs <- data.frame("cluster_label" = "any", "not_found_in" = grp_no_results) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
82 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
83 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
84 for (result in result_files) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
85 group_name <- strsplit(result, .Platform$file.sep)[[1]][2] |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
86 new_filename <- paste(c(group_name, "cluster_stats.txt"), collapse = "_") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
87 new_path <- file.path(outdir, new_filename) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
88 tmp_df <- read.csv(result) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
89 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
90 used_clr <- as.character(unique(tmp_df$label)) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
91 if (length(used_clr) != length(clusters)) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
92 unused <- setdiff(clusters, used_clr) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
93 tmp_udf <- data.frame("cluster_label" = unused, "not_found_in" = group_name) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
94 unused_clrs <- rbind(unused_clrs, tmp_udf) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
95 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
96 colnames(tmp_df)[[1]] <- "group_name" |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
97 write.table(tmp_df, new_path, quote = F, row.names = F, col.names = T, sep = "\t") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
98 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
99 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
100 if (is.null(dim(unused_clrs))) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
101 sink(uc) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
102 cat("All provided cluster definition were found in all provided FCS files.") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
103 sink() |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
104 } else { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
105 write.table(unused_clrs, uc, quote = F, row.names = F, col.names = T, sep = "\t") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
106 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
107 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
108 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
109 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
110 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
111 check_input <- function(report="", outdir="", list_unused="", list_clusters="", |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
112 fcs_files=list(), grp_names=list(), clusters=vector()) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
113 # check FCS files |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
114 fcspaths <- unlist(fcs_files) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
115 fcsnames <- unlist(grp_names) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
116 ct_files <- 0 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
117 some_pb <- FALSE |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
118 for (i in seq_len(length(fcspaths))) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
119 is_file_valid <- FALSE |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
120 tryCatch({ |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
121 fcs <- read.FCS(fcspaths[[i]], transformation = FALSE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
122 is_file_valid <- TRUE |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
123 }, error = function(ex) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
124 print(paste("File is not a valid FCS file:", fcsnames[[i]], ex)) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
125 }) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
126 if (is_file_valid) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
127 metacyto_pp_check <- if ("sample_id" %in% colnames(fcs)) TRUE else FALSE |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
128 if (metacyto_pp_check) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
129 idx <- length(colnames(fcs)) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
130 ct_files <- ct_files + max(fcs@exprs[, idx]) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
131 } else { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
132 quit(save = "no", status = 11, runLast = FALSE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
133 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
134 } else { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
135 some_pb <- TRUE |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
136 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
137 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
138 # check summary file format |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
139 df <- read.table(report, sep = "\t", header = T, colClasses = "character") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
140 nm <- colnames(df) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
141 check_ab <- if ("antibodies" %in% nm) TRUE else FALSE |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
142 check_sdy <- if ("study_id" %in% nm) TRUE else FALSE |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
143 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
144 if (check_sdy && check_ab) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
145 # check that summary index compatible with FCSs in collection - by number of files == index nb |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
146 if (ct_files != length(df$antibodies)) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
147 quit(save = "no", status = 12, runLast = FALSE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
148 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
149 } else { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
150 quit(save = "no", status = 13, runLast = FALSE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
151 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
152 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
153 if (some_pb) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
154 quit(save = "no", status = 10, runLast = FALSE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
155 } else { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
156 write.table(clusters, list_clusters, quote = F, row.names = F, col.names = F) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
157 search_cluster_panels(df, fcspaths, fcsnames, outdir, list_unused, clusters) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
158 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
159 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
160 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
161 ################################################################################ |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
162 ################################################################################ |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
163 args <- commandArgs(trailingOnly = TRUE) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
164 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
165 i <- grep(args, pattern = "FCS_FILES") |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
166 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
167 cluster_def <- vector() |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
168 cl_df <- args[3] |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
169 if (i > 6) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
170 ii <- i - 1 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
171 more_cl <- args[6:ii] |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
172 cl_df <- c(cl_df, more_cl) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
173 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
174 cluster_def <- sapply(cl_df, check_cluster_def) |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
175 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
176 fcs_files <- list() |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
177 fcs_names <- list() |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
178 j <- 1 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
179 m <- i + 1 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
180 tmp_fcs <- args[m:length(args)] |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
181 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
182 for (k in seq_len(length(tmp_fcs))) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
183 if (k %% 2) { |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
184 fcs_files[[j]] <- tmp_fcs[[k]] |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
185 fcs_names[[j]] <- tmp_fcs[[k + 1]] |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
186 j <- j + 1 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
187 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
188 } |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
189 |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
190 check_input(args[1], args[2], args[4], args[5], fcs_files, fcs_names, |
94ac403d134a
"planemo upload for repository https://github.com/AstraZeneca-Omics/immport-galaxy-tools/tree/master/flowtools/metacyto_search_clr commit a1b796a09f6b30919a73b5ded0ce5a6378317007"
azomics
parents:
diff
changeset
|
191 cluster_def) |