annotate gg/getGEO.R @ 21:9746b310d9ad draft

Uploaded
author testtool
date Mon, 06 Feb 2017 09:17:43 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21
9746b310d9ad Uploaded
testtool
parents:
diff changeset
1 require("BiocGenerics", quietly = TRUE)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
2 require("data.table", quietly = TRUE)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
3 require("GEOquery", quietly = TRUE)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
4 require("rtracklayer", quietly = TRUE)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
5 require("FDb.InfiniumMethylation.hg19", quietly = TRUE)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
6
9746b310d9ad Uploaded
testtool
parents:
diff changeset
7 options(warn = -1)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
8 options("download.file.method"="wget")
9746b310d9ad Uploaded
testtool
parents:
diff changeset
9 args <- commandArgs(trailingOnly = TRUE)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
10 GSMTable = args[1]
9746b310d9ad Uploaded
testtool
parents:
diff changeset
11 MetaTable = args[2]
9746b310d9ad Uploaded
testtool
parents:
diff changeset
12 IlmnTable = args[3]
9746b310d9ad Uploaded
testtool
parents:
diff changeset
13 gmTable = args[4]
9746b310d9ad Uploaded
testtool
parents:
diff changeset
14
9746b310d9ad Uploaded
testtool
parents:
diff changeset
15 TAB = fread(GSMTable)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
16
9746b310d9ad Uploaded
testtool
parents:
diff changeset
17 if (is.null(TAB)) {
9746b310d9ad Uploaded
testtool
parents:
diff changeset
18 stop("Must specify input files")
9746b310d9ad Uploaded
testtool
parents:
diff changeset
19 } else {
9746b310d9ad Uploaded
testtool
parents:
diff changeset
20 GEODataTable <- getGEO(TAB$ID[1], getGPL = FALSE)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
21 IlmnIDTable <- Table(GEODataTable)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
22 MetaData <- data.frame(Meta(GEODataTable))
9746b310d9ad Uploaded
testtool
parents:
diff changeset
23
9746b310d9ad Uploaded
testtool
parents:
diff changeset
24
9746b310d9ad Uploaded
testtool
parents:
diff changeset
25 write.csv(MetaData, MetaTable, row.names = FALSE, sep = "\t")
9746b310d9ad Uploaded
testtool
parents:
diff changeset
26 }
9746b310d9ad Uploaded
testtool
parents:
diff changeset
27
9746b310d9ad Uploaded
testtool
parents:
diff changeset
28 hm450.hg19 <- getPlatform()
9746b310d9ad Uploaded
testtool
parents:
diff changeset
29
9746b310d9ad Uploaded
testtool
parents:
diff changeset
30 IlmnInfo <-
9746b310d9ad Uploaded
testtool
parents:
diff changeset
31 data.table(
9746b310d9ad Uploaded
testtool
parents:
diff changeset
32 IlmnID = names(hm450.hg19),
9746b310d9ad Uploaded
testtool
parents:
diff changeset
33 CHR = as.data.frame(hm450.hg19@seqnames)$value,
9746b310d9ad Uploaded
testtool
parents:
diff changeset
34 BP = as.numeric(hm450.hg19@elementMetadata$probeStart)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
35 )
9746b310d9ad Uploaded
testtool
parents:
diff changeset
36
9746b310d9ad Uploaded
testtool
parents:
diff changeset
37
9746b310d9ad Uploaded
testtool
parents:
diff changeset
38 write.csv(IlmnInfo, IlmnTable, row.names = FALSE, sep = "\t")
9746b310d9ad Uploaded
testtool
parents:
diff changeset
39
9746b310d9ad Uploaded
testtool
parents:
diff changeset
40
9746b310d9ad Uploaded
testtool
parents:
diff changeset
41 if (length(TAB$ID) > 1) {
9746b310d9ad Uploaded
testtool
parents:
diff changeset
42 mysamples <-
9746b310d9ad Uploaded
testtool
parents:
diff changeset
43 do.call("data.table", lapply(TAB$ID[-1], function(x)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
44 Table(getGEO(x, getGPL = FALSE))[, -1]))
9746b310d9ad Uploaded
testtool
parents:
diff changeset
45
9746b310d9ad Uploaded
testtool
parents:
diff changeset
46 gmSet <- data.table(IlmnIDTable[, -1], mysamples)
9746b310d9ad Uploaded
testtool
parents:
diff changeset
47
9746b310d9ad Uploaded
testtool
parents:
diff changeset
48 } else {
9746b310d9ad Uploaded
testtool
parents:
diff changeset
49 gmSet <- Table(getGEO(TAB$ID, getGPL = FALSE))
9746b310d9ad Uploaded
testtool
parents:
diff changeset
50 }
9746b310d9ad Uploaded
testtool
parents:
diff changeset
51
9746b310d9ad Uploaded
testtool
parents:
diff changeset
52
9746b310d9ad Uploaded
testtool
parents:
diff changeset
53 write.csv(gmSet, gmTable, row.names = FALSE, sep = "\t")