Mercurial > repos > azomics > fcs_merge_downsample
annotate FCSMergeDownsample.R @ 1:04afe468b234 draft default tip
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit d62d7d86dafd09575d91ddb6d07a8dd6a6dc4a27"
author | azomics |
---|---|
date | Mon, 06 Jul 2020 19:22:44 -0400 |
parents | 8e568997abda |
children |
rev | line source |
---|---|
0
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
1 #!/usr/bin/Rscript |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
2 # Aggregate FCS files Module for Galaxy |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
3 # with FlowSOM AggregateFlowFrames |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
4 ###################################################################### |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
5 # Copyright (c) 2017 Northrop Grumman. |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
6 # All rights reserved. |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
7 ###################################################################### |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
8 # |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
9 # Version 1 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
10 # Cristel Thomas |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
11 # |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
12 # |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
13 library(FlowSOM) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
14 library(flowCore) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
15 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
16 downsampleMergeFCS <- function(fcs_files, nb_cells, output="", flag_fcs=FALSE) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
17 ff <- AggregateFlowFrames(fcs_files, nb_cells, writeOutput = FALSE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
18 n <- length(colnames(ff)) - 2 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
19 exprs(ff) <- exprs(ff)[,1:n] |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
20 if (flag_fcs) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
21 write.FCS(ff, output) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
22 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
23 saveRDS(ff, file=output) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
24 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
25 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
26 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
27 checkFCSfiles <- function(fcsfiles, ds_factor=0.1, out_file ="", |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
28 flag_fcs=FALSE) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
29 isValid <- F |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
30 nb_events <- 0 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
31 markerCheck <- T |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
32 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
33 for (i in 1:length(fcsfiles)){ |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
34 is_file_valid <- F |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
35 tryCatch({ |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
36 fcs <- read.FCS(fcsfiles[i], transformation=FALSE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
37 is_file_valid <- T |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
38 nb_events <- nb_events + as.numeric(fcs@description$`$TOT`) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
39 }, error = function(ex) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
40 print(paste(ex)) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
41 }) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
42 if (is_file_valid){ |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
43 if (i == 1) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
44 m1 <- as.vector(pData(parameters(fcs))$desc) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
45 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
46 m2 <- as.vector(pData(parameters(fcs))$desc) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
47 if (is.na(all(m1==m2))) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
48 mm1 <- is.na(m1) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
49 mm2 <- is.na(m2) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
50 if (all(mm1==mm2)){ |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
51 if (!all(m1==m2, na.rm=TRUE)){ |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
52 markerCheck <- F |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
53 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
54 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
55 markerCheck <- F |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
56 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
57 } else if (!all(m1==m2)) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
58 markerCheck <- F |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
59 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
60 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
61 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
62 quit(save = "no", status = 10, runLast = FALSE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
63 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
64 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
65 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
66 if (markerCheck) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
67 isValid <- T |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
68 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
69 quit(save = "no", status = 12, runLast = FALSE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
70 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
71 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
72 ## translate ds_factor to nb of events |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
73 nb_cell <- floor(ds_factor*nb_events) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
74 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
75 if (isValid) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
76 downsampleMergeFCS(fcsfiles, nb_cell, out_file, flag_fcs) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
77 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
78 quit(save = "no", status = 10, runLast = FALSE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
79 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
80 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
81 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
82 args <- commandArgs(trailingOnly = TRUE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
83 flag_fcs <- FALSE |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
84 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
85 if (args[2] == "FCS"){ |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
86 flag_fcs <- TRUE |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
87 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
88 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
89 if (args[3] == "" || args[3] == "i.e.:0.1 or 10X") { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
90 factor <- 0.1 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
91 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
92 #rm last X if it's there |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
93 ds <- gsub("X", "", args[3]) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
94 if (!is.na(as.numeric(ds))) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
95 factor <- as.numeric(ds) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
96 if (factor > 1 && factor <= 100) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
97 factor <- as.numeric(ds) / 100 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
98 } else if (factor > 100){ |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
99 quit(save = "no", status = 11, runLast = FALSE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
100 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
101 } else { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
102 quit(save = "no", status = 11, runLast = FALSE) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
103 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
104 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
105 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
106 nb_files <- (length(args) - 3) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
107 fcsfiles <- character(nb_files) |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
108 j <- 1 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
109 ## get files and file names |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
110 for (i in 4:length(args)) { |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
111 fcsfiles[[j]] <- args[i] |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
112 j <- j + 1 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
113 } |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
114 |
8e568997abda
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_merge_downsample commit 2fe0269eaff92916ca51729a7ca8d2017f65f89f"
azomics
parents:
diff
changeset
|
115 checkFCSfiles(fcsfiles, factor, args[1], flag_fcs) |