14.3 Custom Enrichment

In addition to all of these curated annotation sets, ArchR is also capable of accepting user-defined annotations to perform custom enrichments. In the below example, we illustrate how to create a custom annotation based on select ENCODE ChIP-seq experiments.

First, we will define the datasets that will be used and provide links for their download. Local files could be used in the same way.

EncodePeaks <- c(
  Encode_K562_GATA1 = "https://www.encodeproject.org/files/ENCFF632NQI/@@download/ENCFF632NQI.bed.gz",
  Encode_GM12878_CEBPB = "https://www.encodeproject.org/files/ENCFF761MGJ/@@download/ENCFF761MGJ.bed.gz",
  Encode_K562_Ebf1 = "https://www.encodeproject.org/files/ENCFF868VSY/@@download/ENCFF868VSY.bed.gz",
  Encode_K562_Pax5 = "https://www.encodeproject.org/files/ENCFF339KUO/@@download/ENCFF339KUO.bed.gz"
)

We then add a custom annotation to our ArchRProject using the addPeakAnnotation() function. Here, we call our custom annotation “ChIP”.

projHeme5 <- addPeakAnnotations(ArchRProj = projHeme5, regions = EncodePeaks, name = "ChIP")
## ArchR logging to : ArchRLogs/ArchR-addPeakAnnotations-371b01c1d7329-Date-2022-12-23_Time-08-00-00.log
## If there is an issue, please report to github with logFile!
## 2022-12-23 08:00:03 : Creating Peak Overlap Matrix, 0.051 mins elapsed.
## 2022-12-23 08:00:04 : All Regions Overlap at least 1 peak!, 0.053 mins elapsed.

As before, we use this custom annotation to perform the peak annotation enrichment using peakAnnoEnrichment() and follow the same steps to create our annotation heatmap.

enrichRegions <- peakAnnoEnrichment(
    seMarker = markerPeaks,
    ArchRProj = projHeme5,
    peakAnnotation = "ChIP",
    cutOff = "FDR <= 0.1 & Log2FC >= 0.5"
  )
## ArchR logging to : ArchRLogs/ArchR-peakAnnoEnrichment-371b03da1b1c9-Date-2022-12-23_Time-08-00-04.log
## If there is an issue, please report to github with logFile!
## 2022-12-23 08:00:09 : Computing Enrichments 1 of 11, 0.082 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 2 of 11, 0.083 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 3 of 11, 0.084 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 4 of 11, 0.084 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 5 of 11, 0.085 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 6 of 11, 0.085 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 7 of 11, 0.086 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 8 of 11, 0.086 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 9 of 11, 0.087 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 10 of 11, 0.087 mins elapsed.
## 2022-12-23 08:00:09 : Computing Enrichments 11 of 11, 0.088 mins elapsed.
## ArchR logging successful to : ArchRLogs/ArchR-peakAnnoEnrichment-371b03da1b1c9-Date-2022-12-23_Time-08-00-04.log
enrichRegions
## class: SummarizedExperiment 
## dim: 4 11 
## metadata(0):
## assays(10): mlog10Padj mlog10p ... CompareFrequency feature
## rownames(4): Encode_K562_GATA1 Encode_GM12878_CEBPB Encode_K562_Ebf1
##   Encode_K562_Pax5
## rowData names(0):
## colnames(11): B CD4.M ... PreB Progenitor
## colData names(0):
heatmapRegions <- plotEnrichHeatmap(enrichRegions, n = 7, transpose = TRUE)
## ArchR logging to : ArchRLogs/ArchR-plotEnrichHeatmap-371b0fb4fe74-Date-2022-12-23_Time-08-00-09.log
## If there is an issue, please report to github with logFile!
## Adding Annotations..
## Preparing Main Heatmap..
## 'magick' package is suggested to install to give better rasterization.
## 
## Set `ht_opt$message = FALSE` to turn off this message.
ComplexHeatmap::draw(heatmapRegions, heatmap_legend_side = "bot", annotation_legend_side = "bot")

To save an editable vectorized version of this plot, we use the plotPDF() function.

plotPDF(heatmapRegions, name = "Regions-Enriched-Marker-Heatmap", width = 8, height = 6, ArchRProj = projHeme5, addDOC = FALSE)
## Plotting ComplexHeatmap!