
---
title: Fetch Windram et al. data
author: John Reid
output: html_document
---


```{r config, echo=FALSE, message=FALSE}
library(knitr)
library(rmarkdown)
#
# knitr options
#
opts_chunk$set(
    fig.path = 'figures/Windram-',
    stop_on_error = TRUE,
    fig.width = 12.5,
    fig.height = 8)

```

```{r build, echo=FALSE, eval=FALSE}
library(rmarkdown)
library(devtools)
load_all('../..')
render('fetch-Windram.Rmd')

```

```{r loadLibs, echo=FALSE, message=FALSE}
library(dplyr)
# suppressMessages(loadfonts())
#
# Stylesheet
#
options(markdown.HTML.stylesheet = system.file("inst/Rmd/foghorn.css",
                                               package="DeLorean"))

```



Windram et al. investigated the defense response in *Arabidopsis thaliana*
to the necrotrophic fungal pathogen *Botrytis cinerea*.

```{r}
# library(dplyr)
# source("http://bioconductor.org/biocLite.R")
# biocLite("GEOquery")
library(GEOquery)
gse <- getGEO("GSE29642", GSEMatrix=TRUE)[[1]]
show(gse)
length(gse)
# Expression data
class(exprs(gse))
dim(exprs(gse))
# Phenotypic data
dim(pData(gse))
class(pData(gse))
names(pData(gse))

windram.expr <- exprs(gse)
colnames(windram.expr)
windram.gene.meta <- data.frame(
    gene=rownames(windram.expr),
    TAIR9=fData(gse)$TAIR9_best)
windram.cell.meta <- data.frame(
    cell=pData(gse)$geo_accession,
    # title=pData(gse)$title,
    obstime=as.numeric(str_match(pData(gse)$title, "[[:digit:]]+")),
    condition=str_match(pData(gse)$title, "^Mock|Botrytis")
) %>% mutate(capture=factor(as.character(obstime),
                            ordered=TRUE,
                            levels=unique(as.character(obstime))))
windram.cell.meta
levels(windram.cell.meta$capture)

```


Add gene names mentioned in the text (Supplemental Table 2) to the meta data
and remove other genes from expression data.
```{r}
text.genes <- c(
    "AT1G65060",
    "AT3G51240",
    "AT1G49720",
    "AT5G46330",
    "AT4G26080",
    "AT1G74590",
    "AT5G57050",
    "AT1G78380",
    "AT5G64750",
    "AT1G17170",
    "AT1G01780",
    "AT1G17180",
    "AT4G11280",
    "AT2G29470",
    "AT1G06080",
    "AT2G29420",
    "AT1G01720",
    "AT3G09270",
    "AT1G52890",
    "AT3G59400",
    "AT3G15500",
    "AT3G14930",
    "AT5G08790",
    "AT2G40490",
    "AT5G39610",
    "AT2G44950",
    "AT1G13280",
    "AT1G74710",
    "AT2G45220",
    "AT1G19180",
    "AT5G05730",
    "AT1G17380",
    "AT1G25220",
    "AT4G22880",
    "AT2G31230",
    "AT1G55020",
    "AT3G62770",
    "AT1G17420",
    "AT5G45900",
    "AT1G72520",
    "AT4G21980",
    "AT5G23010",
    "AT4G04620",
    "AT3G18690",
    "AT1G03850",
    "AT3G45640",
    "AT3G53980",
    "AT4G01370",
    "AT5G05960",
    "AT2G43790",
    "AT1G18300",
    "AT3G06490",
    "AT3G27310",
    "AT1G06180",
    "AT5G64080",
    "AT2G47190",
    "AT2G13820",
    "AT5G61420",
    "AT3G19580",
    "AT5G07690",
    "AT4G33430",
    "AT5G12870",
    "AT3G19710",
    "AT1G18570",
    "AT2G39660",
    "AT1G73410",
    "AT4G39400",
    "AT5G56110",
    "AT3G13380",
    "AT1G32640",
    "AT2G46830",
    "AT2G34720",
    "AT3G21630",
    "AT4G14540",
    "AT4G32410",
    "AT1G09030",
    "AT5G05170",
    "AT1G56170",
    "AT5G45340",
    "AT1G64280",
    "AT2G30770",
    "AT5G45110",
    "AT1G16400",
    "AT3G50410",
    "AT4G13770",
    "AT1G07640",
    "AT5G25350",
    "AT3G55370",
    "AT4G39030",
    "AT1G06160",
    "AT3G23240",
    "AT3G26830",
    "AT3G15210",
    "AT3G22231",
    "AT5G47230",
    "AT3G11820",
    "AT4G17490",
    "AT1G09530",
    "AT5G61270",
    "AT2G14610",
    "AT5G64900",
    "AT5G53160",
    "AT1G01360",
    "AT4G17870",
    "AT3G14230",
    "AT3G01650",
    "AT5G14420",
    "AT2G22990",
    "AT5G66880",
    "AT3G51060",
    "AT5G06850",
    "AT1G22070",
    "AT5G06960",
    "AT3G12250",
    "AT3G02140",
    "AT3G21780",
    "AT5G24780",
    "AT5G55120",
    "AT4G31800",
    "AT2G03340",
    "AT2G38470",
    "AT1G13960",
    "AT1G80840",
    "AT1G62300",
    "AT4G23810",
    "AT2G25000",
    "AT3G56400",
    "AT5G13080",
    "AT5G46350")
windram.gene.meta <- windram.gene.meta %>% filter(TAIR9 %in% text.genes)
windram.expr <- windram.expr[windram.gene.meta$gene,]
dim(windram.expr)

```

Save the data in a format suitable for DeLorean package.
```{r}
save(windram.expr,
     windram.gene.meta,
     windram.cell.meta,
     file='../../data/WindramDeLorean.rda')

```


R version and packages used:
```{r Rversion}
sessionInfo()
```
