git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/crlmm@48937 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -57,7 +57,7 @@ importFrom(ff, ffdf, physical.ff, physical.ffdf) |
57 | 57 |
|
58 | 58 |
exportClasses(CNSetLM, ffdf, list) |
59 | 59 |
exportMethods(open, "[", show, lM, lines, nu, phi, corr, sigma2, tau2) |
60 |
-exportMethods(CA, CB) |
|
60 |
+exportMethods(CA, CB, totalCopyNumber) |
|
61 | 61 |
export(crlmm, |
62 | 62 |
crlmmCopynumber, |
63 | 63 |
crlmmIllumina, |
... | ... |
@@ -245,3 +245,41 @@ setMethod("CA", "CNSet", function(object) { |
245 | 245 |
browser() |
246 | 246 |
##assayDataElement(object, "CA") |
247 | 247 |
}) |
248 |
+ |
|
249 |
+setMethod("totalCopyNumber", |
|
250 |
+ signature=signature(object="CNSet", i="integerOrMissing", j="integerOrMissing"), |
|
251 |
+ function(object, i, j, ...){ |
|
252 |
+ if(missing(i) & missing(j)){ |
|
253 |
+ if(inherits(CA(object), "ff") | inherits(CA(object), "ffdf")) stop("Must specify i and/or j for ff objects") |
|
254 |
+ } |
|
255 |
+ if(missing(i) & !missing(j)){ |
|
256 |
+ snp.index <- which(isSnp(object)) |
|
257 |
+ cn.total <- as.matrix(CA(object)[, j]) |
|
258 |
+ if(length(snp.index) > 0){ |
|
259 |
+ cb <- as.matrix(CB(object)[snp.index, j]) |
|
260 |
+ snps <- (1:nrow(cn.total))[i %in% snp.index] |
|
261 |
+ cn.total[snps, ] <- cn.total[snps, j] + cb |
|
262 |
+ } |
|
263 |
+ } |
|
264 |
+ if(!missing(i) & missing(j)){ |
|
265 |
+ snp.index <- intersect(which(isSnp(object)), i) |
|
266 |
+ cn.total <- as.matrix(CA(object)[i, ]) |
|
267 |
+ if(length(snp.index) > 0){ |
|
268 |
+ cb <- as.matrix(CB(object)[snp.index, ]) |
|
269 |
+ snps <- (1:nrow(cn.total))[i %in% snp.index] |
|
270 |
+ cn.total[snps, ] <- cn.total[snps, ] + cb |
|
271 |
+ } |
|
272 |
+ } |
|
273 |
+ if(!missing(i) & !missing(j)){ |
|
274 |
+ snp.index <- intersect(which(isSnp(object)), i) |
|
275 |
+ cn.total <- as.matrix(CA(object)[i, j]) |
|
276 |
+ if(length(snp.index) > 0){ |
|
277 |
+ cb <- as.matrix(CB(object)[snp.index, j]) |
|
278 |
+ snps <- (1:nrow(cn.total))[i %in% snp.index] |
|
279 |
+ cn.total[snps, ] <- cn.total[snps, ] + cb |
|
280 |
+ } |
|
281 |
+ } |
|
282 |
+ cn.total <- cn.total/100 |
|
283 |
+ dimnames(cn.total) <- NULL |
|
284 |
+ return(cn.total) |
|
285 |
+}) |