DownloadProtocol_v1.R
1.83 KB
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
library(GEOquery)
DownloadGEO <- function( geoid, ddir ){
# Work directory
wdir <- file.path( ddir, geoid, fsep = "/" )
# Create individual folder
if ( !dir.exists( wdir ) ) {
dir.create( wdir )
}
print("Saving...")
print(ddir)
# Removing downloaded files for geo ID
file.remove( list.files( wdir, pattern = geoid, full.names = TRUE ) )
# Download GSE without neither expression values nor platform info
GEO <- getGEO(
GEO = geoid,
destdir = wdir,
AnnotGPL = FALSE,
getGPL = FALSE,
GSEMatrix = FALSE)
return("successful download")
}
#######################################################################################
#-----------------------------------------MAIN-----------------------------------------
#######################################################################################
## Input files and output directories
# Download dir
ddir <- "/export/storage/users/egaytan/GEO-MetaData/download"
#ddir <- "/home/egaytan/automatic-extraction-growth-conditions/Extraction/download"
#ddir <- "/home/egaytan/Documentos/EGAYTAN-GROWTH-CONDITIONS/GEO/download"
# GSE information file
infofile <- "/export/storage/users/egaytan/GEO-MetaData/input/gsm-gse-count_v4.txt"
#infofile <- "/home/egaytan/automatic-extraction-growth-conditions/Extraction/input/gsm-gse-count_v4.txt"
#infofile <- "/home/egaytan/Documentos/EGAYTAN-GROWTH-CONDITIONS/extraccion/gsm-gse-count_v4.txt"
## Load main variables
# GSE-GSM
gseInfo <- read.table( infofile,header = T, sep = "," )
gseInfo <- gseInfo[complete.cases(gseInfo),]
## Download GSE-list
sink("download_report.txt", append = FALSE, split = FALSE)
for (geoid in unique(gseInfo$gse)) {
print(geoid)
report <- tryCatch(
DownloadGEO( geoid, ddir ),
error = function( e ) return( "download failed" ) )
print(report)
}