annotate FlowSOMMApIndividualFCS.R @ 0:e796ed5dfd02 draft

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
author azomics
date Tue, 23 Jun 2020 19:49:33 -0400
parents
children a1054bd1060a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
1 #!/usr/bin/Rscript
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
2 # Module for Galaxy
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
3 # Generates FlowSOM reference tree
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
4 # with FlowSOM AggregateFlowFrames
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
5 ######################################################################
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
6 # Copyright (c) 2017 Northrop Grumman.
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
7 # All rights reserved.
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
8 ######################################################################
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
9 #
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
10 # Version 1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
11 # Cristel Thomas
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
12 #
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
13 #
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
14 library(FlowSOM)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
15 library(flowCore)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
16
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
17 ## geometric mean from
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
18 # https://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
19 gm_mean = function(x, na.rm=TRUE){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
20 exp(sum(log(x[x > 0]), na.rm=na.rm) / length(x))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
21 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
22
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
23 prettyMarkerNames <- function(flowFrame){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
24 n <- flowFrame@parameters@data[, "name"]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
25 d <- flowFrame@parameters@data[, "desc"]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
26 d[is.na(d)] <- n[is.na(d)]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
27 prettyNames <-list()
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
28 if(any(grepl("#",d))){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
29 # Support for hashtag notation:
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
30 # antibody#fluorochrome -> antibody (fluorochrome)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
31 prettyNames <- gsub("#(.*)$"," (\\1)",d)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
32 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
33 prettyNames <- paste(d, " <", n, ">", sep="")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
34 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
35 return(prettyNames)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
36 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
37
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
38 checkMarkers <- function(fcsfiles, flag_ff=FALSE){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
39 markerCheck <- T
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
40 for (i in 1:length(fcsfiles)){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
41 if (flag_ff){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
42 fcs <- readRDS(fcsfiles[i])
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
43 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
44 fcs <- read.FCS(fcsfiles[i], transformation=FALSE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
45 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
46 if (i == 1) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
47 m1 <- as.vector(pData(parameters(fcs))$desc)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
48 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
49 m2 <- as.vector(pData(parameters(fcs))$desc)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
50 if (is.na(all(m1==m2))) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
51 mm1 <- is.na(m1)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
52 mm2 <- is.na(m2)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
53 if (all(mm1==mm2)){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
54 if (!all(m1==m2, na.rm=TRUE)){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
55 markerCheck <- F
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
56 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
57 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
58 markerCheck <- F
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
59 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
60 } else if (!all(m1==m2)) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
61 markerCheck <- F
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
62 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
63 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
64 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
65 if (!markerCheck) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
66 quit(save = "no", status = 13, runLast = FALSE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
67 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
68 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
69
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
70 mapToTree <- function(filenames, filepaths, flag_ff=FALSE, reftree, cluster=10,
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
71 outdir="",flag_meta=FALSE, mfi='mfi', stat1="", stat2="",
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
72 stat3="", plot="", mplot="") {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
73
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
74 checkMarkers(filepaths, flag_ff)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
75
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
76 # get tree
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
77 fst <- readRDS(reftree)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
78 plots <- FALSE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
79 mplots <- FALSE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
80 dir.create(outdir)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
81 if (!plot==""){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
82 dir.create(plot)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
83 plots <- TRUE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
84 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
85 if (!mplot==""){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
86 dir.create(mplot)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
87 mplots <- TRUE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
88 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
89 metaC <- metaClustering_consensus(fst$map$codes, k=cluster, seed=33)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
90 nb_pop <- if (flag_meta) cluster else max(fst$map$mapping[,1])
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
91 nb_samples <- length(filepaths)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
92 nb_marker <- length(fst$prettyColnames)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
93 print_markers <- gsub(' <.*>','',fst$prettyColnames)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
94 print_markers_ff <- append(print_markers, "Population")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
95
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
96 m_stat1 <- matrix(0, nrow=nb_samples, ncol=(nb_pop+2))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
97 colnames(m_stat1) <- c("FileID", "SampleName", seq_len(nb_pop))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
98
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
99 sink(stat2)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
100 cat(print_markers, sep="\t")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
101 cat("\tPercentage\tPopulation\tSampleName\n")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
102 sink()
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
103
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
104 col_m3 <- c("Population")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
105 for (m in print_markers){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
106 m1 <- paste(m, "mean", sep="_")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
107 m2 <- paste(m, "median", sep="_")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
108 m3 <- paste(m, "stdev", sep="_")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
109 col_m3 <- append(col_m3, c(m1,m2,m3))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
110 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
111 col_stat3 <- c(col_m3, "Percentage_mean","Percentage_median","Percentage_stdev")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
112
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
113 for (i in 1:length(filepaths)){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
114 if (flag_ff){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
115 ff <- readRDS(filepaths[i])
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
116 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
117 ff <- read.FCS(filepaths[i], transformation=FALSE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
118 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
119 if (i==1) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
120 # compare to tree markers
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
121 pm <- prettyMarkerNames(ff)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
122 if (!all(fst$prettyColnames %in% pm)){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
123 quit(save = "no", status = 14, runLast = FALSE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
124 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
125 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
126
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
127 fsom <- NewData(fst, ff)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
128
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
129 if (mplots){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
130 markers <- colnames(ff)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
131 tmpmplot <- paste(filenames[i], "marker_plots.pdf", sep="_")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
132 pdf(file.path(mplot,tmpmplot), useDingbats=FALSE, onefile=TRUE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
133 for (marker in markers){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
134 PlotMarker(fsom, marker)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
135 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
136 dev.off()
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
137 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
138
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
139 if (!plot==""){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
140 plotpath <- paste(filenames[i], "tree.png", sep="_")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
141 png(file.path(plot, plotpath), type="cairo", height=800, width=800)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
142 PlotStars(fsom, backgroundValues = as.factor(metaC))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
143 dev.off()
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
144 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
145
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
146 m <- matrix(0,nrow=nrow(ff),ncol=1)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
147 s <- seq_len(nrow(ff))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
148 if (flag_meta){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
149 m[s,] <- metaC[fsom$map$mapping[,1]]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
150 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
151 m[s,] <- fsom$map$mapping[,1]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
152 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
153 colnames(m) <- "FlowSOM"
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
154 ff <- cbind2(ff,m)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
155 out <- exprs(ff)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
156 colnames(out) <- print_markers_ff
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
157
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
158 clr_table <- paste(filenames[i], "clustered.flowclr", sep="_")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
159 write.table(out, file=file.path(outdir, clr_table), quote=F, row.names=F, col.names=T, sep='\t',
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
160 append=F)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
161
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
162 cluster_count <- table(out[,"Population"])
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
163 cluster_prop <- prop.table(cluster_count)*100
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
164 m1_tmp <- numeric(nb_pop)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
165 for (j in 1:nb_pop){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
166 if (as.character(j) %in% names(cluster_count)){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
167 m1_tmp[[j]] <- format(round(cluster_prop[[as.character(j)]], 2), nsmall=2)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
168 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
169 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
170 samplename <- paste("Sample", i, sep="")
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
171 m_stat1[i,] <- c(filenames[i], samplename, m1_tmp)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
172 # flowstat2
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
173 # Marker1 Marker2 Marker3 ... Population Percentage SampleName
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
174 # MFIs for each marker
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
175 # dimension ==> col = nb of markers + 3; row = nb of files * nb of clusters
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
176 if (mfi=="mfi"){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
177 m2 <- aggregate(out[,1:nb_marker], list(out[,nb_marker+1]), mean)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
178 } else if (mfi=="mdfi") {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
179 m2 <- aggregate(out[,1:nb_marker], list(out[,nb_marker+1]), median)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
180 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
181 m2 <- aggregate(out[,1:nb_marker], list(out[,nb_marker+1]), gm_mean)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
182 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
183
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
184 m2["Percentage"] <- as.character(cluster_prop)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
185 m2["Population"] <- as.character(m2$Group.1)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
186 m2["SampleName"] <- samplename
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
187 m2t <- as.matrix(m2[2:length(m2)])
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
188 write.table(m2t, file=stat2, quote=F, row.names=F, col.names=F, sep='\t',
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
189 append=T)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
190
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
191 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
192 write.table(m_stat1, file=stat1, quote=F, row.names=F, col.names=T, sep='\t',
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
193 append=F)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
194
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
195 m2df <- read.table(stat2, sep="\t", header=T)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
196 ag <- aggregate(m2df[,0:nb_marker+1], list(m2df[,nb_marker+2]), function(x) c(mn=mean(x), med=median(x), stdv=sd(x)))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
197 m3t <- as.matrix(ag)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
198 colnames(m3t) <- col_stat3
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
199 write.table(m3t, file=stat3, quote=F, row.names=F, col.names=T, sep='\t',
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
200 append=F)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
201 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
202
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
203 flowFrameOrFCS <- function(filenames, filepaths, reftree, cluster=10, outdir="",
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
204 flag_meta=FALSE, mfi='mfi', stat1="", stat2="",
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
205 stat3="", plot="", mplot=""){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
206
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
207 isValid <- F
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
208 is_fcs <- F
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
209 is_ff <- F
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
210 flag_ff <- FALSE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
211 i <- 0
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
212 for (f in filepaths){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
213 tryCatch({
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
214 is_fcs <- isFCSfile(f)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
215 }, error = function(ex) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
216 print(paste(ex))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
217 })
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
218 if (!is_fcs){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
219 tryCatch({
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
220 ff <- readRDS(f)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
221 is_ff <- T
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
222 }, error = function(ex) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
223 print(paste(ex))
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
224 })
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
225 } else {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
226 i <- i + 1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
227 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
228 if (!is_ff && !is_fcs) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
229 quit(save = "no", status = 10, runLast = FALSE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
230 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
231 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
232 if (i==0) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
233 flag_ff <- TRUE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
234 } else if (!i==length(filenames)){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
235 quit(save = "no", status = 12, runLast = FALSE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
236 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
237 mapToTree(filenames, filepaths, flag_ff, reftree, cluster, outdir, flag_meta,
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
238 mfi, stat1, stat2, stat3, plot, mplot)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
239 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
240
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
241 args <- commandArgs(trailingOnly = TRUE)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
242 plot <- ""
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
243 mplot <- ""
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
244 m <- 8
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
245 flag_meta <- FALSE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
246 if (args[4]=='meta') {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
247 flag_meta <- TRUE
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
248 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
249 if (args[9] == 'newDataTrees') {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
250 plot <- 'newDataTrees'
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
251 m <- m + 1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
252 if (args[10] == 'newDataMarkers') {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
253 mplot <- "newDataMarkers"
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
254 m <- m + 1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
255 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
256 } else if (args[9] == 'newDataMarkers') {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
257 mplot <- "newDataMarkers"
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
258 m <- m + 1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
259 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
260
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
261 n <- m+1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
262 # files + filenames
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
263 nb_files <- (length(args) - m) / 2
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
264 files1 <- character(nb_files)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
265 files2 <- character(nb_files)
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
266 j <- 1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
267 file_list <- args[n:length(args)]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
268 for (i in 1:length(file_list)) {
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
269 if (i%%2){
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
270 files1[[j]] <- file_list[i]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
271 files2[[j]] <- file_list[i+1]
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
272 j <- j + 1
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
273 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
274 }
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
275
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
276 flowFrameOrFCS(files2, files1, args[1], as.numeric(args[3]), args[2], flag_meta,
e796ed5dfd02 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/flowsom_cross_comp commit 2f04d23cb47d9b233d159c54ff406e56c87746e0"
azomics
parents:
diff changeset
277 args[5], args[6], args[7], args[8], plot, mplot)