... | ... |
@@ -59,7 +59,7 @@ Collate: |
59 | 59 |
'utils.R' |
60 | 60 |
'zzz.R' |
61 | 61 |
Depends: |
62 |
- R (>= 2.16.0),flowCore(>= 1.45.2),ncdfFlow(>= 2.19.5) |
|
62 |
+ R (>= 2.16.0),flowCore(>= 1.45.14),ncdfFlow(>= 2.25.4) |
|
63 | 63 |
biocViews: FlowCytometry, DataImport, Preprocessing, DataRepresentation |
64 | 64 |
Suggests: |
65 | 65 |
testthat, |
... | ... |
@@ -304,8 +304,15 @@ load_gs<-function(path){ |
304 | 304 |
} |
305 | 305 |
|
306 | 306 |
} |
307 |
- |
|
308 |
- |
|
307 |
+ trans <- gs@transformation |
|
308 |
+ if(length(trans)!=0) |
|
309 |
+ { |
|
310 |
+ if(is(trans , "transformerList")){ |
|
311 |
+ gs@transformation <- sapply(sampleNames(gs), function(sn)trans, simplify = FALSE) |
|
312 |
+ } |
|
313 |
+ |
|
314 |
+ } |
|
315 |
+ |
|
309 | 316 |
message("Done") |
310 | 317 |
list(gs=gs,files=c(dat.file,rds.file)) |
311 | 318 |
} |
... | ... |
@@ -1935,6 +1942,7 @@ setMethod("[",c("GatingSet"),function(x,i,j,...,drop){ |
1935 | 1942 |
#copy the R structure |
1936 | 1943 |
clone <- x |
1937 | 1944 |
clone@axis <- clone@axis[i] |
1945 |
+ clone@transformation <- clone@transformation[i] |
|
1938 | 1946 |
#subsetting data |
1939 | 1947 |
fs <- flowData(clone)[i] |
1940 | 1948 |
|
... | ... |
@@ -2045,7 +2053,7 @@ setMethod("[[",c(x="GatingSet",i="character"),function(x,i,j,...){ |
2045 | 2053 |
, flag = x@flag |
2046 | 2054 |
, axis = x@axis |
2047 | 2055 |
, guid = x@guid |
2048 |
- , transformation = x@transformation |
|
2056 |
+ , transformation = x@transformation[[i]] |
|
2049 | 2057 |
, compensation = x@compensation |
2050 | 2058 |
, name = i) |
2051 | 2059 |
|
... | ... |
@@ -2251,7 +2259,7 @@ setMethod("keyword",c("GatingSet","character"),function(object,keyword){ |
2251 | 2259 |
#' is supported. |
2252 | 2260 |
#' |
2253 | 2261 |
#' @param _data \code{GatingSet} or \code{GatingSetList} |
2254 |
-#' @param translist expect a \code{transformList} object |
|
2262 |
+#' @param translist expect a \code{transformList} object or a list of \code{transformList} objects(with names matched to sample names) |
|
2255 | 2263 |
#' @param ... other arguments passed to 'transform' method for 'ncdfFlowSet'.(e.g. 'ncdfFile') |
2256 | 2264 |
#' @return a \code{GatingSet} or \code{GatingSetList} object with the underling flow data transformed. |
2257 | 2265 |
#' @examples |
... | ... |
@@ -2279,13 +2287,29 @@ setMethod("transform", |
2279 | 2287 |
{ |
2280 | 2288 |
|
2281 | 2289 |
gs <- `_data` |
2282 |
- if(missing(translist)||!is(translist, "transformerList")) |
|
2283 |
- stop("expect the second argument as a 'transformerList' object!") |
|
2290 |
+ |
|
2291 |
+ if(missing(translist)) |
|
2292 |
+ stop("Missing the second argument 'translist'!") |
|
2293 |
+ else if(is(translist, "transformerList")) |
|
2294 |
+ { |
|
2295 |
+ translist <- sapply(sampleNames(gs), function(obj)translist, simplify = FALSE) |
|
2296 |
+ } |
|
2297 |
+ |
|
2298 |
+ if(is(translist, "list")) |
|
2299 |
+ { |
|
2300 |
+ tList <- lapply(translist, function(trans){ |
|
2301 |
+ if(!is(trans, "transformerList")) |
|
2302 |
+ stop("All the elements of 'translist' must be 'transformerList' objects!") |
|
2303 |
+ |
|
2304 |
+ res <- lapply(trans, function(obj)obj[["transform"]]) |
|
2305 |
+ transformList(names(trans), res) |
|
2306 |
+ }) |
|
2307 |
+ }else |
|
2308 |
+ stop("expect the second argument as a 'transformerList' object or a list of 'transformerList' objects!") |
|
2284 | 2309 |
gs@transformation <- translist |
2285 | 2310 |
|
2286 | 2311 |
fs <- getData(gs) |
2287 |
- tList <- lapply(translist, function(obj)obj[["transform"]]) |
|
2288 |
- tList <- transformList(names(translist), tList) |
|
2312 |
+ |
|
2289 | 2313 |
suppressMessages(fs_trans <- transform(fs, tList, ...)) |
2290 | 2314 |
flowData(gs) <- fs_trans |
2291 | 2315 |
gs |
... | ... |
@@ -13,7 +13,7 @@ |
13 | 13 |
\arguments{ |
14 | 14 |
\item{_data}{\code{GatingSet} or \code{GatingSetList}} |
15 | 15 |
|
16 |
-\item{translist}{expect a \code{transformList} object} |
|
16 |
+\item{translist}{expect a \code{transformList} object or a list of \code{transformList} objects(with names matched to sample names)} |
|
17 | 17 |
|
18 | 18 |
\item{...}{other arguments passed to 'transform' method for 'ncdfFlowSet'.(e.g. 'ncdfFile')} |
19 | 19 |
} |
... | ... |
@@ -64,11 +64,13 @@ test_that("compensate & transform a GatingSet", { |
64 | 64 |
|
65 | 65 |
transObj <- estimateLogicle(gs[[1]], c("FL1-H", "FL2-H")) |
66 | 66 |
|
67 |
- expect_error(gs.trans <- transform(gs), regexp = "transformerList") |
|
67 |
+ expect_error(gs.trans <- transform(gs), "Missing the second argument") |
|
68 | 68 |
expect_error(gs.trans <- transform(gs, translist), regexp = "transformerList") |
69 | 69 |
|
70 | 70 |
suppressMessages(gs.trans <- transform(gs, transObj)) |
71 |
- expect_equal(gs.trans@transformation, transObj) |
|
71 |
+ transObj.list <- sapply(sampleNames(gs), function(obj)transObj, simplify = FALSE) |
|
72 |
+ |
|
73 |
+ expect_equal(gs.trans@transformation, transObj.list) |
|
72 | 74 |
fs.trans.gs <- getData(gs.trans) |
73 | 75 |
expect_equal(fsApply(fs.trans.gs, colMeans, use.exprs = TRUE), expectRes) |
74 | 76 |
|
... | ... |
@@ -78,4 +80,4 @@ test_that("compensate & transform a GatingSet", { |
78 | 80 |
fs.trans.gs <- getData(gs.trans) |
79 | 81 |
expect_equal(fsApply(fs.trans.gs, colMeans, use.exprs = TRUE), expectRes) |
80 | 82 |
expect_equal(fs.trans.gs@file, tmp) |
81 |
- }) |
|
82 | 83 |
\ No newline at end of file |
84 |
+ }) |