-
Notifications
You must be signed in to change notification settings - Fork 2
/
Download_GEOQuery.R
61 lines (50 loc) · 2.32 KB
/
Download_GEOQuery.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
### Script made Wed Nov 4 19:52:46 CST 2015
### R version 3.2.0 (2015-04-16) -- "Full of Ingredients"
### Platform: x86_64-unknown-linux-gnu (64-bit)
### GEOquery_2.34.0 Biobase_2.28.0 BiocGenerics_0.14.0
#install GEOquery
source("http://bioconductor.org/biocLite.R")
biocLite("GEOquery")
library(GEOquery)
############################################################################
# A) If you have the GSM vector try to Download the .CEL files through: ###
############################################################################
# You need your own GSM vector, or for this time you can use the following:
############### Example GSM vector #################
MyGSMList = c("GSM272923","GSM272924","GSM272925")##
####################################################
sapply(MyGSMList,function(x){ getGEOSuppFiles(x)})
###################################################################
# B) If you only have a GSE's list use the next chunk of code #####
###################################################################
#This couple of functions download the .CEl.gz files asociated with your GSEs
# and also retrieves you a vector with the GSM names.
GSMnamesFromVecGSEnames<- function(vecGSEnames){
#This function recieves a vector of GSEnames
# Build up a list with equal length to the vector of GSEnames
GSEObjects<-list(length=length(vecGSEnames))
#Fill thath list with GSEObjects
for(i in 1:length(vecGSEnames)){
GSEObjects[i]<-getGEO(vecGSEnames[i],GSEMatrix=FALSE)
print("We have theGSE Object"); print(i)
}
#Call to the function to GEt a vector of GSM names of each GSE
AllGSMnames<-NamesVectorGSMFromGSE(GSEObjects)
#Call to a function to download the CEL files, from the previous GSMnames vector.
DownCELFromThisGSMVec(AllGSMnames)
#Return the GSMnames vector
return(AllGSMnames)
}
# This function recieves a List of GSEObjects and return all GSMnames in a Vector
NamesVectorGSMFromGSE <-function(ThisGSEObject){
#Build up a vector of length zero
vecpartialnames<-vector(length=0)
#Fill the previous object with the GSM names.
for (i in 1:length(ThisGSEObject)){
vecpartialnames<-c(vecpartialnames,names(GSMList(ThisGSEObject[[i]])))
}
return(vecpartialnames)
}
# Example of use
MyGSE=c("GSE2327","GSE2298")
GSMList_of_MyGSE<-GSMnamesFromVecGSEnames(MyGSE)