Contents

1 TWGBS data

The DNA methylation data have been stored as rds files and are bsseq objects. They contain the raw counts for each CpG position in the mm10 reference genome as well the preprocessed smoothed values for each sample. In addition there is a second file containing DNA methylation profiles per tissue, e.g. the replicates from the same tissue have been collapsed. Also here the smoothed values have been precomputed and are directly available.

1.1 Per sample

We first load necessary libraries and data:

library(ExperimentHub)
library(bsseq)
eh <- ExperimentHub()
#> snapshotDate(): 2019-05-07
BS.obj.ex.fit <- eh[["EH1072"]]
#> see ?tissueTreg and browseVignettes('tissueTreg') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache 
#>     'EH1072 : 1072'

For example to visually inspect the DNA methylation state of the FoxP3 gene in the CNS2 region we first specify a single region:

regions <- GRanges(
  seqnames = c("X"),
  ranges = IRanges(start = c(7579676),
                   end = c(7595243)
  )
)

We can then directly use the plotRegion function from the bsseq package for visualization based on smoothed values:

plotRegion(BS.obj.ex.fit, region=regions[1,], extend = 2000)

We assume that the three sample with higher DNA methylation in CNS2 are the T conventional samples. To check that visually we can color the samples by tissue and cell type.

We check the order in the object first:

colnames(BS.obj.ex.fit)
#>  [1] "Fat-Treg-R1"     "Fat-Treg-R2"     "Fat-Treg-R3"     "Liver-Treg-R1"  
#>  [5] "Liver-Treg-R2"   "Liver-Treg-R3"   "Skin-Treg-R1"    "Skin-Treg-R2"   
#>  [9] "Skin-Treg-R3"    "Lymph-N-Tcon-R1" "Lymph-N-Tcon-R2" "Lymph-N-Tcon-R3"
#> [13] "Lymph-N-Treg-R1" "Lymph-N-Treg-R2" "Lymph-N-Treg-R3"

And assign the colors:

pData <- pData(BS.obj.ex.fit)
pData$col <- rep(c("red", "blue", "green", "yellow", "orange"), rep(3,5))
pData(BS.obj.ex.fit) <- pData
plotRegion(BS.obj.ex.fit, region=regions[1,], extend = 2000)

This plot is confirming our assumption but we don’t have to plot all samples since they seem to be already consistent. We would now like to do the same region using smoothed values for each group.

1.2 Per tissue / cell type

The smoothed data has already been precomputed and stored in a another rds file which we first need to load:

BS.obj.ex.fit.combined <- eh[["EH1073"]]
#> see ?tissueTreg and browseVignettes('tissueTreg') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache 
#>     'EH1073 : 1073'
colnames(BS.obj.ex.fit.combined)
#> [1] "Fat-Treg"     "Liver-Treg"   "Lymph-N-Tcon" "Lymph-N-Treg"
#> [5] "Skin-Treg"

We now only have the tissue and cell type instead of the replicates. We assign the same colors:

pData <- pData(BS.obj.ex.fit.combined)
pData$col <- c("red", "blue", "yellow", "orange", "green")
pData(BS.obj.ex.fit.combined) <- pData
plotRegion(BS.obj.ex.fit.combined, region=regions[1,], extend = 2000)

2 RNA-seq data

2.1 Per sample

The RNA-seq experiments are available and as a SummarizedExperiment object. Two objects are available for usage: RPKM values and htseq counts. We will use the RPKM values and would like to look up the expression of FoxP3:

We load the SummarizedExperiment object:

se_rpkms <- eh[["EH1074"]]
#> see ?tissueTreg and browseVignettes('tissueTreg') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache 
#>     'EH1074 : 1074'

EnsemblIDs are given as well as gene symbols:

head(assay(se_rpkms))
#>                    Fat-Treg-R1 Fat-Treg-R2 Fat-Treg-R3 Liver-Treg-R1
#> ENSMUSG00000030105          29          11          19             6
#> ENSMUSG00000042428           0           0           0             0
#> ENSMUSG00000096054           2           1           3             1
#> ENSMUSG00000046532           5           5           3             0
#> ENSMUSG00000020495           2           0           2             1
#> ENSMUSG00000058979           2           4           4             7
#>                    Liver-Treg-R2 Liver-Treg-R3 Lymph-N-Tcon-R1
#> ENSMUSG00000030105            11            16              12
#> ENSMUSG00000042428             0             0               0
#> ENSMUSG00000096054             1             2               1
#> ENSMUSG00000046532             0             0               2
#> ENSMUSG00000020495             2             2               2
#> ENSMUSG00000058979            14             7               8
#>                    Lymph-N-Tcon-R2 Lymph-N-Tcon-R3 Lymph-N-Treg-R1
#> ENSMUSG00000030105              19              19              18
#> ENSMUSG00000042428               0               0               0
#> ENSMUSG00000096054               1               1               1
#> ENSMUSG00000046532               1               1               0
#> ENSMUSG00000020495               3               2               3
#> ENSMUSG00000058979               8              14               8
#>                    Lymph-N-Treg-R2 Lymph-N-Treg-R3 Skin-Treg-R1 Skin-Treg-R2
#> ENSMUSG00000030105              22              21           16           19
#> ENSMUSG00000042428               0               0            0            0
#> ENSMUSG00000096054               2               1            1            2
#> ENSMUSG00000046532               0               0            0            1
#> ENSMUSG00000020495               2               2            1            1
#> ENSMUSG00000058979               8              10            6            3
#>                    Skin-Treg-R3
#> ENSMUSG00000030105           24
#> ENSMUSG00000042428            0
#> ENSMUSG00000096054            3
#> ENSMUSG00000046532            1
#> ENSMUSG00000020495            1
#> ENSMUSG00000058979            8
head(rowData(se_rpkms))
#> DataFrame with 6 rows and 1 column
#>                      id_symbol
#>                    <character>
#> ENSMUSG00000030105       Arl8b
#> ENSMUSG00000042428       Mgat3
#> ENSMUSG00000096054       Syne1
#> ENSMUSG00000046532          Ar
#> ENSMUSG00000020495        Smg8
#> ENSMUSG00000058979       Cecr5

We can for example obtain the RPKM values for Foxp3 in this way:

assay(se_rpkms)[rowData(se_rpkms)$id_symbol=="Foxp3",]
#>     Fat-Treg-R1     Fat-Treg-R2     Fat-Treg-R3   Liver-Treg-R1 
#>              14              16              20              13 
#>   Liver-Treg-R2   Liver-Treg-R3 Lymph-N-Tcon-R1 Lymph-N-Tcon-R2 
#>              14              18               1               1 
#> Lymph-N-Tcon-R3 Lymph-N-Treg-R1 Lymph-N-Treg-R2 Lymph-N-Treg-R3 
#>               1              15              13              15 
#>    Skin-Treg-R1    Skin-Treg-R2    Skin-Treg-R3 
#>              25              14              21

colData() also contains information about the tissue and cell type the replicate belongs to:

head(colData(se_rpkms))
#> DataFrame with 6 rows and 1 column
#>               tissue_cell
#>               <character>
#> Fat-Treg-R1      Fat-Treg
#> Fat-Treg-R2      Fat-Treg
#> Fat-Treg-R3      Fat-Treg
#> Liver-Treg-R1  Liver-Treg
#> Liver-Treg-R2  Liver-Treg
#> Liver-Treg-R3  Liver-Treg

We can put this information together and visualize a simple barplot:

library(ggplot2)
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
library(reshape2)
foxp3_rpkm <- assay(se_rpkms)[rowData(se_rpkms)$id_symbol=="Foxp3",]
foxp3_rpkm_molten <- melt(foxp3_rpkm)
ggplot(data=foxp3_rpkm_molten, aes(x=rownames(foxp3_rpkm_molten), y=value, fill=colData(se_rpkms)$tissue_cell)) +
    geom_bar(stat="identity") +
    theme(axis.text.x=element_text(angle=45, hjust=1)) +
    xlab("Sample") +
    ylab("RPKM") +
    ggtitle("FoxP3 expression") +
    guides(fill=guide_legend(title="tissue / cell type"))