... | ... |
@@ -11,6 +11,8 @@ S3method(getTransformations,cytobankExperiment) |
11 | 11 |
S3method(getTransformations,graphGML) |
12 | 12 |
S3method(openWorkspace,character) |
13 | 13 |
S3method(print,cytobankExperiment) |
14 |
+export(CytoML.par.get) |
|
15 |
+export(CytoML.par.set) |
|
14 | 16 |
export(GatingSet2cytobank) |
15 | 17 |
export(GatingSet2flowJo) |
16 | 18 |
export(closeWorkspace) |
... | ... |
@@ -127,7 +127,7 @@ setMethod("closeWorkspace","flowJoWorkspace",function(workspace){ |
127 | 127 |
#' @return the macthed workspace type |
128 | 128 |
#' @noRd |
129 | 129 |
.getWorkspaceType <- function(wsversion){ |
130 |
- curSupport <- unlist(flowWorkspace.par.get("flowJo_versions")) |
|
130 |
+ curSupport <- unlist(CytoML.par.get("flowJo_versions")) |
|
131 | 131 |
ver_ind <- match(wsversion, curSupport) |
132 | 132 |
if(is.na(ver_ind)) |
133 | 133 |
stop("Unsupported version: ", wsversion) |
... | ... |
@@ -244,7 +244,7 @@ setMethod("parseWorkspace",signature("flowJoWorkspace"),function(obj, ...){ |
244 | 244 |
wsversion <- obj@version |
245 | 245 |
|
246 | 246 |
wsType <- .getWorkspaceType(wsversion) |
247 |
- wsNodePath <- flowWorkspace.par.get("nodePath")[[wsType]] |
|
247 |
+ wsNodePath <- CytoML.par.get("nodePath")[[wsType]] |
|
248 | 248 |
|
249 | 249 |
#sample info |
250 | 250 |
allSamples <- .getSamples(x, wsType, sampNloc = sampNloc) |
... | ... |
@@ -692,7 +692,7 @@ getFileNames <- function(ws){ |
692 | 692 |
} |
693 | 693 |
} |
694 | 694 |
.getFileNames <- function(x, wsType){ |
695 |
- wsNodePath <- flowWorkspace.par.get("nodePath")[[wsType]] |
|
695 |
+ wsNodePath <- CytoML.par.get("nodePath")[[wsType]] |
|
696 | 696 |
unlist(xpathApply(x, file.path(wsNodePath[["sample"]], "Keywords/Keyword[@name='$FIL']") |
697 | 697 |
, function(x)xmlGetAttr(x,"value") |
698 | 698 |
) |
... | ... |
@@ -736,7 +736,7 @@ setMethod("getKeywords",c("flowJoWorkspace","character"),function(obj,y, ...){ |
736 | 736 |
x <- obj@doc |
737 | 737 |
wsversion <- obj@version |
738 | 738 |
wsType <- .getWorkspaceType(wsversion) |
739 |
- wsNodePath <- flowWorkspace.par.get("nodePath")[[wsType]] |
|
739 |
+ wsNodePath <- CytoML.par.get("nodePath")[[wsType]] |
|
740 | 740 |
.getKeywordsBySampleName(obj@doc,y, wsNodePath[["sample"]], ...) |
741 | 741 |
}) |
742 | 742 |
#' @rdname getKeywords |
... | ... |
@@ -747,7 +747,7 @@ setMethod("getKeywords",c("flowJoWorkspace","numeric"),function(obj,y, ...){ |
747 | 747 |
x <- obj@doc |
748 | 748 |
wsversion <- obj@version |
749 | 749 |
wsType <- .getWorkspaceType(wsversion) |
750 |
- wsNodePath <- flowWorkspace.par.get("nodePath")[[wsType]] |
|
750 |
+ wsNodePath <- CytoML.par.get("nodePath")[[wsType]] |
|
751 | 751 |
.getKeywordsBySampleID(obj@doc,y, wsNodePath[["sampleID"]],...) |
752 | 752 |
}) |
753 | 753 |
|
... | ... |
@@ -840,7 +840,7 @@ getFJWSubsetIndices<-function(ws,key=NULL,value=NULL,group,requiregates=TRUE){ |
840 | 840 |
x <- ws@doc |
841 | 841 |
wsversion <- ws@version |
842 | 842 |
wsType <- .getWorkspaceType(wsversion) |
843 |
- wsNodePath <- flowWorkspace.par.get("nodePath")[[wsType]] |
|
843 |
+ wsNodePath <- CytoML.par.get("nodePath")[[wsType]] |
|
844 | 844 |
|
845 | 845 |
s<- .getSamples(x, wsType); |
846 | 846 |
#TODO Use the actual value of key to name the column |
... | ... |
@@ -929,7 +929,7 @@ setMethod("getSampleGroups","flowJoWorkspace",function(x){ |
929 | 929 |
#' @importFrom stats na.omit |
930 | 930 |
.getSampleGroups<-function(x, wsType){ |
931 | 931 |
|
932 |
- wsNodePath <- flowWorkspace.par.get("nodePath")[[wsType]] |
|
932 |
+ wsNodePath <- CytoML.par.get("nodePath")[[wsType]] |
|
933 | 933 |
|
934 | 934 |
if(grepl("mac", wsType)){ |
935 | 935 |
do.call(rbind,xpathApply(x, wsNodePath[["group"]],function(x){ |
... | ... |
@@ -980,7 +980,7 @@ setMethod("getSampleGroups","flowJoWorkspace",function(x){ |
980 | 980 |
|
981 | 981 |
.getSamples<-function(x, wsType, sampNloc="keyword"){ |
982 | 982 |
|
983 |
- wsNodePath <- flowWorkspace.par.get("nodePath")[[wsType]] |
|
983 |
+ wsNodePath <- CytoML.par.get("nodePath")[[wsType]] |
|
984 | 984 |
lastwarn<-options("warn")[[1]] |
985 | 985 |
options("warn"=-1) |
986 | 986 |
top <- xmlRoot(x) |
... | ... |
@@ -12,10 +12,12 @@ NULL |
12 | 12 |
#' @importFrom graph nodeData |
13 | 13 |
#' @export |
14 | 14 |
#' @examples |
15 |
+#' \dontrun{ |
|
15 | 16 |
#' xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
16 | 17 |
#' g <- read.gatingML.cytobank(xmlfile) |
17 | 18 |
#' getNodes(g) |
18 | 19 |
#' getNodes(g, only.names = FALSE) |
20 |
+#' } |
|
19 | 21 |
setMethod("getNodes", signature = c("graphGML"), |
20 | 22 |
definition = function(x, y |
21 | 23 |
, order = c("default", "bfs", "dfs", "tsort") |
... | ... |
@@ -68,10 +70,12 @@ setMethod("getNodes", signature = c("graphGML"), |
68 | 70 |
#' @export |
69 | 71 |
#' @return a graphNEL node |
70 | 72 |
#' @examples |
73 |
+#' \dontrun{ |
|
71 | 74 |
#' xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
72 | 75 |
#' g <- read.gatingML.cytobank(xmlfile) |
73 | 76 |
#' getChildren(g, "GateSet_722326") |
74 | 77 |
#' getParent(g, "GateSet_722326") |
78 |
+#' } |
|
75 | 79 |
#' @importClassesFrom methods character ANY data.frame environment list logical matrix missing numeric oldClass |
76 | 80 |
#' @importFrom flowWorkspace getChildren |
77 | 81 |
setMethod("getChildren", signature = c("graphGML", "character"), |
... | ... |
@@ -136,10 +140,11 @@ setMethod("show", signature = c("graphGML"), |
136 | 140 |
#' @importFrom graph nodeData nodes<- nodeRenderInfo<- |
137 | 141 |
#' @importFrom Rgraphviz renderGraph layoutGraph |
138 | 142 |
#' @examples |
143 |
+#' \dontrun{ |
|
139 | 144 |
#' xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
140 | 145 |
#' g <- read.gatingML.cytobank(xmlfile) |
141 | 146 |
#' plot(g) |
142 |
-#' |
|
147 |
+#'} |
|
143 | 148 |
setMethod("plot", signature = c(x = "graphGML", y = "missing"), definition = function(x, y = "missing", label = c("popName", "gateName")){ |
144 | 149 |
label <- match.arg(label, c("popName", "gateName")) |
145 | 150 |
if(label == "popName") |
... | ... |
@@ -286,6 +291,7 @@ getCompensationMatrices.graphGML <- function(x){ |
286 | 291 |
|
287 | 292 |
#' Extract transformations from graphGML object. |
288 | 293 |
#' @param x graphGML |
294 |
+#' @param ... not used |
|
289 | 295 |
#' @return transformerList object |
290 | 296 |
#' @importFrom flowCore eval parameters colnames |
291 | 297 |
#' @importFrom flowWorkspace transformerList asinh_Gml2 flow_trans asinhtGml2_trans logicleGml2_trans logtGml2_trans |
... | ... |
@@ -25,9 +25,11 @@ setClass("graphGML", contains = "graphNEL") |
25 | 25 |
#' The gate and population name are stored in nodeData of each node. |
26 | 26 |
#' Compensation and transformations are stored in graphData. |
27 | 27 |
#' @examples |
28 |
+#' \dontrun{ |
|
28 | 29 |
#' xml <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
29 | 30 |
#' g <- read.gatingML.cytobank(xml) #parse the population tree |
30 | 31 |
#' #plot(g) #visualize it |
32 |
+#' } |
|
31 | 33 |
read.gatingML.cytobank <- function(file, ...){ |
32 | 34 |
|
33 | 35 |
#parse all the elements:gate, GateSets, comp, trans |
34 | 36 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,107 @@ |
1 |
+## Store state info in this internal global environment |
|
2 |
+CytoML.state <- new.env(hash = FALSE) |
|
3 |
+CytoML.state[["par"]] <- list() |
|
4 |
+ |
|
5 |
+#' workspace version is parsed from xml node '/Workspace/version' in flowJo workspace |
|
6 |
+#' and matched with this list to dispatch to the one of the three workspace parsers |
|
7 |
+CytoML.par.init <- function(){ |
|
8 |
+ |
|
9 |
+ fj_ver <- list(win = c("1.61", "1.6") |
|
10 |
+ , macII = c("2.0") |
|
11 |
+ , macIII = c("3.0") |
|
12 |
+ , vX = c("1.8", "20.0") |
|
13 |
+ ) |
|
14 |
+ |
|
15 |
+ mac_II_path <- list(group = "/Workspace/Groups/GroupNode"# abs path |
|
16 |
+ , sampleRef = ".//SampleRefs/SampleRef"#relative GroupNode |
|
17 |
+ , sample = "/Workspace/SampleList/Sample"#abs path |
|
18 |
+ , sampleNode = "./SampleNode"#relative to sample |
|
19 |
+ , popNode = "./Population"#relative to sampleNode |
|
20 |
+ , attrName = "name" |
|
21 |
+ , compMatName = "name" |
|
22 |
+ , compMatChName = "name" |
|
23 |
+ , compMatVal = "value" |
|
24 |
+ ) |
|
25 |
+ mac_II_path[["sampleID"]] <- mac_II_path[["sample"]] |
|
26 |
+ |
|
27 |
+ #mac version 3.0 (flowJo version 9.7.2-9.7.4) |
|
28 |
+ mac_III_path <- mac_II_path |
|
29 |
+ mac_III_path[["sample"]] <- sub("SampleList", "Samples", mac_III_path[["sample"]]) |
|
30 |
+ mac_III_path[["attrName"]] <- "nodeName" |
|
31 |
+ mac_III_path[["compMatName"]] <- "matrixName" |
|
32 |
+ mac_III_path[["compMatChName"]] <- "fluorName" |
|
33 |
+ mac_III_path[["compMatVal"]] <- "spillValue" |
|
34 |
+ mac_III_path[["sampleID"]] <- mac_III_path[["sample"]] |
|
35 |
+ ####windows version |
|
36 |
+ #inherit most paths from mac |
|
37 |
+ win_path <- mac_II_path |
|
38 |
+ win_path[["popNode"]] <- "./*/Population" |
|
39 |
+ win_path[["gateDim"]] <- "*[local-name()='dimension']"#relative to gateNode |
|
40 |
+ win_path[["gateParam"]] <- "*[local-name()='parameter']"#relative to dimNode |
|
41 |
+ win_path[["sampleID"]] <- file.path(win_path[["sample"]],"DataSet") |
|
42 |
+ |
|
43 |
+ ####version X |
|
44 |
+ #inherit most paths from win |
|
45 |
+ vX_path <- win_path |
|
46 |
+ vX_path[["gateParam"]] <- "*[local-name()='fcs-dimension']"; |
|
47 |
+ |
|
48 |
+ CytoML.state[["par"]] <- list(flowJo_versions = fj_ver |
|
49 |
+ , nodePath = list(win = win_path |
|
50 |
+ , macII = mac_II_path |
|
51 |
+ , macIII = mac_III_path |
|
52 |
+ , vX = vX_path |
|
53 |
+ ) |
|
54 |
+ ) |
|
55 |
+ |
|
56 |
+} |
|
57 |
+ |
|
58 |
+## call the init function |
|
59 |
+CytoML.par.init() |
|
60 |
+ |
|
61 |
+#' CytoML.par.set sets a set of parameters in the CytoML package namespace. |
|
62 |
+#' |
|
63 |
+#' @param value A named list of values to set for category name or a list of such lists if name is missing. |
|
64 |
+#' @rdname CytoML.par.get |
|
65 |
+#' @export |
|
66 |
+CytoML.par.set <- function (name, value) |
|
67 |
+{ |
|
68 |
+ old <- CytoML.state[["par"]] |
|
69 |
+ if(name%in%names(old)){ |
|
70 |
+ CytoML.state[["par"]][[name]] <- lattice:::updateList(old[[name]], value) |
|
71 |
+ }else |
|
72 |
+ stop(name, " is not a valid CytoML parameters!") |
|
73 |
+ |
|
74 |
+ invisible() |
|
75 |
+} |
|
76 |
+ |
|
77 |
+#' Query and set session-wide parameter defaults. |
|
78 |
+#' |
|
79 |
+#' CytoML.par.get gets a set of parameters in the CytoML package namespace. |
|
80 |
+#' |
|
81 |
+#' It is currently used to add/remove the support for a specific flowJo versions (parsed from xml node '/Workspace/version' in flowJo workspace) |
|
82 |
+#' |
|
83 |
+#' @param name The name of a parameter category to get or set. |
|
84 |
+#' |
|
85 |
+#' |
|
86 |
+#' @examples |
|
87 |
+#' #get the flowJo versions currently supported |
|
88 |
+#' old <- CytoML.par.get("flowJo_versions") |
|
89 |
+#' |
|
90 |
+#' #add the new version |
|
91 |
+#' old[["win"]] <- c(old[["win"]], "1.7") |
|
92 |
+#' CytoML.par.set("flowJo_versions", old) |
|
93 |
+#' |
|
94 |
+#' CytoML.par.get("flowJo_versions") |
|
95 |
+#' |
|
96 |
+#' @export |
|
97 |
+#' @rdname CytoML.par.get |
|
98 |
+CytoML.par.get <- function (name = NULL) |
|
99 |
+{ |
|
100 |
+ lPars <- CytoML.state[["par"]] |
|
101 |
+ if (is.null(name)) |
|
102 |
+ lPars |
|
103 |
+ else if (name %in% names(lPars)) |
|
104 |
+ lPars[[name]] |
|
105 |
+ else NULL |
|
106 |
+} |
|
107 |
+ |
0 | 108 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,33 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/zzz.R |
|
3 |
+\name{CytoML.par.set} |
|
4 |
+\alias{CytoML.par.set} |
|
5 |
+\alias{CytoML.par.get} |
|
6 |
+\title{CytoML.par.set sets a set of parameters in the CytoML package namespace.} |
|
7 |
+\usage{ |
|
8 |
+CytoML.par.set(name, value) |
|
9 |
+ |
|
10 |
+CytoML.par.get(name = NULL) |
|
11 |
+} |
|
12 |
+\arguments{ |
|
13 |
+\item{name}{The name of a parameter category to get or set.} |
|
14 |
+ |
|
15 |
+\item{value}{A named list of values to set for category name or a list of such lists if name is missing.} |
|
16 |
+} |
|
17 |
+\description{ |
|
18 |
+CytoML.par.get gets a set of parameters in the CytoML package namespace. |
|
19 |
+} |
|
20 |
+\details{ |
|
21 |
+It is currently used to add/remove the support for a specific flowJo versions (parsed from xml node '/Workspace/version' in flowJo workspace) |
|
22 |
+} |
|
23 |
+\examples{ |
|
24 |
+ #get the flowJo versions currently supported |
|
25 |
+ old <- CytoML.par.get("flowJo_versions") |
|
26 |
+ |
|
27 |
+ #add the new version |
|
28 |
+ old[["win"]] <- c(old[["win"]], "1.7") |
|
29 |
+ CytoML.par.set("flowJo_versions", old) |
|
30 |
+ |
|
31 |
+ CytoML.par.get("flowJo_versions") |
|
32 |
+ |
|
33 |
+} |
0 | 34 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,13 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/zzz.R |
|
3 |
+\name{CytoML.par.init} |
|
4 |
+\alias{CytoML.par.init} |
|
5 |
+\title{workspace version is parsed from xml node '/Workspace/version' in flowJo workspace |
|
6 |
+and matched with this list to dispatch to the one of the three workspace parsers} |
|
7 |
+\usage{ |
|
8 |
+CytoML.par.init() |
|
9 |
+} |
|
10 |
+\description{ |
|
11 |
+workspace version is parsed from xml node '/Workspace/version' in flowJo workspace |
|
12 |
+and matched with this list to dispatch to the one of the three workspace parsers |
|
13 |
+} |
... | ... |
@@ -19,8 +19,10 @@ a graphNEL node |
19 | 19 |
get children nodes |
20 | 20 |
} |
21 | 21 |
\examples{ |
22 |
+\dontrun{ |
|
22 | 23 |
xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
23 | 24 |
g <- read.gatingML.cytobank(xmlfile) |
24 | 25 |
getChildren(g, "GateSet_722326") |
25 | 26 |
getParent(g, "GateSet_722326") |
26 | 27 |
} |
28 |
+} |
... | ... |
@@ -24,8 +24,10 @@ It returns the node names and population names by default. Or return the entire |
24 | 24 |
get nodes from {graphGML} object |
25 | 25 |
} |
26 | 26 |
\examples{ |
27 |
+\dontrun{ |
|
27 | 28 |
xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
28 | 29 |
g <- read.gatingML.cytobank(xmlfile) |
29 | 30 |
getNodes(g) |
30 | 31 |
getNodes(g, only.names = FALSE) |
31 | 32 |
} |
33 |
+} |
... | ... |
@@ -22,8 +22,9 @@ nothing |
22 | 22 |
The node with dotted order represents the population that has tailored gates (sample-specific gates) defined. |
23 | 23 |
} |
24 | 24 |
\examples{ |
25 |
+\dontrun{ |
|
25 | 26 |
xmlfile <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
26 | 27 |
g <- read.gatingML.cytobank(xmlfile) |
27 | 28 |
plot(g) |
28 |
- |
|
29 |
+} |
|
29 | 30 |
} |
... | ... |
@@ -21,7 +21,9 @@ The Default parser (flowUtils::read.gatingML) does not parse the population tre |
21 | 21 |
the custom information from cytobank. (e.g. gate name, fcs filename). |
22 | 22 |
} |
23 | 23 |
\examples{ |
24 |
+\dontrun{ |
|
24 | 25 |
xml <- system.file("extdata/cytotrol_tcell_cytobank.xml", package = "CytoML") |
25 | 26 |
g <- read.gatingML.cytobank(xml) #parse the population tree |
26 | 27 |
#plot(g) #visualize it |
27 | 28 |
} |
29 |
+} |