annotate getGEO/getGEO.R @ 13:8c5fb91cba27 draft

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