Mercurial > repos > azomics > edit_fcs_markers
annotate editFCSmarkers.R @ 0:02b2412598b6 draft default tip
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
author | azomics |
---|---|
date | Mon, 22 Jun 2020 20:07:30 -0400 |
parents | |
children |
rev | line source |
---|---|
0
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
1 #!/usr/bin/Rscript |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
2 # modify channels and marker names in FCS |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
3 # |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
4 ###################################################################### |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
5 # Copyright (c) 2017 Northrop Grumman. |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
6 # All rights reserved. |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
7 ###################################################################### |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
8 # |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
9 # Cristel Thomas |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
10 # Version 2 - May 2018 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
11 # Modified to take in marker/channel names by name rather than index |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
12 # |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
13 library(flowCore) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
14 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
15 checkCandM <- function(m_set, channels=vector(), markers=vector()){ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
16 if (m_set[[3]]){ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
17 in_file <- m_set[[1]] %in% channels |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
18 } else { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
19 in_file <- m_set[[1]] %in% markers |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
20 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
21 if (sum(in_file)==0) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
22 warning("Given original columns are either not in the channels or in the markers of the read object. Will fail.") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
23 return(FALSE) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
24 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
25 return(TRUE) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
26 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
27 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
28 modifyMarkersFCS <- function(input, output="", report="", flag_fcs=F, |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
29 marker_sets=list()) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
30 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
31 fcs <- read.FCS(input, transformation=F) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
32 original_channels <- colnames(fcs) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
33 original_markers <- as.vector(pData(parameters(fcs))$desc) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
34 nb <- length(original_channels) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
35 ## check if markers are in FCS files |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
36 check_markers <- sapply(marker_sets, checkCandM, channels=original_channels, |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
37 markers=original_markers) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
38 if (sum(check_markers)==0) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
39 quit(save = "no", status = 13, runLast = FALSE) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
40 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
41 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
42 post_channels <- colnames(fcs) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
43 post_markers <- as.vector(pData(parameters(fcs))$desc) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
44 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
45 for (m_set in marker_sets) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
46 if (m_set[[3]]){ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
47 chan_to_replace <- post_channels %in% m_set[[1]] |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
48 for (i in 1:nb){ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
49 if (chan_to_replace[[i]]){ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
50 post_channels[[i]] <- m_set[[2]][[match(post_channels[[i]], m_set[[1]])[1]]] |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
51 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
52 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
53 } else { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
54 marker_to_replace <- post_markers %in% m_set[[1]] |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
55 for (i in 1:nb){ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
56 if (marker_to_replace[[i]]){ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
57 post_markers[[i]] <- m_set[[2]][[match(post_markers[[i]], m_set[[1]])[1]]] |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
58 pm <- paste("$P", as.character(i), "S", sep="") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
59 fcs@description[[pm]] <- post_markers[[i]] |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
60 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
61 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
62 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
63 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
64 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
65 colnames(fcs) <- post_channels |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
66 pData(parameters(fcs))$desc <- post_markers |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
67 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
68 # write report |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
69 sink(report) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
70 cat("###########################\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
71 cat("## BEFORE RENAMING ##\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
72 cat("###########################\nFCS Channels\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
73 cat("---------------------------\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
74 cat(original_channels,"---------------------------", "FCS Markers","---------------------------",original_markers, sep="\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
75 cat("\n###########################\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
76 cat("## AFTER RENAMING ##\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
77 cat("###########################\nFCS Channels\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
78 cat("---------------------------\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
79 cat(post_channels,"---------------------------","FCS Markers","---------------------------", post_markers, sep="\n") |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
80 sink() |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
81 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
82 # output fcs |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
83 if (flag_fcs) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
84 write.FCS(fcs, output) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
85 } else { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
86 saveRDS(fcs, file = output) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
87 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
88 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
89 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
90 checkFCS <- function(fcsfile, out_file ="", report="", flag_fcs=FALSE, |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
91 marker_sets=list()) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
92 isValid <- F |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
93 tryCatch({ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
94 isValid <- isFCSfile(fcsfile) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
95 }, error = function(ex) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
96 print(paste(ex)) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
97 }) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
98 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
99 if (isValid) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
100 modifyMarkersFCS(fcsfile, out_file, report, flag_fcs, marker_sets) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
101 } else { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
102 quit(save = "no", status = 10, runLast = FALSE) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
103 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
104 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
105 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
106 ################################################################################ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
107 ################################################################################ |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
108 args <- commandArgs(trailingOnly = TRUE) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
109 flag_fcs <- if (args[3]=="FCS") TRUE else FALSE |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
110 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
111 items <- args[5:length(args)] |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
112 marker_sets <- list() |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
113 j <- 1 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
114 for (i in seq(1, length(items), 3)) { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
115 if (items[i]=="None" || items[i]== "" || items[i]== "i.e.:TLR 6, TLR6PE") { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
116 quit(save = "no", status = 11, runLast = FALSE) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
117 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
118 if (items[i+1]=="None" || items[i+1]=="" || items[i+1]=="i.e.:TLR6") { |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
119 quit(save = "no", status = 12, runLast = FALSE) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
120 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
121 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
122 old_names <- strsplit(items[i], ",")[[1]] |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
123 to_replace <- sapply(old_names, trimws) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
124 replacement <- sapply(strsplit(items[i+1], ",")[[1]], trimws) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
125 flag_channel <- if (items[i+2]=="C") TRUE else FALSE |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
126 m_set <- list(to_replace, replacement, flag_channel) |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
127 marker_sets[[j]] <- m_set |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
128 j <- j + 1 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
129 } |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
130 |
02b2412598b6
"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/edit_fcs_marker commit 05dd0e3c6e8eff9383d3f755ade2ca8557ebe7e7"
azomics
parents:
diff
changeset
|
131 checkFCS(args[1], args[2], args[4], flag_fcs, marker_sets) |