Contents

1 Introduction

Gene regulatory networks model the underlying gene regulation hierarchies that drive gene expression and cell states. The main functions of the epiregulon package are to construct gene regulatory networks and infer transcription factor (TF) activity at the single cell level by integrating scATAC-seq and scRNA-seq data and incorporating of public bulk TF ChIP-seq data.

There are three related packages: epiregulon, epiregulon.extra and epiregulon.archr, the two of which are available through Bioconductor and the last of which is only available through github. The basic epiregulon package takes in gene expression and chromatin accessibility matrices in the form of SingleCellExperiment objects, constructs gene regulatory networks (“regulons”) and outputs the activity of transcription factors at the single cell level. The epiregulon.extra package provides a suite of tools for enrichment analysis of target genes, visualization of target genes and transcription factor activity, and network analysis which can be run on the epireglon output. If the users would like to start from ArchR projects instead of SingleCellExperiment objects, they may choose to use epiregulon.archr package, which allows for seamless integration with the ArchR package, and continue with the rest of the workflow offered in epiregulon.extra.

For full documentation of the epiregulon package, please refer to the epiregulon book.

This tutorial demonstrates the basic functions of epiregulon, using the reprogram-seq dataset which can be downloaded from the scMultiome package. In this example, prostate cancer cells (LNCaP) were infected in separate wells with viruses encoding 4 transcription factors (NKX2-1, GATA6, FOXA1 and FOXA2) and a positive control (mNeonGreen) before pooling. The identity of the infected transcription factors was tracked through cell hashing (available in the field hash_assignment of the colData) and serves as the ground truth.

2 Installation

# if (!require("BiocManager", quietly = TRUE))
#     install.packages("BiocManager")
# 
# BiocManager::install("epiregulon")
library(epiregulon)

Alternatively, you could install from github

devtools::install_github(repo ='xiaosaiyao/epiregulon')

library(epiregulon)

3 Data preparation

Prior to using epiregulon, single cell preprocessing needs to performed by user’s favorite methods. The following components are required:
1. Peak matrix from scATAC-seq containing the chromatin accessibility information
2. Gene expression matrix from either paired or unpaired scRNA-seq. RNA-seq integration needs to be performed for unpaired dataset.
3. Dimensionality reduction matrix from with either single modalities or joint scRNA-seq and scATAC-seq

# load the MAE object
library(scMultiome)
#> Loading required package: AnnotationHub
#> Loading required package: BiocFileCache
#> Loading required package: dbplyr
#> 
#> Attaching package: 'AnnotationHub'
#> The following object is masked from 'package:Biobase':
#> 
#>     cache
#> Loading required package: ExperimentHub
#> Loading required package: MultiAssayExperiment

mae <- scMultiome::reprogramSeq()
#> see ?scMultiome and browseVignettes('scMultiome') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache

# extract peak matrix
PeakMatrix <- mae[["PeakMatrix"]]

# extract expression matrix
GeneExpressionMatrix <- mae[["GeneExpressionMatrix"]]
rownames(GeneExpressionMatrix) <- rowData(GeneExpressionMatrix)$name

# define the order of hash_assigment
GeneExpressionMatrix$hash_assignment <- factor(as.character(GeneExpressionMatrix$hash_assignment),
                                               levels = c("HTO10_GATA6_UTR", "HTO2_GATA6_v2", "HTO8_NKX2.1_UTR", "HTO3_NKX2.1_v2", 
                                                          "HTO1_FOXA2_v2", "HTO4_mFOXA1_v2", "HTO6_hFOXA1_UTR", "HTO5_NeonG_v2"))
# extract dimensional reduction matrix
reducedDimMatrix <- reducedDim(mae[['TileMatrix500']], "LSI_ATAC")

# transfer UMAP_combined from TileMatrix to GeneExpressionMatrix
reducedDim(GeneExpressionMatrix, "UMAP_Combined") <- reducedDim(mae[['TileMatrix500']], "UMAP_Combined")

Visualize singleCellExperiment by UMAP


scater::plotReducedDim(GeneExpressionMatrix, 
                       dimred = "UMAP_Combined", 
                       text_by = "Clusters", 
                       colour_by = "Clusters")

4 Quick start

4.1 Retrieve bulk TF ChIP-seq binding sites

First, we retrieve a GRangesList object containing the binding sites of all the transcription factors and co-regulators. These binding sites are derived from bulk ChIP-seq data in the ChIP-Atlas and ENCODE databases. For the same transcription factor, multiple ChIP-seq files from different cell lines or tissues are merged. For further information on how these peaks are derived, please refer to ?epiregulon::getTFMotifInfo. Currently, human genomes hg19 and hg38 and mouse mm10 are supported.

grl <- getTFMotifInfo(genome = "hg38")
#> see ?scMultiome and browseVignettes('scMultiome') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache
grl
#> GRangesList object of length 1558:
#> $AEBP2
#> GRanges object with 2700 ranges and 0 metadata columns:
#>          seqnames            ranges strand
#>             <Rle>         <IRanges>  <Rle>
#>      [1]     chr1        9792-10446      *
#>      [2]     chr1     942105-942400      *
#>      [3]     chr1     984486-984781      *
#>      [4]     chr1   3068932-3069282      *
#>      [5]     chr1   3069411-3069950      *
#>      ...      ...               ...    ...
#>   [2696]     chrY   8465261-8465730      *
#>   [2697]     chrY 11721744-11722260      *
#>   [2698]     chrY 11747448-11747964      *
#>   [2699]     chrY 19302661-19303134      *
#>   [2700]     chrY 19985662-19985982      *
#>   -------
#>   seqinfo: 25 sequences from an unspecified genome; no seqlengths
#> 
#> ...
#> <1557 more elements>

4.3 Add TF motif binding to peaks

The next step is to add the TF binding information by overlapping regions of the peak matrix with the bulk chip-seq database. The output is a data frame object with three columns:

  1. idxATAC - index of the peak in the peak matrix
  2. idxTF - index in the gene expression matrix corresponding to the transcription factor
  3. tf - name of the transcription factor

overlap <- addTFMotifInfo(grl = grl, p2g = p2g, peakMatrix = PeakMatrix)
#> Computing overlap...
#> Success!
head(overlap)
#>      idxATAC idxTF     tf
#> 9312      37     4   AGO1
#> 9313      37     7 ARID1B
#> 9314      37     8  ARID2
#> 9315      37    18   ATF3
#> 9316      37    21   ATF7
#> 9317      37    23  BACH1

4.4 Generate regulons

A DataFrame, representing the inferred regulons, is then generated. The DataFrame consists of ten columns:

  1. idxATAC - index of the peak in the peak matrix
  2. chr - chromosome number
  3. start - start position of the peak
  4. end - end position of the peak
  5. idxRNA - index in the gene expression matrix corresponding to the target gene
  6. target - name of the target gene
  7. distance - distance between the transcription start site of the target gene and the middle of the peak
  8. idxTF - index in the gene expression matrix corresponding to the transcription factor
  9. tf - name of the transcription factor
  10. corr - correlation between target gene expression and the chromatin accessibility at the peak. if cluster labels are provided, this field is a matrix with columns names corresponding to correlation across all cells and for each of the clusters.

regulon <- getRegulon(p2g = p2g, overlap = overlap, aggregate = FALSE)
regulon
#> DataFrame with 743319 rows and 10 columns
#>          idxATAC         chr     start       end    idxRNA      target
#>        <integer> <character> <integer> <integer> <integer> <character>
#> 1             37        chr1   1020509   1021009        22  AL645608.4
#> 2             37        chr1   1020509   1021009        22  AL645608.4
#> 3             37        chr1   1020509   1021009        22  AL645608.4
#> 4             37        chr1   1020509   1021009        22  AL645608.4
#> 5             37        chr1   1020509   1021009        22  AL645608.4
#> ...          ...         ...       ...       ...       ...         ...
#> 743315    126541        chrX 154374945 154375445     36389        FLNA
#> 743316    126541        chrX 154374945 154375445     36389        FLNA
#> 743317    126590        chrX 155228844 155229344     36426       CLIC2
#> 743318    126590        chrX 155228844 155229344     36426       CLIC2
#> 743319    126590        chrX 155228844 155229344     36426       CLIC2
#>         distance     idxTF          tf     corr
#>        <integer> <integer> <character> <matrix>
#> 1         106139         4        AGO1 0.592745
#> 2         106139         7      ARID1B 0.592745
#> 3         106139         8       ARID2 0.592745
#> 4         106139        18        ATF3 0.592745
#> 5         106139        21        ATF7 0.592745
#> ...          ...       ...         ...      ...
#> 743315      3524      1492      ZNF692 0.572236
#> 743316      3524      1557        ZXDB 0.572236
#> 743317    103268       114       FOXA1 0.527470
#> 743318    103268       128       GATA2 0.527470
#> 743319    103268       952       SUMO2 0.527470

4.6 Add Weights

While the pruneRegulon function provides statistics on the joint occurrence of TF-RE-TG, we would like to further estimate the strength of regulation. Biologically, this can be interpreted as the magnitude of gene expression changes induced by transcription factor activity. Epiregulon estimates the regulatory potential using one of the three measures: 1) correlation between TF and target gene expression, 2) mutual information between the TF and target gene expression and 3) Wilcoxon test statistics of target gene expression in cells jointly expressing all 3 elements vs cells that do not.

Two of the measures (correlation and Wilcoxon statistics) give both the magnitude and directionality of changes whereas mutual information is always positive. The correlation and mutual information statistics are computed on pseudobulks aggregated by user-supplied cluster labels, whereas the Wilcoxon method groups cells into two categories: 1) the active category of cells jointly expressing TF, RE and TG and 2) the inactive category consisting of the remaining cells.

We calculate cluster-specific weights if users supply cluster labels.


regulon.w <- addWeights(regulon = pruned.regulon,
                        expMatrix  = GeneExpressionMatrix,
                        exp_assay  = "normalizedCounts",
                        peakMatrix = PeakMatrix,
                        peak_assay = "counts",
                        clusters = GeneExpressionMatrix$Clusters,
                        method = "wilcox")

regulon.w

4.7 (Optional) Annotate with TF motifs

So far the gene regulatory network was constructed from TF ChIP-seq exclusively. Some users would prefer to further annotate regulatory elements with the presence of motifs. We provide an option to annotate peaks with motifs from the Cisbp database. If no motifs are present for this particular factor (as in the case of co-factors or chromatin modifiers), we return NA. If motifs are available for a factor and the RE contains a motif, we return 1. If motifs are available and the RE does not contain a motif, we return 0.


regulon.w.motif <- addMotifScore(regulon = regulon.w,
                                 peaks = rowRanges(PeakMatrix),
                                 species = "human",
                                 genome = "hg38")
#> annotating peaks with motifs
#> see ?scMultiome and browseVignettes('scMultiome') for documentation
#> downloading 1 resources
#> retrieving 1 resource
#> loading from cache
#> 
#> 
#> Attaching package: 'Biostrings'
#> The following object is masked from 'package:base':
#> 
#>     strsplit
#> 
#> Attaching package: 'rtracklayer'
#> The following object is masked from 'package:BiocIO':
#> 
#>     FileForFormat
#> The following object is masked from 'package:AnnotationHub':
#> 
#>     hubUrl

# if desired, set weight to 0 if no motif is found
regulon.w.motif$weight[regulon.w.motif$motif == 0] <- 0

regulon.w.motif
#> DataFrame with 3296 rows and 15 columns
#>        idxATAC         chr     start       end    idxRNA      target  distance
#>      <integer> <character> <integer> <integer> <integer> <character> <integer>
#> 1           86        chr1   1290083   1290583        58        DVL1     56527
#> 2          288        chr1   2526365   2526865       108  AL139246.1     32908
#> 3          640        chr1   7988538   7989038       208     TNFRSF9     47473
#> 4          654        chr1   8040536   8041036       212      ERRFI1     24704
#> 5          787        chr1   9290024   9290524       229       SPSB1       368
#> ...        ...         ...       ...       ...       ...         ...       ...
#> 3292    120296        chr9  36118633  36119133     34311        CLTA     69721
#> 3293    121835        chr9  98192900  98193400     34702      CORO2A     19817
#> 3294    122254        chr9 108991440 108991940     34784     CTNNAL1     27686
#> 3295    122461        chr9 113174265 113174765     34825     SLC31A1     44777
#> 3296    123380        chr9 128635245 128635745     35034      SPTAN1     82488
#>          idxTF          tf     corr                                   pval
#>      <integer> <character> <matrix>                               <matrix>
#> 1          490          AR 0.524540 1.91265e-03:0.50585953:0.000249278:...
#> 2          490          AR 0.602193 5.02384e-02:0.00249757:1.000000000:...
#> 3          490          AR 0.875387 7.53206e-09:0.15249790:1.000000000:...
#> 4          490          AR 0.550906 9.18676e-02:0.76535176:1.000000000:...
#> 5          490          AR 0.891738 9.64012e-13:0.51358560:1.000000000:...
#> ...        ...         ...      ...                                    ...
#> 3292       807      NKX2-1 0.522644                    0.035831331:1:1:...
#> 3293       807      NKX2-1 0.541195                    0.000419607:1:1:...
#> 3294       807      NKX2-1 0.872888                    0.013099814:1:1:...
#> 3295       807      NKX2-1 0.683659                    0.045120208:1:1:...
#> 3296       807      NKX2-1 0.745530                    0.045120208:1:1:...
#>                               stats                qval            weight
#>                            <matrix>            <matrix>          <matrix>
#> 1     9.63153:0.4426222:13.4176:... 1.00000e+00:1:1:...         0:0:0:...
#> 2     3.83348:9.1423696: 0.0000:... 1.00000e+00:1:1:...         0:0:0:...
#> 3    33.39232:2.0470852: 0.0000:... 1.24754e-04:1:1:...         0:0:0:...
#> 4     2.84134:0.0890786: 0.0000:... 1.00000e+00:1:1:...         0:0:0:...
#> 5    50.91607:0.4267549: 0.0000:... 1.60845e-08:1:1:...         0:0:0:...
#> ...                             ...                 ...               ...
#> 3292                4.40511:0:0:...           1:1:1:... 0.0343753:0:0:...
#> 3293               12.44280:0:0:...           1:1:1:... 0.0000000:0:0:...
#> 3294                6.15558:0:0:...           1:1:1:... 0.0000000:0:0:...
#> 3295                4.01414:0:0:...           1:1:1:... 0.0000000:0:0:...
#> 3296                4.01414:0:0:...           1:1:1:... 0.0000000:0:0:...
#>          motif
#>      <numeric>
#> 1            0
#> 2            0
#> 3            0
#> 4            0
#> 5            0
#> ...        ...
#> 3292         1
#> 3293         0
#> 3294         0
#> 3295         0
#> 3296         0

4.8 Calculate TF activity

Finally, the activities for a specific TF in each cell are computed by averaging expressions of target genes linked to the TF weighted by the test statistics of choice, chosen from either correlation, mutual information or the Wilcoxon test statistics. \[y=\frac{1}{n}\sum_{i=1}^{n} x_i * weights_i\] where \(y\) is the activity of a TF for a cell, \(n\) is the total number of targets for a TF, \(x_i\) is the log count expression of target \(i\) where \(i\) in {1,2,…,n} and \(weights_i\) is the weight of TF - target \(i\)

score.combine <- calculateActivity(expMatrix = GeneExpressionMatrix,
                                   regulon = regulon.w, 
                                   mode = "weight", 
                                   method = "weightedMean", 
                                   exp_assay = "normalizedCounts",
                                   normalize = FALSE)
#> calculating TF activity from regulon using weightedmean
#> Warning in calculateActivity(expMatrix = GeneExpressionMatrix, regulon =
#> regulon.w, : The weight column contains multiple subcolumns but no cluster
#> information was provided. Using first column to compute activity...
#> aggregating regulons...
#> creating weight matrix...
#> calculating activity scores...
#> normalize by the number of targets...

score.combine[1:5,1:5]
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#>        reprogram#TTAGGAACAAGGTACG-1 reprogram#GAGCGGTCAACCTGGT-1
#> AR                      0.043269067                   0.05990426
#> FOXA1                   0.035230591                   0.04406452
#> FOXA2                   0.008868738                   0.04479888
#> GATA6                   0.033783968                   0.13927846
#> NKX2-1                  0.064753874                   0.02838985
#>        reprogram#TTATAGCCACCCTCAC-1 reprogram#TGGTGATTCCTGTTCA-1
#> AR                       0.02726117                   0.03401218
#> FOXA1                    0.01707489                   0.01827346
#> FOXA2                    0.01153884                   0.01998275
#> GATA6                    0.01662905                   0.01899377
#> NKX2-1                   0.01398469                   0.01015379
#>        reprogram#TCGGTTCTCACTAGGT-1
#> AR                       0.04009311
#> FOXA1                    0.03426071
#> FOXA2                    0.01368200
#> GATA6                    0.02897034
#> NKX2-1                   0.05320529

5 Session Info

sessionInfo()
#> R Under development (unstable) (2024-03-18 r86148)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 22.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB              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       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] BSgenome.Hsapiens.UCSC.hg38_1.4.5 BSgenome_1.71.2                  
#>  [3] rtracklayer_1.63.1                BiocIO_1.13.0                    
#>  [5] Biostrings_2.71.4                 XVector_0.43.1                   
#>  [7] scMultiome_1.3.0                  MultiAssayExperiment_1.29.1      
#>  [9] ExperimentHub_2.11.1              AnnotationHub_3.11.3             
#> [11] BiocFileCache_2.11.1              dbplyr_2.5.0                     
#> [13] epiregulon_0.99.6                 SingleCellExperiment_1.25.0      
#> [15] SummarizedExperiment_1.33.3       Biobase_2.63.0                   
#> [17] GenomicRanges_1.55.4              GenomeInfoDb_1.39.9              
#> [19] IRanges_2.37.1                    S4Vectors_0.41.5                 
#> [21] BiocGenerics_0.49.1               MatrixGenerics_1.15.0            
#> [23] matrixStats_1.2.0                 BiocStyle_2.31.0                 
#> 
#> loaded via a namespace (and not attached):
#>   [1] bitops_1.0-7                filelock_1.0.3             
#>   [3] R.oo_1.26.0                 tibble_3.2.1               
#>   [5] XML_3.99-0.16.1             DirichletMultinomial_1.45.0
#>   [7] lifecycle_1.0.4             edgeR_4.1.18               
#>   [9] lattice_0.22-6              backports_1.4.1            
#>  [11] magrittr_2.0.3              limma_3.59.6               
#>  [13] sass_0.4.9                  rmarkdown_2.26             
#>  [15] jquerylib_0.1.4             yaml_2.3.8                 
#>  [17] metapod_1.11.1              cowplot_1.1.3              
#>  [19] DBI_1.2.2                   CNEr_1.39.0                
#>  [21] abind_1.4-5                 zlibbioc_1.49.3            
#>  [23] R.utils_2.12.3              purrr_1.0.2                
#>  [25] RCurl_1.98-1.14             pracma_2.4.4               
#>  [27] rappdirs_0.3.3              GenomeInfoDbData_1.2.11    
#>  [29] ggrepel_0.9.5               irlba_2.3.5.1              
#>  [31] seqLogo_1.69.0              annotate_1.81.2            
#>  [33] dqrng_0.3.2                 DelayedMatrixStats_1.25.1  
#>  [35] codetools_0.2-19            DelayedArray_0.29.9        
#>  [37] scuttle_1.13.1              tidyselect_1.2.1           
#>  [39] farver_2.1.1                ScaledMatrix_1.11.1        
#>  [41] viridis_0.6.5               GenomicAlignments_1.39.4   
#>  [43] jsonlite_1.8.8              BiocNeighbors_1.21.2       
#>  [45] motifmatchr_1.25.0          scater_1.31.2              
#>  [47] tools_4.4.0                 TFMPvalue_0.0.9            
#>  [49] Rcpp_1.0.12                 glue_1.7.0                 
#>  [51] gridExtra_2.3               SparseArray_1.3.4          
#>  [53] xfun_0.42                   dplyr_1.1.4                
#>  [55] HDF5Array_1.31.6            withr_3.0.0                
#>  [57] BiocManager_1.30.22         fastmap_1.1.1              
#>  [59] rhdf5filters_1.15.4         bluster_1.13.0             
#>  [61] fansi_1.0.6                 caTools_1.18.2             
#>  [63] digest_0.6.35               rsvd_1.0.5                 
#>  [65] R6_2.5.1                    mime_0.12                  
#>  [67] colorspace_2.1-0            GO.db_3.18.0               
#>  [69] gtools_3.9.5                poweRlaw_0.80.0            
#>  [71] RSQLite_2.3.5               R.methodsS3_1.8.2          
#>  [73] utf8_1.2.4                  generics_0.1.3             
#>  [75] httr_1.4.7                  S4Arrays_1.3.6             
#>  [77] TFBSTools_1.41.0            pkgconfig_2.0.3            
#>  [79] gtable_0.3.4                blob_1.2.4                 
#>  [81] htmltools_0.5.7             bookdown_0.38              
#>  [83] scales_1.3.0                png_0.1-8                  
#>  [85] scran_1.31.3                knitr_1.45                 
#>  [87] tzdb_0.4.0                  reshape2_1.4.4             
#>  [89] rjson_0.2.21                checkmate_2.3.1            
#>  [91] curl_5.2.1                  cachem_1.0.8               
#>  [93] rhdf5_2.47.6                stringr_1.5.1              
#>  [95] BiocVersion_3.19.1          parallel_4.4.0             
#>  [97] vipor_0.4.7                 AnnotationDbi_1.65.2       
#>  [99] restfulr_0.0.15             pillar_1.9.0               
#> [101] grid_4.4.0                  vctrs_0.6.5                
#> [103] BiocSingular_1.19.0         beachmat_2.19.1            
#> [105] xtable_1.8-4                cluster_2.1.6              
#> [107] beeswarm_0.4.0              evaluate_0.23              
#> [109] readr_2.1.5                 magick_2.8.3               
#> [111] cli_3.6.2                   locfit_1.5-9.9             
#> [113] compiler_4.4.0              Rsamtools_2.19.4           
#> [115] rlang_1.1.3                 crayon_1.5.2               
#> [117] labeling_0.4.3              plyr_1.8.9                 
#> [119] ggbeeswarm_0.7.2            stringi_1.8.3              
#> [121] viridisLite_0.4.2           BiocParallel_1.37.1        
#> [123] munsell_0.5.0               Matrix_1.6-5               
#> [125] hms_1.1.3                   sparseMatrixStats_1.15.0   
#> [127] bit64_4.0.5                 ggplot2_3.5.0              
#> [129] Rhdf5lib_1.25.1             KEGGREST_1.43.0            
#> [131] statmod_1.5.0               highr_0.10                 
#> [133] igraph_2.0.3                memoise_2.0.1              
#> [135] bslib_0.6.1                 bit_4.0.5