Date: 2026-04-28

# ‘Motif2Site’: an R package to detect binding sites from ChIP-seq and recenter them

Peyman Zarrineh1*

1The University of Manchester

*peyman.zarrineh@manchester.ac.uk

#### April 28, 2026

#### Abstract

‘Motif2Site’ is an R package to detect transcription factor binding sites from motif sets and ChIP-seq experiments. The motif sets are either user provided bed files or user provided DNA nucleotide sequence motifs. It also combines andcompares binding sites of a transcription factor across various experiments and conditions.

#### Package

Motif2Site 1.16.0

# Contents

# 1 Introduction

Transcription factors often bind to specific DNA nucleotide patterns referred to as sequence motifs. Although sequence motifs are well-characterized for many transcription factors, detecting the actual binding sites is not always a straightforward task. Chromatin immunoprecipitation (ChIP) followed by DNA sequencing (ChIP-seq) is the major technology to detect binding regions of transcription factors. However, the binding regions detected by ChIP-seq may contains several or no DNA sequence motifs. Motif2Site is a novel R package which uses ChIP-seq information and detect transcription factor binding sites from a user provided DNA sequence motifs set.

Motif2Site gets two different input, motif and ChIP-seq alignment information, to detect binding sites. First input is ChIP-seq alignment short reads in the bam or bed format. For each aligned short read the center of the alignment is calculated using GenomicAlignments (Lawrence et al. 2013) and Rsamtools (Morgan et al. 2020) packages. Motif information is the second input which is provided by user either as a bed file or a DNA string with a mismatch number. In the case of DNA string input, Biostrings (H. Pagès et al. 2019) and BSgenome (Hervé Pagès 2019) packages are used to find motif locations on the genome in GenomicRanges (Lawrence et al. 2013) format.

Negative binomial distribution is used to model count data by using edgeR package (Robinson, McCarthy, and Smyth 2010). mixtools (Benaglia et al. 2009) is used to deconvolve binding intensities of closely spaced binding sites. Motif2Site also combines binding sites across different experiments. It calls differential binding sites using TMM normalization and GLM test using edgeR package (Robinson, McCarthy, and Smyth 2010).

# 2 Major functions of Motif2Site

First install and load the libraries needed to run the examples of this document:

    library(GenomicRanges)
    library(Motif2Site)
    library(BSgenome.Scerevisiae.UCSC.sacCer3)
    library(BSgenome.Ecoli.NCBI.20080805)

The functions, implemented in Motif2Site, perform three tasks: 1. To assist users to select better sequence motif input. 2. To detect binding sites from sequence motifs and ChIP-seq datasets 3. To combine and compare binding sites across different experiments, conditions, or tissues. Each of these functions are explained in a separate section.

# 3 Selecting sequence motif

Motif2Site uses DNA motif information as one of its input. To facilitate choosing proper sequence motif, `compareBedFiless2UserProvidedRegions` and `compareMotifs2UserProvidedRegions` functions compare motif regions with a user provided confident regions in terms of precision and recall.

As the first example, an artificially generated “YeastSampleMotif.bed” bed file in yeast is considered as a confident binding regions set. `compareMotifs2UserProvidedRegions` function compares these regions with locations of ‘TGATTSCAGGANT’ 1-mismatch, ‘TGATTCCAGGANT’ 0-mismatch, ‘TGATWSCAGGANT’ 2-mismatches on the yeast genome in terms of precision and recall.

    yeastExampleFile =
      system.file("extdata", "YeastSampleMotif.bed", package="Motif2Site")
    YeastRegionsChIPseq <- Bed2Granges(yeastExampleFile)
    SequenceComparison <-
      compareMotifs2UserProvidedRegions(
        givenRegion=YeastRegionsChIPseq,
        motifs = c("TGATTSCAGGANT", "TGATTCCAGGANT", "TGATWSCAGGANT"),
        mismatchNumbers = c(1,0,2),
        genome="Scerevisiae",
        genomeBuild="sacCer3"
        )

    SequenceComparison

    ##                 motifName regionCoverage motifCoverage
    ## 1 TGATTSCAGGANT_1mismatch    0.350877193     0.6060606
    ## 2 TGATTCCAGGANT_0mismatch    0.005847953     1.0000000
    ## 3 TGATWSCAGGANT_2mismatch    1.000000000     0.0475132

In the following example, an artificially generated “YeastSampleMotif.bed” bed file in yeast is considered as a confident binding regions set. `compareBedFiless2UserProvidedRegions` function compares these regions with two bed files “YeastBedFile1.bed” and “YeastBedFile2.bed” in terms of precision and recall.

    # Yeast artificial dataset for comparison bed files

    yeastExampleFile =
      system.file("extdata", "YeastSampleMotif.bed", package="Motif2Site")
    YeastRegionsChIPseq <- Bed2Granges(yeastExampleFile)
    bed1 <- system.file("extdata", "YeastBedFile1.bed", package="Motif2Site")
    bed2 <- system.file("extdata", "YeastBedFile2.bed", package="Motif2Site")
    BedFilesVector <- c(bed1, bed2)
    SequenceComparison <-
      compareBedFiless2UserProvidedRegions(
        givenRegion=YeastRegionsChIPseq,
        bedfiles = BedFilesVector,
        motifnames = c("YeastBed1", "YeastBed2")
        )

    SequenceComparison

    ##   motifName regionCoverage motifCoverage
    ## 1 YeastBed1      0.3099415      1.000000
    ## 2 YeastBed2      0.4853801      0.209068

# 4 Detecting binding sites

`DetectBindingSitesMotif` function detects binding sites from provided sequence motif information. Here, Artificial ChIP-seq data for FUR transcription factor in Escherichia coli was generated in two conditions fe2+ and dpd inspired by (Seo et al. 2014). In the following examples, artificial sequence motif locations have been and provided as a bed file called ‘FurMotifs.bed’. The alignment of ChIP-seq short reads is the other input of this function. The alignment files can be passed to the function as bam or bed files. In the following examples both IP and background alignment files have been passed as single-end bed files to this function.

    # FUR candidate motifs in NC_000913 E. coli
    FurMotifs = system.file("extdata", "FurMotifs.bed", package="Motif2Site")

    # ChIP-seq FUR fe datasets binding sites from user provided bed file
    # ChIP-seq datasets in bed single end format

    IPFe <- c(system.file("extdata", "FUR_fe1.bed", package="Motif2Site"),
              system.file("extdata", "FUR_fe2.bed", package="Motif2Site"))
    Inputs <- c(system.file("extdata", "Input1.bed", package="Motif2Site"),
                system.file("extdata", "Input2.bed", package="Motif2Site"))
    FURfeBedInputStats <-
      DetectBindingSitesBed(BedFile=FurMotifs,
                            IPfiles=IPFe,
                            BackgroundFiles=Inputs,
                            genome="Ecoli",
                            genomeBuild="20080805",
                            DB="NCBI",
                            expName="FUR_Fe_BedInput",
                            format="BEDSE"
                            )
    FURfeBedInputStats

    ## $FRiP
    ## [1] 0.3668289 0.1997165
    ##
    ## $sequencingStatitic
    ##   nonSequenced underBinding overBinding
    ## 1   0.02293399            0 0.005022041
    ##
    ## $motifStatistics
    ##   skewnessTestRejected decompositionRejected accepted
    ## 1                   98                    59      192

    # ChIP-seq FUR dpd datasets binding sites from user provided bed file
    # ChIP-seq datasets in bed single end format

    IPDpd <- c(system.file("extdata", "FUR_dpd1.bed", package="Motif2Site"),
               system.file("extdata", "FUR_dpd2.bed", package="Motif2Site"))
    FURdpdBedInputStats <-
      DetectBindingSitesBed(BedFile=FurMotifs,
                            IPfiles=IPDpd,
                            BackgroundFiles=Inputs,
                            genome="Ecoli",
                            genomeBuild="20080805",
                            DB="NCBI",
                            expName="FUR_Dpd_BedInput",
                            format="BEDSE"
                            )
    FURdpdBedInputStats

    ## $FRiP
    ## [1] 0.2826046 0.2823270
    ##
    ## $sequencingStatitic
    ##   nonSequenced underBinding overBinding
    ## 1   0.02254338            0 0.005022041
    ##
    ## $motifStatistics
    ##   skewnessTestRejected decompositionRejected accepted
    ## 1                   63                    59      192

`DetectBindingSitesMotif` function also works with DNA string motifs. In the following example, FUR binding sites in fe2+ condition are detected from ‘GWWTGAGAA’ with 1-mismatch motif. The dataset is generated only for ‘NC_000913’ build. Therefore, in this example the coordinates of this regions are provided as a ‘GivenRegion’ field. Providing this field ensures that binding sites are only detected in the given regions. This will accelerate the peak calling, and also improve the prediction accuracy.

    # Granages region for motif search
    NC_000913_Coordiante <- GRanges(seqnames=Rle("NC_000913"),
                                    ranges = IRanges(1, 4639675))

    # ChIP-seq FUR fe datasets binding sites from user provided string motif
    # ChIP-seq datasets in bed single end format

    FURfeStringInputStats <-
      DetectBindingSitesMotif(motif = "GWWTGAGAA",
                              mismatchNumber = 1,
                              IPfiles=IPFe,
                              BackgroundFiles=Inputs,
                              genome="Ecoli",
                              genomeBuild="20080805",
                              DB= "NCBI",
                              expName="FUR_Fe_StringInput",
                              format="BEDSE",
                              GivenRegion = NC_000913_Coordiante
                              )
    FURfeStringInputStats

    ## $FRiP
    ## [1] 0.07620002 0.08057296
    ##
    ## $sequencingStatitic
    ##   nonSequenced underBinding overBinding
    ## 1   0.02464332            0 0.003891051
    ##
    ## $motifStatistics
    ##   skewnessTestRejected decompositionRejected accepted
    ## 1                    3                     2       36

# 5 Combining binding sites across experiments

`recenterBindingSitesAcrossExperiments` function combines the binding sites of different tissues or conditions into a single count matrix. In the FUR example, at the first step it combines fe2+ and dpd binding sites. At the next step, it recalculates the p-adjusted values. To ensure the high quality of the combined binding site set, an stringent cross-experiment FDR cutoff is applied (default 0.001). The accepted binding sites should fullfill this cutoff at least in one experiment. Another FDR cutoff value (default 0.05) is used to assign binding or non-binding labels to each binding site for each experiment.

    # Combine FUR binding sites from bed input into one table
    corMAT <- recenterBindingSitesAcrossExperiments(
      expLocations=c("FUR_Fe_BedInput","FUR_Dpd_BedInput"),
      experimentNames=c("FUR_Fe","FUR_Dpd"),
      expName="combinedFUR"
      )
    corMAT

    ##             FUR_Fe     FUR_Fe    FUR_Dpd    FUR_Dpd
    ## FUR_Fe   1.0000000  0.4135960 -0.4306805 -0.3712371
    ## FUR_Fe   0.4135960  1.0000000 -0.4787001 -0.4365536
    ## FUR_Dpd -0.4306805 -0.4787001  1.0000000  0.7266292
    ## FUR_Dpd -0.3712371 -0.4365536  0.7266292  1.0000000

    FurTable <-
      read.table(file.path("combinedFUR","CombinedMatrix"),
                 header = TRUE,
                  check.names = FALSE
                 )
    FurBindingTotal <-
      GRanges(seqnames=Rle(FurTable[,1]),
              ranges = IRanges(FurTable[,2], FurTable[,3])
              )
    FurFe <- FurBindingTotal[which((FurTable$FUR_Fe_binding =="Binding")==TRUE)]
    FurDpd <- FurBindingTotal[which((FurTable$FUR_Dpd_binding =="Binding")==TRUE)]
    findOverlaps(FurFe,FurDpd)

    ## Hits object with 104 hits and 0 metadata columns:
    ##         queryHits subjectHits
    ##         <integer>   <integer>
    ##     [1]         1           1
    ##     [2]         7           5
    ##     [3]         9           7
    ##     [4]        10           8
    ##     [5]        16          10
    ##     ...       ...         ...
    ##   [100]       200         185
    ##   [101]       201         186
    ##   [102]       202         187
    ##   [103]       203         188
    ##   [104]       205         190
    ##   -------
    ##   queryLength: 208 / subjectLength: 191

`pairwisDifferential` function uses edgeR TMM normalization and GLM test to detect differential binding sites across two experiments. In the following example it takes combined FUR count matrix and detect differential binding sites across fe2+ and dpd.

    # Differential binding sites across FUR conditions fe vs dpd
    diffFUR <- pairwisDifferential(tableOfCountsDir="combinedFUR",
                                  exp1="FUR_Fe",
                                  exp2="FUR_Dpd",
                                  FDRcutoff = 0.05,
                                  logFCcuttoff = 1
                                  )
    FeUp <- diffFUR[[1]]
    DpdUp <- diffFUR[[2]]
    TotalComparison <- diffFUR[[3]]
    head(TotalComparison)

    ##    seqnames  start    end      logFC   logCPM         LR     PValue
    ## 1 NC_000913   8346   8355  0.3544662 11.75555 0.04482902 0.83231874
    ## 2 NC_000913  58862  58874  7.7183451 11.56126 8.89912689 0.00285307
    ## 3 NC_000913  70508  70516  5.4556744 11.84325 6.73983391 0.00942834
    ## 4 NC_000913 111527 111535  5.0124893 11.47762 4.79052209 0.02861675
    ## 5 NC_000913 146492 146501 -6.8521148 10.83546 5.34414287 0.02079200
    ## 6 NC_000913 167150 167158 -4.4631807 11.42447 3.95981339 0.04659887

# 6 Session Info

    sessionInfo()

    ## R version 4.6.0 Patched (2026-04-24 r89963)
    ## Platform: aarch64-apple-darwin23
    ## Running under: macOS Tahoe 26.3.1
    ##
    ## Matrix products: default
    ## BLAS:   /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib
    ## LAPACK: /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
    ##
    ## locale:
    ## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    ##
    ## time zone: America/New_York
    ## tzcode source: internal
    ##
    ## attached base packages:
    ## [1] stats4    stats     graphics  grDevices utils     datasets  methods
    ## [8] base
    ##
    ## other attached packages:
    ##  [1] BSgenome.Ecoli.NCBI.20080805_1.3.1000
    ##  [2] BSgenome.Scerevisiae.UCSC.sacCer3_1.4.0
    ##  [3] BSgenome_1.80.0
    ##  [4] rtracklayer_1.72.0
    ##  [5] BiocIO_1.22.0
    ##  [6] Biostrings_2.80.0
    ##  [7] XVector_0.52.0
    ##  [8] Motif2Site_1.16.0
    ##  [9] GenomicRanges_1.64.0
    ## [10] Seqinfo_1.2.0
    ## [11] IRanges_2.46.0
    ## [12] S4Vectors_0.50.0
    ## [13] BiocGenerics_0.58.0
    ## [14] generics_0.1.4
    ## [15] BiocStyle_2.40.0
    ##
    ## loaded via a namespace (and not attached):
    ##  [1] tidyselect_1.2.1            viridisLite_0.4.3
    ##  [3] dplyr_1.2.1                 farver_2.1.2
    ##  [5] mixtools_2.0.0.1            S7_0.2.2
    ##  [7] bitops_1.0-9                lazyeval_0.2.3
    ##  [9] fastmap_1.2.0               RCurl_1.98-1.18
    ## [11] GenomicAlignments_1.48.0    XML_3.99-0.23
    ## [13] digest_0.6.39               lifecycle_1.0.5
    ## [15] survival_3.8-6              statmod_1.5.1
    ## [17] kernlab_0.9-33              magrittr_2.0.5
    ## [19] compiler_4.6.0              rlang_1.2.0
    ## [21] sass_0.4.10                 tools_4.6.0
    ## [23] yaml_2.3.12                 data.table_1.18.2.1
    ## [25] knitr_1.51                  htmlwidgets_1.6.4
    ## [27] S4Arrays_1.12.0             curl_7.1.0
    ## [29] DelayedArray_0.38.0         RColorBrewer_1.1-3
    ## [31] abind_1.4-8                 BiocParallel_1.46.0
    ## [33] purrr_1.2.2                 grid_4.6.0
    ## [35] edgeR_4.10.0                ggplot2_4.0.3
    ## [37] scales_1.4.0                MASS_7.3-65
    ## [39] dichromat_2.0-0.1           tinytex_0.59
    ## [41] SummarizedExperiment_1.42.0 cli_3.6.6
    ## [43] rmarkdown_2.31              crayon_1.5.3
    ## [45] otel_0.2.0                  httr_1.4.8
    ## [47] rjson_0.2.23                cachem_1.1.0
    ## [49] splines_4.6.0               parallel_4.6.0
    ## [51] BiocManager_1.30.27         restfulr_0.0.16
    ## [53] matrixStats_1.5.0           vctrs_0.7.3
    ## [55] Matrix_1.7-5                jsonlite_2.0.0
    ## [57] bookdown_0.46               magick_2.9.1
    ## [59] locfit_1.5-9.12             limma_3.68.0
    ## [61] plotly_4.12.0               tidyr_1.3.2
    ## [63] jquerylib_0.1.4             glue_1.8.1
    ## [65] codetools_0.2-20            gtable_0.3.6
    ## [67] GenomeInfoDb_1.48.0         UCSC.utils_1.8.0
    ## [69] tibble_3.3.1                pillar_1.11.1
    ## [71] htmltools_0.5.9             R6_2.6.1
    ## [73] evaluate_1.0.5              lattice_0.22-9
    ## [75] Biobase_2.72.0              Rsamtools_2.28.0
    ## [77] cigarillo_1.2.0             segmented_2.2-1
    ## [79] bslib_0.10.0                Rcpp_1.1.1-1.1
    ## [81] nlme_3.1-169                SparseArray_1.12.0
    ## [83] xfun_0.57                   pkgconfig_2.0.3
    ## [85] MatrixGenerics_1.24.0

# References

Benaglia, T., D. Chauveau, D. R. Hunter, and D. Young. 2009. “mixtools: An R Package for Analyzing Finite Mixture Models.” Journal of Statistical Software 32 (6): 1–29. http://www.jstatsoft.org/v32/i06/.
Lawrence, M., W. Huber, H. Pagès, P. Aboyoun, M. Carlson, R. Gentleman, M. Morgan, and V. Carey. 2013. “Software for Computing and Annotating Genomic Ranges.” PLoS Computational Biology 9. https://doi.org/10.1371/journal.pcbi.1003118.
Morgan, M., H. Pagès, V. Obenchain, and N. Hayden. 2020. Rsamtools: Binary Alignment (BAM), FASTA, Variant Call (BCF), and Tabix File Import. http://bioconductor.org/packages/Rsamtools.
Pagès, H., P. Aboyoun, R. Gentleman, and S. DebRoy. 2019. Biostrings: Efficient Manipulation of Biological Strings.
Pagès, Hervé. 2019. BSgenome: Software Infrastructure for Efficient Representation of Full Genomes and Their SNPs.
Robinson, M. D., D. J. McCarthy, and G. K. Smyth. 2010. “edgeR: A Bioconductor Package for Differential Expression Analysis of Digital Gene Expression Data.” Bioinformatics 26 (1): 139–40. https://doi.org/10.1093/bioinformatics/btp616.
Seo, S. W., D. Kim, H. Latif, et al. 2014. “Deciphering Fur Transcriptional Regulatory Network Highlights Its Complex Role Beyond Iron Metabolism in Escherichia Coli.” Nature Communications 5. https://doi.org/10.1038/ncomms5910.