34
|
1 require("minfi", quietly = TRUE)
|
36
|
2 require("GEOquery", quietly = TRUE)
|
|
3 require("FDb.InfiniumMethylation.hg19", quietly = TRUE)
|
34
|
4
|
|
5 args <- commandArgs(trailingOnly = TRUE)
|
|
6 GSE = args[1]
|
|
7 output = args[2]
|
|
8
|
36
|
9 getAnnotationString <- function(annotation) {
|
|
10 if(length(annotation) == 1)
|
|
11 return(sprintf("%sanno", annotation))
|
|
12 if(all(c("array", "annotation") %in% names(annotation)))
|
|
13 return(sprintf("%sanno.%s", annotation["array"], annotation["annotation"]))
|
|
14 stop("unable to get the annotation string for this object")
|
|
15 }
|
|
16
|
|
17 default.450k.annotation <- "ilmn12.hg19"
|
|
18
|
|
19
|
|
20
|
37
|
21 array = "IlluminaHumanMethylation450k"
|
|
22 annotation = default.450k.annotation
|
|
23 what = c("Beta", "M")
|
|
24 mergeManifest = FALSE
|
|
25 i = 1
|
|
26
|
|
27 gset <- getGEO(GSE)
|
|
28 gset <- gset[[1]]
|
|
29
|
|
30 platform <- annotation(gset)
|
|
31
|
|
32 ann <- getAnnotationString(c(array = array, annotation = annotation))
|
|
33 if (!require(ann, character.only = TRUE))
|
|
34 stop(sprintf("cannot load annotation package %s", ann))
|
|
35
|
|
36 object <- get(ann)
|
|
37
|
|
38 gr <- getLocations(object, mergeManifest = mergeManifest,
|
|
39 orderByLocation = TRUE)
|
|
40 locusNames <- names(gr)
|
|
41 sampleNames(gset) <- gset$title
|
|
42 common <- intersect(locusNames, fData(gset)$Name)
|
|
43 if (length(common) == 0) {
|
|
44 stop("No rowname matches. 'rownames' need to match IlluminaHumanMethylation450k probe names.")
|
|
45 ind1 <- match(common, fData(gset)$Name)
|
|
46 ind2 <- match(common, locusNames)
|
|
47 preprocessing <- c(rg.norm = paste0("See GEO ", GSE, " for details"))
|
|
48 if (what == "Beta") {
|
|
49 out <- GenomicRatioSet(gr = gr[ind2, ], Beta = exprs(gset)[ind1,
|
|
50 , drop = FALSE], M = NULL, CN = NULL, pData = pData(gset),
|
|
51 annotation = c(array = array, annotation = annotation),
|
|
52 preprocessMethod = preprocessing)
|
35
|
53 }
|
37
|
54 else {
|
|
55 out <- GenomicRatioSet(gr = gr[ind2, ], Beta = NULL,
|
|
56 M = exprs(gset)[ind1, , drop = FALSE], CN = NULL,
|
|
57 pData = pData(gset), annotation = c(array = array,
|
|
58 annotation = annotation), preprocessMethod = preprocessing)
|
|
59 }
|
|
60 return(out)
|
35
|
61 }
|
37
|
62 save(out,file = output)
|
|
63
|
|
64
|