# HG changeset patch # User testtool # Date 1493038626 14400 # Node ID c982fdb0e27d9ff7682244a9d76e86ba1cfd4670 # Parent b3761b109ca925a7e05450236ce1ad26e296fd26 Uploaded diff -r b3761b109ca9 -r c982fdb0e27d GRsetFromGEO/GRsetFromGEO.R --- a/GRsetFromGEO/GRsetFromGEO.R Mon Apr 24 08:50:59 2017 -0400 +++ b/GRsetFromGEO/GRsetFromGEO.R Mon Apr 24 08:57:06 2017 -0400 @@ -21,44 +21,47 @@ -function (GSE = GSE, array = "IlluminaHumanMethylation450k", annotation = default.450k.annotation, - what = c("Beta", "M"), mergeManifest = FALSE, i = 1){ - - - gset <- getGEO(GSE) - gset <- gset[[1]] - - platform <- annotation(gset) - - ann <- getAnnotationString(c(array = array, annotation = annotation)) - if (!require(ann, character.only = TRUE)) - stop(sprintf("cannot load annotation package %s", ann)) - - object <- get(ann) - - gr <- getLocations(object, mergeManifest = mergeManifest, - orderByLocation = TRUE) - locusNames <- names(gr) - sampleNames(gset) <- gset$title - common <- intersect(locusNames, fData(gset)$Name) - if (length(common) == 0) { - stop("No rowname matches. 'rownames' need to match IlluminaHumanMethylation450k probe names.") - ind1 <- match(common, fData(gset)$Name) - ind2 <- match(common, locusNames) - preprocessing <- c(rg.norm = paste0("See GEO ", GSE, " for details")) - if (what == "Beta") { - out <- GenomicRatioSet(gr = gr[ind2, ], Beta = exprs(gset)[ind1, - , drop = FALSE], M = NULL, CN = NULL, pData = pData(gset), - annotation = c(array = array, annotation = annotation), - preprocessMethod = preprocessing) - } - else { - out <- GenomicRatioSet(gr = gr[ind2, ], Beta = NULL, - M = exprs(gset)[ind1, , drop = FALSE], CN = NULL, - pData = pData(gset), annotation = c(array = array, - annotation = annotation), preprocessMethod = preprocessing) - } - return(out) +array = "IlluminaHumanMethylation450k" +annotation = default.450k.annotation +what = c("Beta", "M") +mergeManifest = FALSE +i = 1 + +gset <- getGEO(GSE) +gset <- gset[[1]] + +platform <- annotation(gset) + +ann <- getAnnotationString(c(array = array, annotation = annotation)) +if (!require(ann, character.only = TRUE)) + stop(sprintf("cannot load annotation package %s", ann)) + +object <- get(ann) + +gr <- getLocations(object, mergeManifest = mergeManifest, + orderByLocation = TRUE) +locusNames <- names(gr) +sampleNames(gset) <- gset$title +common <- intersect(locusNames, fData(gset)$Name) +if (length(common) == 0) { + stop("No rowname matches. 'rownames' need to match IlluminaHumanMethylation450k probe names.") + ind1 <- match(common, fData(gset)$Name) + ind2 <- match(common, locusNames) + preprocessing <- c(rg.norm = paste0("See GEO ", GSE, " for details")) + if (what == "Beta") { + out <- GenomicRatioSet(gr = gr[ind2, ], Beta = exprs(gset)[ind1, + , drop = FALSE], M = NULL, CN = NULL, pData = pData(gset), + annotation = c(array = array, annotation = annotation), + preprocessMethod = preprocessing) } - save(out,file = output) + else { + out <- GenomicRatioSet(gr = gr[ind2, ], Beta = NULL, + M = exprs(gset)[ind1, , drop = FALSE], CN = NULL, + pData = pData(gset), annotation = c(array = array, + annotation = annotation), preprocessMethod = preprocessing) + } + return(out) } +save(out,file = output) + +