annotate FCSstats.R @ 1:d2749aa59d20 draft default tip

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
author azomics
date Mon, 22 Jun 2020 17:33:38 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
1 #!/usr/bin/Rscript --vanilla
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
2 # FCS Summary Statistic Module for Galaxy
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
3 # FlowCore
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
4 ######################################################################
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
5 # Copyright (c) 2016 Northrop Grumman.
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
6 # All rights reserved.
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
7 ######################################################################
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
8 #
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
9 # Version 1
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
10 # Cristel Thomas
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
11 #
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
12 #
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
13
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
14 library(flowCore)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
15
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
16 getMarkerNames <- function(input, output) {
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
17 fcs <- read.FCS(input, transformation=F)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
18
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
19 ## marker names
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
20 channels <- colnames(fcs)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
21 markers <- as.vector(pData(parameters(fcs))$desc)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
22 df <- data.frame(channels, markers)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
23 fcs_summary <- capture.output(summary(fcs))
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
24 fcs_dim <- capture.output(dim(fcs))
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
25 fcs_markers <- capture.output(df)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
26
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
27
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
28 sink(output)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
29 cat(fcs_dim, sep="\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
30 cat("\n\n=========================\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
31 cat("== FCS SUMMARY ==\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
32 cat("=========================\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
33 cat(fcs_summary, sep="\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
34 cat("\n\n=========================\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
35 cat("== MARKERS IN FCS ==\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
36 cat("=========================\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
37 cat(fcs_markers, sep="\n")
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
38 sink()
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
39 }
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
40
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
41 checkFCS <- function(input_file, output_file) {
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
42 isValid <- F
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
43 # Check file beginning matches FCS standard
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
44 tryCatch({
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
45 isValid <- isFCSfile(input_file)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
46 }, error = function(ex) {
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
47 print (paste(" ! Error in isFCSfile", ex))
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
48 })
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
49
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
50 if (isValid) {
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
51 getMarkerNames(input_file, output_file)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
52 } else {
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
53 print (paste(input_file, "does not meet FCS standard"))
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
54 }
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
55 }
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
56
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
57 args <- commandArgs(trailingOnly = TRUE)
d2749aa59d20 "planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/fcs_summary commit 72efaa6d006ddda6c8eed10ec9ba541cbdecf3a8"
azomics
parents:
diff changeset
58 checkFCS(args[1], args[2])