---
title: "Differential expression using RNA-seq data"
author: "Guillermo Ayala" 
date: "`r Sys.Date()`"
format: 
    revealjs:  
      scrollable: true
      echo: true
      embed-resources: true
    pdf:
       toc: true
       number-sections: false
       colorlinks: true  
---

# Packages
 
We have to load the package **SummarizedExperiment** to use the class
**RangedSummarizedExperiment** or simply **SummarizedExperiment**. 
```{r}
#| label: se1
pacman::p_load(tami,SummarizedExperiment)
```

# Data  
The RNA-seq dataset used in this vignette is **PRJNA297664** and can be loaded
from **tamidata**.

```{r}
#| label: se2
data(PRJNA297664,package="tamidata")
```


The phenotypic covariables are 
```{r}
#| label: se3
colData(PRJNA297664)
```
The covariable `colData(x)[,"treatment"]` will be used as the 
experimental factor giving the group or condition of each sample.


# Marginal differential expression using edgeR

# Common dispersion  

We can consider a common dispersion.
```{r}
#| label: se4
PRJNA297664_common_deo = 
  tami::dema(x=PRJNA297664,y="treatment",test = edgercommon,
       correction = "BH",fdr= 0.01,foutput = "output")
```
A `data.frame` with the results is obtained with 
```{r}
#| label: se5
df1 = tidy(PRJNA297664_common_deo)
```
The same report in a html file is obtained with
```{r}
#| label: se6
glimpse(PRJNA297664_common_deo)
```
We can open the file with
```{r}
#| label: se7
browseURL(glimpse(PRJNA297664_common_deo))
```

# Tagwise dispersion  

The second choice is to consider a different dispersion parameter
per gene. 

```{r}
#| label: se8
PRJNA297664_tagwise_deo = 
  dema(x=PRJNA297664,y="treatment",test = edgertagwise,
       correction = "BH",fdr= 0.01,foutput = "output")
```
A `data.frame` with the results is obtained with 
```{r}
#| label: se9
df1 = tidy(PRJNA297664_tagwise_deo)
```
The same report in a html file is obtained with
```{r}
#| label: se10
glimpse(PRJNA297664_tagwise_deo)
```
We can open the file with
```{r}
#| label: se11
browseURL(glimpse(PRJNA297664_tagwise_deo))
```
