comparison GRsetFromGEO/GRsetFromGEO.R @ 37:c982fdb0e27d draft

Uploaded
author testtool
date Mon, 24 Apr 2017 08:57:06 -0400
parents b3761b109ca9
children 234e990e8e1d
comparison
equal deleted inserted replaced
36:b3761b109ca9 37:c982fdb0e27d
19 19
20 default.450k.annotation <- "ilmn12.hg19" 20 default.450k.annotation <- "ilmn12.hg19"
21 21
22 22
23 23
24 function (GSE = GSE, array = "IlluminaHumanMethylation450k", annotation = default.450k.annotation, 24 array = "IlluminaHumanMethylation450k"
25 what = c("Beta", "M"), mergeManifest = FALSE, i = 1){ 25 annotation = default.450k.annotation
26 26 what = c("Beta", "M")
27 27 mergeManifest = FALSE
28 gset <- getGEO(GSE) 28 i = 1
29 gset <- gset[[1]] 29
30 30 gset <- getGEO(GSE)
31 platform <- annotation(gset) 31 gset <- gset[[1]]
32 32
33 ann <- getAnnotationString(c(array = array, annotation = annotation)) 33 platform <- annotation(gset)
34 if (!require(ann, character.only = TRUE)) 34
35 stop(sprintf("cannot load annotation package %s", ann)) 35 ann <- getAnnotationString(c(array = array, annotation = annotation))
36 36 if (!require(ann, character.only = TRUE))
37 object <- get(ann) 37 stop(sprintf("cannot load annotation package %s", ann))
38 38
39 gr <- getLocations(object, mergeManifest = mergeManifest, 39 object <- get(ann)
40 orderByLocation = TRUE) 40
41 locusNames <- names(gr) 41 gr <- getLocations(object, mergeManifest = mergeManifest,
42 sampleNames(gset) <- gset$title 42 orderByLocation = TRUE)
43 common <- intersect(locusNames, fData(gset)$Name) 43 locusNames <- names(gr)
44 if (length(common) == 0) { 44 sampleNames(gset) <- gset$title
45 stop("No rowname matches. 'rownames' need to match IlluminaHumanMethylation450k probe names.") 45 common <- intersect(locusNames, fData(gset)$Name)
46 ind1 <- match(common, fData(gset)$Name) 46 if (length(common) == 0) {
47 ind2 <- match(common, locusNames) 47 stop("No rowname matches. 'rownames' need to match IlluminaHumanMethylation450k probe names.")
48 preprocessing <- c(rg.norm = paste0("See GEO ", GSE, " for details")) 48 ind1 <- match(common, fData(gset)$Name)
49 if (what == "Beta") { 49 ind2 <- match(common, locusNames)
50 out <- GenomicRatioSet(gr = gr[ind2, ], Beta = exprs(gset)[ind1, 50 preprocessing <- c(rg.norm = paste0("See GEO ", GSE, " for details"))
51 , drop = FALSE], M = NULL, CN = NULL, pData = pData(gset), 51 if (what == "Beta") {
52 annotation = c(array = array, annotation = annotation), 52 out <- GenomicRatioSet(gr = gr[ind2, ], Beta = exprs(gset)[ind1,
53 preprocessMethod = preprocessing) 53 , drop = FALSE], M = NULL, CN = NULL, pData = pData(gset),
54 } 54 annotation = c(array = array, annotation = annotation),
55 else { 55 preprocessMethod = preprocessing)
56 out <- GenomicRatioSet(gr = gr[ind2, ], Beta = NULL,
57 M = exprs(gset)[ind1, , drop = FALSE], CN = NULL,
58 pData = pData(gset), annotation = c(array = array,
59 annotation = annotation), preprocessMethod = preprocessing)
60 }
61 return(out)
62 } 56 }
63 save(out,file = output) 57 else {
58 out <- GenomicRatioSet(gr = gr[ind2, ], Beta = NULL,
59 M = exprs(gset)[ind1, , drop = FALSE], CN = NULL,
60 pData = pData(gset), annotation = c(array = array,
61 annotation = annotation), preprocessMethod = preprocessing)
62 }
63 return(out)
64 } 64 }
65 save(out,file = output)
66
67