# fourSynergy

# Introduction

Circular Chromosome Conformation Capture Sequencing (4C-seq) is a sequencing technique enabling the identification of chromatin interactions. Currently, there are several tools available for 4C-seq analysis:

- r3Cseq
- fourSig (https://doi.org/10.1093/nar/gku156)
- FourCSeq (https://doi.org/10.1093/bioinformatics/btv335) (deprecated)
- peakC (https://doi.org/10.1093/nar/gky443)
- R.4Cker (https://doi.org/10.1371/journal.pcbi.1004780)

A benchmarking of those tools revealed that none of the tools performed adequately in all evaluated tasks (Walter et al. 2019). To address this we developed fourSynergy, a ensemble algorithm that leverages synergies between the base tools r3cseq, fourSig, peakC, and R.4cker. To this end, all of these tools need to be run, which can be achieved using the fourSynergy pipeline. This pipeline, written in snakemake, includes quality control, interaction calling, and post-processing steps to prepare the output of the base tools for the ensemble algorithm.

# Requirements

If you want to quickly start with testing the package you can jump to the section R analysis and run the fourSynergy R package on testdata.

## Pipeline

- snakemake installation

We recommend the pipeline to be executed in a docker.

# Running fourSynergy

## Installation

fourSynergy can be installed as follows:

    BiocManager::install("fourSynergy")

## Requirements

To run fourSynergy, you need R (Version 4.5 or higher).

## Getting started

A basic workflow of 4C-seq data is demonstrated in the following on an exemplary dataset. First, we need to run the fourSynergy pipeline.

If you want to quickly start with testing the package you can jump to the section R analysis and run the fourSynergy R package on testdata.

## fourSynergy Pipeline

Before starting the R analysis you have to run the fourSynergy snakemake pipeline, which is available at (https://github.com/sophiewind/fourSynergy_pip).

### Input

Input for the fourSynergy pipeline are…

- 4C-seq FASTQ files

- config.yaml

- Reference genome

#### config

The config file is crucial to run fourSynergy. All relevant experimental information is stored here. You can find an exemplary info.yaml in `inst/extdata/Datasets/Demo/info.yaml`.

### Output

The pipeline creates a results directory in the directory were its executed. In the results directory is a directory called like the `author` provided in the config file. In this directory, all results of the base tools and fourSynergy are written.

    ├── Datasets
    ├── ...
    └── results
        └── author
            ├── alignment   -> alignment results
            ├── basic4Cseq  -> Basic4Cseq results
            ├── foursig     -> fourSig results
            ├── peakC       -> peakC results
            ├── qc          -> FASTQC results
            ├── r3cseq      -> r3Cseq results
            ├── r4cker      -> R.4Cker results
            └── sia         -> standardized tools results

# R analysis

After the pipeline is executed we can start with the analysis in R by loading the fourSynergy R package.

    library(fourSynergy)

## Load data

Than the pipeline results can be loaded into an fourSynergy object. In the provided example, `config` and the pathes are stored in extdata. However, in a real-world scenario, `res_path` would typically be located in `./results/[DatasetName]` and the `tracks` in `./results/[DatasetName]/alignment`.

    # Load config
    config <- system.file("extdata", "Datasets", "Demo", "info.yaml",
        package = "fourSynergy"
    )

    # Load results path
    res_path <- system.file("extdata", "results", "Demo",
        package = "fourSynergy"
    )

    # Load path of .bedGraphs
    tracks <- system.file("extdata", "results", "Demo", "alignment",
        package = "fourSynergy"
    )
    sia <- createIa(
        res_path = res_path,
        config = config,
        tracks = tracks
    )

The fourSynergy object stores information about the single tool calls in condition and in control as well as metadata.

Slot | Data
--- | ---
metadata | Metadata from config
expInteractions | Base tool results - experiment
ctrlInteractions | Base tool results - control
expConsensus | Ensemble results - experiment
ctrlConsensus | Ensemble results - control
vp | Viewpoint position
vfl | Virtual fragment library (VFL)
tracks | Path of .bedGraphs
differential | Differential ensemble results

## Base tool results

The base tool results are stored in the fourSynergy object in the slots `expInteractions` and `ctrlInteractions`.

    slotNames(sia)
    #>  [1] "metadata"         "expInteractions"  "ctrlInteractions" "expConsensus"
    #>  [5] "ctrlConsensus"    "vp"               "vfl"              "tracks"
    #>  [9] "differential"     "dds"

They can be visualized using `plotIaIndiviualTools()`. There is also the object to pass genes of interest, which are than shown in the karyoplot.

    plotIaIndiviualTools(sia, genes_of_interest = c("Ldlrad4", "Cep76"))

Further, the base tool results can be visualized in higher resolution using `plotBaseTracks()`.

    plotBaseTracks(sia)
    #> [[1]]

    #>
    #> [[2]]

## Ensemble results

To perform ensemble calling you need to specify if you want to use the F1 or the AUPRC model.

    sia <- consensusIa(sia, model = "AUPRC")
    #> Starting ensemble algorithm...

The ensemble results can than be visualized.

    plotConsensusIa(ia = sia)

The consensus results can be visualized in higher resolution using `plotConsensusTracks()`.

    plotConsensusTracks(sia)
    #> [[1]]

    #>
    #> [[2]]

## Differential interaction analysis

fourSynergy provides differential interaction analysis to compare interactions across conditions. The differential interaction analysis is based on DESeq2 using count data to model the variability in the data using a negative binomial distribution. In the example dataset the `fitType` was set to ‘mean’, by default this value is ‘local’.

(The plots do not look representative here because the BAM file size has been drastically reduced for this example.)

    sia <- differentialAnalysis(ia = sia, fitType = "mean")
    #> Processing /tmp/RtmpluMT0X/Rinst1caf6cb2b0e4/fourSynergy/extdata/results/Demo/alignment/TGFb_1_sorted.bam: fOr brOoMmHiLdA!!!
    #> Processing /tmp/RtmpluMT0X/Rinst1caf6cb2b0e4/fourSynergy/extdata/results/Demo/alignment/TGFb_2_sorted.bam: yOu cAn'T pIlE-Up FaStEr!!!
    #> Processing /tmp/RtmpluMT0X/Rinst1caf6cb2b0e4/fourSynergy/extdata/results/Demo/alignment/shc_1_sorted.bam: I'M gOnNa cHaSe'em and PiLe'em aLl up!!!
    #> Processing /tmp/RtmpluMT0X/Rinst1caf6cb2b0e4/fourSynergy/extdata/results/Demo/alignment/shc_2_sorted.bam: tHaT'S tHa fAStEsT pIlE-uP bAm iN tHe SoUth!!!
    #> Warning in DESeqDataSet(se, design = design, ignoreRank): some variables in
    #> design formula are characters, converting to factors
    #> gene-wise dispersion estimates
    #> mean-dispersion relationship
    #> final dispersion estimates

The results of the differential analysis are stored in the `@differential` slot of the `sia` object and can be visualized using `plotDiffIa()`.

    plotDiffIa(ia = sia, genes_of_interest = c("Ldlrad4", "Cep76"))

    sessionInfo()
    #> R version 4.6.0 (2026-04-24)
    #> Platform: x86_64-pc-linux-gnu
    #> Running under: Ubuntu 24.04.4 LTS
    #>
    #> Matrix products: default
    #> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
    #> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
    #>
    #> locale:
    #>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    #>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
    #>  [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: Etc/UTC
    #> tzcode source: system (glibc)
    #>
    #> attached base packages:
    #> [1] stats4    stats     graphics  grDevices utils     datasets  methods
    #> [8] base
    #>
    #> other attached packages:
    #>  [1] org.Mm.eg.db_3.23.0  AnnotationDbi_1.75.0 Biobase_2.73.1
    #>  [4] fourSynergy_1.1.0    GenomicRanges_1.65.0 Seqinfo_1.3.0
    #>  [7] IRanges_2.47.0       S4Vectors_0.51.1     BiocGenerics_0.59.0
    #> [10] generics_0.1.4       BiocStyle_2.41.0
    #>
    #> loaded via a namespace (and not attached):
    #>   [1] DBI_1.3.0
    #>   [2] bitops_1.0-9
    #>   [3] gridExtra_2.3
    #>   [4] rlang_1.2.0
    #>   [5] magrittr_2.0.5
    #>   [6] biovizBase_1.61.0
    #>   [7] matrixStats_1.5.0
    #>   [8] compiler_4.6.0
    #>   [9] RSQLite_2.4.6
    #>  [10] GenomicFeatures_1.65.0
    #>  [11] png_0.1-9
    #>  [12] vctrs_0.7.3
    #>  [13] reshape2_1.4.5
    #>  [14] ProtGenerics_1.45.0
    #>  [15] stringr_1.6.0
    #>  [16] pkgconfig_2.0.3
    #>  [17] crayon_1.5.3
    #>  [18] fastmap_1.2.0
    #>  [19] backports_1.5.1
    #>  [20] XVector_0.53.0
    #>  [21] labeling_0.4.3
    #>  [22] Rsamtools_2.29.0
    #>  [23] rmarkdown_2.31
    #>  [24] UCSC.utils_1.9.0
    #>  [25] purrr_1.2.2
    #>  [26] bit_4.6.0
    #>  [27] xfun_0.57
    #>  [28] cachem_1.1.0
    #>  [29] cigarillo_1.3.0
    #>  [30] GenomeInfoDb_1.49.0
    #>  [31] jsonlite_2.0.0
    #>  [32] blob_1.3.0
    #>  [33] DelayedArray_0.39.1
    #>  [34] BiocParallel_1.47.0
    #>  [35] cluster_2.1.8.2
    #>  [36] parallel_4.6.0
    #>  [37] VariantAnnotation_1.59.0
    #>  [38] R6_2.6.1
    #>  [39] TxDb.Mmusculus.UCSC.mm10.knownGene_3.10.0
    #>  [40] bezier_1.1.2
    #>  [41] bslib_0.10.0
    #>  [42] stringi_1.8.7
    #>  [43] RColorBrewer_1.1-3
    #>  [44] rtracklayer_1.73.0
    #>  [45] rpart_4.1.27
    #>  [46] jquerylib_0.1.4
    #>  [47] Rcpp_1.1.1-1.1
    #>  [48] SummarizedExperiment_1.43.0
    #>  [49] knitr_1.51
    #>  [50] base64enc_0.1-6
    #>  [51] BiocBaseUtils_1.15.0
    #>  [52] nnet_7.3-20
    #>  [53] Matrix_1.7-5
    #>  [54] tidyselect_1.2.1
    #>  [55] rstudioapi_0.18.0
    #>  [56] dichromat_2.0-0.1
    #>  [57] abind_1.4-8
    #>  [58] yaml_2.3.12
    #>  [59] codetools_0.2-20
    #>  [60] curl_7.1.0
    #>  [61] lattice_0.22-9
    #>  [62] tibble_3.3.1
    #>  [63] plyr_1.8.9
    #>  [64] regioneR_1.45.0
    #>  [65] withr_3.0.2
    #>  [66] KEGGREST_1.53.0
    #>  [67] S7_0.2.2
    #>  [68] evaluate_1.0.5
    #>  [69] foreign_0.8-91
    #>  [70] Biostrings_2.81.1
    #>  [71] karyoploteR_1.38.0
    #>  [72] pillar_1.11.1
    #>  [73] BiocManager_1.30.27
    #>  [74] MatrixGenerics_1.25.0
    #>  [75] checkmate_2.3.4
    #>  [76] TxDb.Hsapiens.UCSC.hg19.knownGene_3.22.1
    #>  [77] RCurl_1.98-1.18
    #>  [78] ensembldb_2.37.0
    #>  [79] ggplot2_4.0.3
    #>  [80] scales_1.4.0
    #>  [81] glue_1.8.1
    #>  [82] lazyeval_0.2.3
    #>  [83] Hmisc_5.2-5
    #>  [84] maketools_1.3.2
    #>  [85] tools_4.6.0
    #>  [86] BiocIO_1.23.3
    #>  [87] data.table_1.18.2.1
    #>  [88] sys_3.4.3
    #>  [89] BSgenome_1.81.0
    #>  [90] locfit_1.5-9.12
    #>  [91] GenomicAlignments_1.49.0
    #>  [92] buildtools_1.0.0
    #>  [93] XML_3.99-0.23
    #>  [94] grid_4.6.0
    #>  [95] tidyr_1.3.2
    #>  [96] colorspace_2.1-2
    #>  [97] htmlTable_2.5.0
    #>  [98] restfulr_0.0.16
    #>  [99] Formula_1.2-5
    #> [100] cli_3.6.6
    #> [101] S4Arrays_1.13.0
    #> [102] dplyr_1.2.1
    #> [103] AnnotationFilter_1.37.0
    #> [104] gtable_0.3.6
    #> [105] DESeq2_1.53.0
    #> [106] sass_0.4.10
    #> [107] digest_0.6.39
    #> [108] SparseArray_1.13.0
    #> [109] htmlwidgets_1.6.4
    #> [110] org.Hs.eg.db_3.23.1
    #> [111] rjson_0.2.23
    #> [112] farver_2.1.2
    #> [113] memoise_2.0.1
    #> [114] htmltools_0.5.9
    #> [115] lifecycle_1.0.5
    #> [116] httr_1.4.8
    #> [117] bit64_4.8.0
    #> [118] bamsignals_1.43.0

Walter, Carolin, Daniel Schuetzmann, Frank Rosenbauer, and Martin Dugas. 2019. “Benchmarking of 4C-Seq Pipelines Based on Real and Simulated Data.” Bioinformatics 35 (23): 4938–45. https://doi.org/10.1093/bioinformatics/btz426.