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