```{r setup, include=FALSE}
library(edgeR)
```

```{r prepareData}
load("../Robjects/DE.Rdata")
results <- as.data.frame(topTags(lrt_BvsL, n = Inf))
# Load in the mouse c2 gene sets
# The R object is called Mm.c2
load("../data/mouse_c2_v5.rdata")
c2.ind <- ids2indices(Mm.c2, rownames(dgeObj$counts))
# all gene sets with MYC in the name
myc <- grep("MYC_",names(c2.ind))
# Specify a design matrix without an intercept term
design <- model.matrix(~ CellType + Status, data = sampleinfo)
```

> ## Challenge 1 {.challenge}
>
> 1. Test whether the MYC signalling pathways tend to be differentially expressed between basal virgin vs lactating.
> 1. Look for gene sets containing "WNT" in the name and see whether they tend to be differentially expressed in basal pregnant vs lactating.
>

```{r solutionChallenge1}
colnames(design)
#Solution 1
myc.rst2 <- roast.DGEList(dgeObj,index=c2.ind[myc],design=design,contrast=4,nrot=999)
myc.rst2[1:15,]

#Solution 2
wnt <- grep("WNT",names(c2.ind))
wnt.rst <- roast.DGEList(dgeObj,index=c2.ind[wnt],design=design,contrast=3,nrot=999)
wnt.rst[1:15,]
```


> ## Challenge 2 {.challenge}
>
> 1. Run `camera` on the pregnant vs lactating contrast.
> 1. Run `camera` on a different set of MSigDB gene sets, the hallmark datasets, `mouse_H_v5.rdata`.
> You will need to load in the hallmark gene sets, and the object will be called `Mm.H` in R.
>


```{r solutionChallenge2}

# Run `camera` on the pregnant vs lactating contrast.

# Check contrasts:
colnames(design)

# Run analysis:
gst.camera <- camera.DGEList(dgeObj,index=c2.ind,design=design,contrast=3,inter.gene.cor=0.05)
gst.camera[1:5,]
table(gst.camera$FDR < 0.05)

# Run `camera` on a different set of MSigDB gene sets, the hallmark datasets, `mouse_H_v5.rdata`.

load("../data/mouse_H_v5.rdata")
H.ind <- ids2indices(Mm.H, rownames(dgeObj$counts))

# Check contrasts:
print(colnames(design))

# Run analysis:
H.camera <- camera.DGEList(dgeObj,index=H.ind,design=design,contrast=3,inter.gene.cor=0.05)
table(H.camera$FDR < 0.05)
H.camera[1:10,]
```
