# Accession numbers of datasets:

accnumber <- c("E-GEOD-60542",  
               "E-GEOD-71571",  
               "E-GEOD-64415",  
               "E-GEOD-48278",  
               "E-GEOD-58697",  
               "E-GEOD-68720",  
               "E-GEOD-67851",  
               "E-GEOD-64857",  
               "E-GEOD-53224",  
               "E-GEOD-49697",  
               "E-GEOD-28654",  
               "E-GEOD-54543",  
               "E-GEOD-63626",  
               "E-GEOD-57065",  
               "E-GEOD-61804",  
               "E-GEOD-33532",  
               "E-GEOD-19722",  
               "E-GEOD-59312",  
               "E-GEOD-39084",  
               "E-GEOD-60028",  
               "E-GEOD-45670",  
               "E-GEOD-38662",  
               "E-GEOD-58558",  
               "E-GEOD-49243",  
               "E-GEOD-54837",  
               "E-GEOD-50774",  
               "E-GEOD-46474",  
               "E-GEOD-48780",  
               "E-GEOD-48350",  
               "E-GEOD-53890",  
               "E-GEOD-45216",  
               "E-GEOD-53987",  
               "E-GEOD-29623",  
               "E-GEOD-45867")


# Sort accession numbers alphabetically:

accnumber <- sort(accnumber)




# Iterate through datasets, load the Rda-files containing the phenodata
# and extract the proportions of female patients and the number of observations
# for each dataset:

sizes <- probfemale <- 0

for(i in seq(along=accnumber)) {
  load(paste("./ICSVCodeData/DataRetrieval/sdrffiles/", accnumber[i], "_datainfo.Rda", sep=""))
  y <- factor(as.numeric(datainfo$sexvar=="female")+1, levels=c(1,2))
  probfemale[i] <- mean(y==2)
  sizes[i] <- length(y)
}



# Years of publication of the dataset (obtained manually from the ArrayExpress webpage):

pubyear <- c(2014, 2015, 2014, 2014, 2014, 2014, 2014, 
             2014, 2013, 2014, 2015, 2014, 2014, 2014, 
             2015, 2014, 2015, 2014, 2014, 2015, 2014, 
             2014, 2014, 2015, 2014, 2014, 2015, 2014, 
             2014, 2015, 2015, 2015, 2015, 2015)  



# Make LaTeX-code for table found in the Supplementary Materials:

entries <- paste(accnumber, " & ", sizes, " & ", format(round(probfemale, 2), nsmall=2), " & ", pubyear, "\\\\[1pt]", sep="")
entries <- c("{\\centering", 
             "\\captionof{table}{Meta information on the datasets used in the empirical study.}", 
             "\\label{tab:datasets}", "\\begin{tabular}{l l l l}", "Accession number & Number of & Proportion of & Year of\\\\",
             " & observations & female patients & publication\\\\[5pt]", "\\hline",
             entries, "\\end{tabular}}")

for(i in seq(along=entries))
  cat(entries[i], "\n")
