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(): 2020-04-27
BS.obj.ex.fit <- eh[["EH1072"]]
#> see ?tissueTreg and browseVignettes('tissueTreg') for documentation
#> loading from cache

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
#> loading from cache
colnames(BS.obj.ex.fit.combined)
#> [1] "Fat-Treg"     "Liver-Treg"   "Lymph-N-Tcon" "Lymph-N-Treg" "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
#> loading from cache

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 Lymph-N-Tcon-R2
#> ENSMUSG00000030105            11            16              12              19
#> ENSMUSG00000042428             0             0               0               0
#> ENSMUSG00000096054             1             2               1               1
#> ENSMUSG00000046532             0             0               2               1
#> ENSMUSG00000020495             2             2               2               3
#> ENSMUSG00000058979            14             7               8               8
#>                    Lymph-N-Tcon-R3 Lymph-N-Treg-R1 Lymph-N-Treg-R2
#> ENSMUSG00000030105              19              18              22
#> ENSMUSG00000042428               0               0               0
#> ENSMUSG00000096054               1               1               2
#> ENSMUSG00000046532               1               0               0
#> ENSMUSG00000020495               2               3               2
#> ENSMUSG00000058979              14               8               8
#>                    Lymph-N-Treg-R3 Skin-Treg-R1 Skin-Treg-R2 Skin-Treg-R3
#> ENSMUSG00000030105              21           16           19           24
#> ENSMUSG00000042428               0            0            0            0
#> ENSMUSG00000096054               1            1            2            3
#> ENSMUSG00000046532               0            0            1            1
#> ENSMUSG00000020495               2            1            1            1
#> ENSMUSG00000058979              10            6            3            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   Liver-Treg-R2 
#>              14              16              20              13              14 
#>   Liver-Treg-R3 Lymph-N-Tcon-R1 Lymph-N-Tcon-R2 Lymph-N-Tcon-R3 Lymph-N-Treg-R1 
#>              18               1               1               1              15 
#> Lymph-N-Treg-R2 Lymph-N-Treg-R3    Skin-Treg-R1    Skin-Treg-R2    Skin-Treg-R3 
#>              13              15              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)
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"))

3 sessionInfo()

#> R version 4.0.0 (2020-04-24)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.11-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.11-bioc/R/lib/libRlapack.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats4    parallel  stats     graphics  grDevices utils     datasets 
#> [8] methods   base     
#> 
#> other attached packages:
#>  [1] reshape2_1.4.4              ggplot2_3.3.0              
#>  [3] tissueTreg_1.8.0            bsseq_1.24.0               
#>  [5] SummarizedExperiment_1.18.1 DelayedArray_0.14.0        
#>  [7] matrixStats_0.56.0          Biobase_2.48.0             
#>  [9] GenomicRanges_1.40.0        GenomeInfoDb_1.24.0        
#> [11] IRanges_2.22.1              S4Vectors_0.26.0           
#> [13] ExperimentHub_1.14.0        AnnotationHub_2.20.0       
#> [15] BiocFileCache_1.12.0        dbplyr_1.4.3               
#> [17] BiocGenerics_0.34.0         BiocStyle_2.16.0           
#> 
#> loaded via a namespace (and not attached):
#>  [1] bitops_1.0-6                  bit64_0.9-7                  
#>  [3] httr_1.4.1                    tools_4.0.0                  
#>  [5] R6_2.4.1                      HDF5Array_1.16.0             
#>  [7] DBI_1.1.0                     colorspace_1.4-1             
#>  [9] permute_0.9-5                 withr_2.2.0                  
#> [11] tidyselect_1.0.0              bit_1.1-15.2                 
#> [13] curl_4.3                      compiler_4.0.0               
#> [15] labeling_0.3                  rtracklayer_1.48.0           
#> [17] bookdown_0.18                 scales_1.1.0                 
#> [19] rappdirs_0.3.1                stringr_1.4.0                
#> [21] digest_0.6.25                 Rsamtools_2.4.0              
#> [23] rmarkdown_2.1                 R.utils_2.9.2                
#> [25] XVector_0.28.0                pkgconfig_2.0.3              
#> [27] htmltools_0.4.0               fastmap_1.0.1                
#> [29] limma_3.44.1                  BSgenome_1.56.0              
#> [31] rlang_0.4.6                   RSQLite_2.2.0                
#> [33] shiny_1.4.0.2                 DelayedMatrixStats_1.10.0    
#> [35] farver_2.0.3                  BiocParallel_1.22.0          
#> [37] gtools_3.8.2                  dplyr_0.8.5                  
#> [39] R.oo_1.23.0                   RCurl_1.98-1.2               
#> [41] magrittr_1.5                  GenomeInfoDbData_1.2.3       
#> [43] Matrix_1.2-18                 Rcpp_1.0.4.6                 
#> [45] munsell_0.5.0                 Rhdf5lib_1.10.0              
#> [47] lifecycle_0.2.0               R.methodsS3_1.8.0            
#> [49] stringi_1.4.6                 yaml_2.2.1                   
#> [51] zlibbioc_1.34.0               plyr_1.8.6                   
#> [53] rhdf5_2.32.0                  grid_4.0.0                   
#> [55] blob_1.2.1                    promises_1.1.0               
#> [57] crayon_1.3.4                  lattice_0.20-41              
#> [59] Biostrings_2.56.0             locfit_1.5-9.4               
#> [61] magick_2.3                    knitr_1.28                   
#> [63] pillar_1.4.4                  XML_3.99-0.3                 
#> [65] glue_1.4.0                    BiocVersion_3.11.1           
#> [67] evaluate_0.14                 data.table_1.12.8            
#> [69] BiocManager_1.30.10           vctrs_0.2.4                  
#> [71] httpuv_1.5.2                  gtable_0.3.0                 
#> [73] purrr_0.3.4                   assertthat_0.2.1             
#> [75] xfun_0.13                     mime_0.9                     
#> [77] xtable_1.8-4                  later_1.0.0                  
#> [79] tibble_3.0.1                  GenomicAlignments_1.24.0     
#> [81] AnnotationDbi_1.50.0          memoise_1.1.0                
#> [83] ellipsis_0.3.0                interactiveDisplayBase_1.26.0