# **MODIFY THIS CHUNK**
library(here)
kundaje_dir    <- trimws(readr::read_lines(here("code/AK_PROJ_DIR.txt")))
doc_id         <- "02"
out            <- here("output/03-chrombpnet/03-syntax/", doc_id); dir.create(out, recursive = TRUE)
figout         <- here("figures/03-chrombpnet/03-syntax", doc_id, "/"); dir.create(figout, recursive = TRUE)
chrombpnet_dir <- here("output/03-chrombpnet")

1 Overview

In this document we visualize tracks for chromatin accessibility and ChromBPNet products. Plotting of genomic tracks is done with BPCells together with some custom helper functions located in code/utils/track_helpers*.R.

2 Set up

library(dplyr)
library(tidyr)
library(ggplot2)
library(readr)
library(scales)
library(glue)
library(purrr)
library(stringr)
library(ggrepel)
library(ggseqlogo)
library(BPCells)
library(patchwork)
library(ggrastr)
library(BSgenome)
library(BSgenome.Hsapiens.UCSC.hg38)

script_path <- here("code/utils/")
source(file.path(script_path, "plotting_config.R"))
source(file.path(script_path, "hdma_palettes.R"))
source(file.path(script_path, "sj_scRNAseq_helpers.R"))
source(file.path(script_path, "track_helpers_BL.R"))
source(file.path(script_path, "track_helpers_SJ.R"))
source(file.path(script_path, "chrombpnet_utils.R"))

ggplot2::theme_set(theme_BOR())

3 Load data

Cluster metadata

cluster_meta <- read_csv(here("output/05-misc/03/TableS2_cluster_meta_qc.csv")) %>% 
  mutate(Cluster_chrombpnet = Cluster_ChromBPNet)
## Rows: 203 Columns: 19
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (11): Cluster, organ, organ_code, compartment, L1_annot, L2_annot, L3_an...
## dbl  (8): cluster_id, dend_order, ncell, median_numi, median_ngene, median_n...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
organ_map <- cluster_meta %>% distinct(organ, organ_code)
cmap_cluster <- cluster_meta %>% dplyr::select(Cluster_chrombpnet, organ_color) %>% tibble::deframe()

Set params:

finemo_param <- "counts_v0.23_a0.8_all"

4 Load BPCells object

global_bp_obj <- readRDS(here("output/05-misc/01/global_bp_obj.rds"))

head(global_bp_obj$cell_metadata)
##                                     cb Cluster Cluster_chrombpnet   organ
## 1 T318_b16_Adr_PCW21#CL131_E05+G07+B04    AG_0         Adrenal_c0 Adrenal
## 2 T318_b16_Adr_PCW21#CL132_E06+C05+G06    AG_0         Adrenal_c0 Adrenal
## 3 T318_b16_Adr_PCW21#CL131_E06+H08+A07    AG_0         Adrenal_c0 Adrenal
## 4 T318_b16_Adr_PCW21#CL131_E02+D10+G10    AG_0         Adrenal_c0 Adrenal
## 5 T318_b16_Adr_PCW21#CL131_E05+H06+A03    AG_0         Adrenal_c0 Adrenal
## 6 T318_b16_Adr_PCW21#CL131_E11+D02+G02    AG_0         Adrenal_c0 Adrenal
##   organ_code nFrags              L1_annot               L2_annot       L3_annot
## 1         AG  11499 AG_0_adrenal cortex 1 Adrenal adrenal cortex adrenal cortex
## 2         AG   4449 AG_0_adrenal cortex 1 Adrenal adrenal cortex adrenal cortex
## 3         AG  13058 AG_0_adrenal cortex 1 Adrenal adrenal cortex adrenal cortex
## 4         AG  11339 AG_0_adrenal cortex 1 Adrenal adrenal cortex adrenal cortex
## 5         AG   6374 AG_0_adrenal cortex 1 Adrenal adrenal cortex adrenal cortex
## 6         AG  11742 AG_0_adrenal cortex 1 Adrenal adrenal cortex adrenal cortex
##   cluster_id compartment archive_L1_clusterID archive_L1_clusterName
## 1          0         epi                    0                 AG_epi
## 2          0         epi                    0                 AG_epi
## 3          0         epi                    0                 AG_epi
## 4          0         epi                    0                 AG_epi
## 5          0         epi                    0                 AG_epi
## 6          0         epi                    0                 AG_epi
##   archive_L2_clusterID archive_L2_clusterName archive_L3_clusterName
## 1              AG_epi1         adrenal cortex       adrenal cortex 1
## 2              AG_epi1         adrenal cortex       adrenal cortex 1
## 3              AG_epi1         adrenal cortex       adrenal cortex 1
## 4              AG_epi1         adrenal cortex       adrenal cortex 1
## 5              AG_epi1         adrenal cortex       adrenal cortex 1
## 6              AG_epi1         adrenal cortex       adrenal cortex 1
##   archive_L3_clusterID
## 1  AG_adrenal cortex 1
## 2  AG_adrenal cortex 1
## 3  AG_adrenal cortex 1
## 4  AG_adrenal cortex 1
## 5  AG_adrenal cortex 1
## 6  AG_adrenal cortex 1

5 Model performance in heart

region <- "chr6:43168502-43176649" # "chr6:43169979-43183223"
region_zoom <- "chr6:43171139-43171286"
cluster <- "Heart_c0"

Once we’ve fixed the regions, we can load tracks once and subset them to avoid loading over and over.

# predicted signal
bw_pred <- rtracklayer::import.bw(glue("{chrombpnet_dir}/01-models/predictions/bias_corrected/{cluster}_avg_chrombpnet_nobias.bw"))

# nuc occupancy signal
nuc_bw <- rtracklayer::import.bedGraph(glue("{chrombpnet_dir}/02-compendium/nucleoatac/{cluster}/{cluster}.occ.bedgraph.gz"))

# contribution scores
bw_contrib <- rtracklayer::import.bw(glue("{chrombpnet_dir}/01-models/contribs/bias_Heart_c0_thresh0.4/{cluster}/average_shaps.counts.bw"))

# hits
hits <- rtracklayer::import.bed(
  glue("{chrombpnet_dir}/02-compendium/hits_unified_motifs/reconciled_per_celltype_peaks/{cluster}/{finemo_param}/{cluster}__hits_unified.{finemo_param}.reconciled.bed.gz"),
  extraCols = c("pattern_class" = "character"))

bw_pred_filt <- bw_pred[bw_pred %over% str_to_gr(region)]
nuc_bw_filt  <- nuc_bw[nuc_bw %over% str_to_gr(region)]
contrib_filt <- bw_contrib[bw_contrib %over% str_to_gr(region)]
hits_filt    <- hits[hits %over% str_to_gr(region)]

save(bw_pred_filt, nuc_bw_filt, contrib_filt, hits_filt, file = glue("{out}/heart_bw_inputs.Rda"))
load(glue("{out}/heart_bw_inputs.Rda"))

# get the color palette
cmap_clusters <- cluster_meta %>%
  filter(Cluster_chrombpnet %in% cluster) %>%
  dplyr::select(Cluster_chrombpnet, organ_color) %>% tibble::deframe()

# subset the global object
sub_meta <- global_bp_obj$cell_metadata %>%
  dplyr::filter(Cluster_chrombpnet %in% cluster)

# coverage track
track_cov <- trackplot_coverage2(
  region           = region,
  fragments        = global_bp_obj$frags %>% select_cells(sub_meta$cb),
  groups           = sub_meta$Cluster_chrombpnet,
  cell_read_counts = sub_meta$nFrags,
  colors           = c("Heart_c0" = "black"),
  bins             = 500) +
  ylab(NULL)
## [1] 1
track_cov <- BPCells:::set_trackplot_label(track_cov, "Obs (RPKM)")

# gene annotation
track_genes <- trackplot_gene(global_bp_obj$transcripts, region) +
  ggplot2::guides(color = "none")

# scale bar for the top
scale_plot <- trackplot_scalebar(region)

# plot the predicted accessibility
track_preds_corrected <- trackplot_bw(
  bw          = bw_pred_filt,
  region      = region,
  facet_label = "Pred (bias-corrected)",
  track_label = NULL,
  color       = c("Heart" = "#BE1E2D"),
  tile_width = 25)
## @ preparing data...
## @ plotting in region with width 8148
## @ binning data with tile width 25
## @ plotting...
# continuous nuc signal
track_nuc <- trackplot_bw(
  bw          = nuc_bw_filt,
  region      = region,
  facet_label = "Nucleosome signal",
  tile_width = 1,
  track_label = NULL,
  color       = c("Heart" = "navy"))
## @ preparing data...
## @ plotting in region with width 8148
## @ plotting without binning.
## @ plotting...
# zoom in on pred. accessibility
track_preds_corrected_zoom <- trackplot_bw(
  bw          = bw_pred_filt,
  region      = region_zoom,
  track_label = NULL,
  facet_label = "Pred (bias-corrected) [zoom]",
  color       = c("Heart" = "#BE1E2D"),
  tile_width  = 1,
  plot_as     = "bar")
## @ preparing data...
## @ plotting in region with width 148
## @ plotting without binning.
## @ plotting...
# zoomed-in contribs
track_contribs <- trackplot_contribs(contrib_filt,
                                     region = region_zoom, 
                                     track_label = NULL,
                                     facet_label = "Contributions",
                                     genome = BSgenome.Hsapiens.UCSC.hg38,
                                     rel_height = 1) + xlab(NULL)
## @ plotting basepair-level contribs for width 148
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
track_hits <- trackplot_genome_annotation(loci = hits_filt,
                                          region = region_zoom,
                                          color_by = "score",
                                          show_strand = TRUE,
                                          colors = c("white", "red"), 
                                          label_size = 3,
                                          label_by = "name",
                                          track_label = "Instances")

plot_list <- map(list(track_cov, track_preds_corrected, track_nuc, track_genes),
                 ~ .x + highlight_region(region_zoom, alpha = 0.4, color = "yellow"))

plot_list2 <- list(track_preds_corrected_zoom, track_contribs, track_hits)

trackplot_combine(c(list(scale_plot), plot_list, plot_list2),
                  title = paste0(cluster, ": ", str_to_pretty(region))) &
  ggplot2::theme(legend.direction = "vertical")

6 Example of reducing motifs in muscle

region <- "chr11:17713291-17722392" # "chr6:43169979-43183223"
region_zoom1 <- "chr11:17713844-17713983"
region_zoom2 <- "chr11:17721432-17721577"
cluster <- "Muscle_c0"
# predicted signal
bw_pred <- rtracklayer::import.bw(glue("{chrombpnet_dir}/01-models/predictions/bias_corrected/{cluster}_avg_chrombpnet_nobias.bw"))

# nuc occupancy signal
nuc_bw <- rtracklayer::import.bedGraph(glue("{chrombpnet_dir}/02-compendium/nucleoatac/{cluster}/{cluster}.occ.bedgraph.gz"))

# contribution scores
bw_contrib <- rtracklayer::import.bw(glue("{chrombpnet_dir}/01-models/contribs/bias_Heart_c0_thresh0.4/{cluster}/average_shaps.counts.bw"))

# hits
hits <- rtracklayer::import.bed(
  glue("{chrombpnet_dir}/02-compendium/hits_unified_motifs/reconciled_per_celltype_peaks/{cluster}/{finemo_param}/{cluster}__hits_unified.{finemo_param}.reconciled.bed.gz"),
  extraCols = c("pattern_class" = "character"))

bw_pred_filt <- bw_pred[bw_pred %over% str_to_gr(region)]
nuc_bw_filt  <- nuc_bw[nuc_bw %over% str_to_gr(region)]
contrib_filt <- bw_contrib[bw_contrib %over% str_to_gr(region)]
hits_filt    <- hits[hits %over% str_to_gr(region)]

save(bw_pred_filt, nuc_bw_filt, contrib_filt, hits_filt, file = glue("{out}/muscle_bw_inputs.Rda"))
load(glue("{out}/muscle_bw_inputs.Rda"))

# get the color palette
cmap_clusters <- cluster_meta %>%
  filter(Cluster_chrombpnet %in% cluster) %>%
  dplyr::select(Cluster_chrombpnet, organ_color) %>% tibble::deframe()

# subset the global object
sub_meta <- global_bp_obj$cell_metadata %>%
  dplyr::filter(Cluster_chrombpnet %in% cluster)

# coverage track
track_cov <- trackplot_coverage2(
  region           = region,
  fragments        = global_bp_obj$frags %>% select_cells(sub_meta$cb),
  groups           = sub_meta$Cluster_chrombpnet,
  cell_read_counts = sub_meta$nFrags,
  colors           = c("Muscle_c0" = cmap_organ[["Muscle"]]),
  bins             = 500) +
  ylab(NULL)
## [1] 1
track_cov <- BPCells:::set_trackplot_label(track_cov, "Obs (RPKM)")

# gene annotation
track_genes <- trackplot_gene(global_bp_obj$transcripts, region) +
  ggplot2::guides(color = "none")

# scale bar for the top
scale_plot <- trackplot_scalebar(region)

track_preds_corrected <- trackplot_bw(
  bw          = bw_pred_filt,
  region      = region,
  facet_label = "Pred (bias-corrected)",
  track_label = NULL,
  color       = c("Muscle" = cmap_organ[["Muscle"]]),
  tile_width = 25)
## @ preparing data...
## @ plotting in region with width 9102
## @ binning data with tile width 25
## @ plotting...
track_nuc <- trackplot_bw(
  bw          = nuc_bw_filt,
  region      = region,
  facet_label = "Nucleosome signal",
  tile_width = 1,
  track_label = NULL,
  color       = c("Muscle" = "navy"))
## @ preparing data...
## @ plotting in region with width 9102
## @ plotting without binning.
## @ plotting...
track_preds_corrected_zoom1 <- trackplot_bw(
  bw          = bw_pred_filt,
  region      = region_zoom1,
  track_label = NULL,
  facet_label = "Pred (bias-corrected) [zoom]",
  color       = c("Muscle" = cmap_organ[["Muscle"]]),
  tile_width  = 1,
  plot_as     = "bar")
## @ preparing data...
## @ plotting in region with width 140
## @ plotting without binning.
## @ plotting...
# zoomed-in contribs
track_contribs1 <- trackplot_contribs(contrib_filt,
                                      region = region_zoom1, 
                                      track_label = NULL,
                                      facet_label = "Contributions",
                                      genome = BSgenome.Hsapiens.UCSC.hg38,
                                      rel_height = 1) + xlab(NULL)
## @ plotting basepair-level contribs for width 140
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
track_hits1 <- trackplot_genome_annotation(loci = hits_filt,
                                           region = region_zoom1,
                                           color_by = "pattern_class",
                                           show_strand = TRUE,
                                           colors = c("darkred", "darkgreen"), 
                                           label_size = 3,
                                           label_by = "name",
                                           track_label = "Instances")

# track_preds_corrected_zoom2 <- trackplot_bw(
#   bw          = bw_pred,
#   region      = region_zoom2,
#   track_label = NULL,
#   facet_label = "Pred (bias-corrected) [zoom]",
#   color       = c("Muscle" = cmap_organ[["Muscle"]]),
#   tile_width  = 1,
#   plot_as     = "bar")
# 
# # zoomed-in contribs
# track_contribs2 <- trackplot_contribs(bw_contrib,
#                                      region = region_zoom2, 
#                                      track_label = NULL,
#                                      facet_label = "Contributions",
#                                      genome = BSgenome.Hsapiens.UCSC.hg38,
#                                      rel_height = 1) + xlab(NULL)
# 
# track_hits2 <- trackplot_genome_annotation(loci = hits,
#                             region = region_zoom2,
#                             color_by = "pattern_class",
#                             show_strand = TRUE,
#                             colors = c("darkred", "darkgreen"), 
#                             label_size = 3,
#                             label_by = "name",
#                             track_label = "Instances")

plot_list <- map(list(track_cov, track_preds_corrected, track_nuc, track_genes),
                 ~ .x + highlight_region(region_zoom1, alpha = 0.4, color = "yellow"))

plot_list2 <- list(track_preds_corrected_zoom1, track_contribs1, track_hits1)

# plot_list3 <- list(track_preds_corrected_zoom2, track_contribs2, track_hits2)

trackplot_combine(c(list(scale_plot), plot_list, plot_list2),
                  title = paste0(cluster, ": ", str_to_pretty(region))) &
  ggplot2::theme(legend.direction = "vertical")

7 Consistency of syntax in endothelial cells

Here we want to load the tracks for several endothelial clusters.

region <- "chr5:150128841-150131272"
region_gr <- str_to_gr(region)

region_zoom <- "chr5:150129885-150130189"

endo_clusters <- c("Muscle_c5", "Spleen_c2", "Thymus_c7", "Brain_c13",
                   "Liver_c10", "Stomach_c10")
sub_meta <- global_bp_obj$cell_metadata %>%
  dplyr::filter(Cluster_chrombpnet %in% endo_clusters)

# coverage track
track_cov <- trackplot_coverage2(
  region           = region,
  fragments        = global_bp_obj$frags %>% select_cells(sub_meta$cb),
  groups           = sub_meta$Cluster_chrombpnet,
  cell_read_counts = sub_meta$nFrags,
  colors           = cmap_cluster[endo_clusters],
  bins             = 500) +
  ylab(NULL) +
  highlight_region(region_zoom, color = "yellow")
## [1] 1
tracks_pred_un <- list()
tracks_pred <- list()
tracks_contrib <- list()

# loop over clusters and plot the predicted accessibility and contribution scores
for (i in endo_clusters) {
  
  organ <- str_split(i, pattern = "\\_")[[1]][1]
  
  message(i)

  # uncorrected signal
  bw_pred_un <- rtracklayer::import.bw(glue("{chrombpnet_dir}/01-models/predictions/uncorrected/{i}_avg_chrombpnet_uncorrected.bw"))
  bw_unc_filt <- bw_pred_un[bw_pred_un %over% region_gr]
  rm(bw_pred_un)
    
  # predicted signal
  bw_pred <- rtracklayer::import.bw(glue("{chrombpnet_dir}/01-models/predictions/bias_corrected/{i}_avg_chrombpnet_nobias.bw"))
  
  # subset the bigwig
  bw_filt <- bw_pred[bw_pred %over% region_gr]
  rm(bw_pred)
  
  # contrib scores
  bw_contrib <- rtracklayer::import.bw(glue("{chrombpnet_dir}/01-models/contribs/bias_Heart_c0_thresh0.4/{i}/average_shaps.counts.bw"))
  bw_contrib_filt <- bw_contrib[bw_contrib %over% region_gr]
  rm(bw_contrib)
  
  tracks_pred_un[[i]] <- bw_unc_filt
  tracks_pred[[i]] <- bw_filt
  tracks_contrib[[i]] <- bw_contrib_filt
  
}

save(tracks_pred_un, tracks_pred, tracks_contrib, file = glue("{out}/tracks_endo.Rda"))

Plot tracks:

load(glue("{out}/tracks_endo.Rda"))

# plot all the predictions in the wide region
track_preds_broad <- imap(tracks_pred, ~ trackplot_bw(
  bw          = .x,
  region      = region,
  facet_label = .y,
  track_label = "Pred (bias-corrected)",
  color       = cmap_cluster[.y],
  tile_width = 5) + highlight_region(region_zoom, alpha = 0.4, color = "yellow"))
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
# plot all the predictions in the zoomed region
track_preds_zoom <- imap(tracks_pred, ~ trackplot_bw(
  bw          = .x,
  region      = region_zoom,
  facet_label = .y,
  track_label = "Pred (bias-corrected)",
  color       = cmap_cluster[.y],
  tile_width = 1))
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
# plot all the uncorrected predictions in the wide region
track_preds_un_broad <- imap(tracks_pred_un, ~ trackplot_bw(
  bw          = .x,
  region      = region,
  facet_label = .y,
  track_label = "Pred (uncorrected)",
  color       = cmap_cluster[.y],
  tile_width = 5) + highlight_region(region_zoom, alpha = 0.4, color = "yellow"))
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
## @ preparing data...
## @ plotting in region with width 2432
## @ binning data with tile width 5
## @ plotting...
# plot all the predictions in the zoomed region
track_preds_un_zoom <- imap(tracks_pred_un, ~ trackplot_bw(
  bw          = .x,
  region      = region_zoom,
  facet_label = .y,
  track_label = "Pred (uncorrected)",
  color       = cmap_cluster[.y],
  tile_width = 1))
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
## @ preparing data...
## @ plotting in region with width 305
## @ plotting without binning.
## @ plotting...
# plot all the contributions in the zoomed region
# this version prints the ymin-ymax scale
track_contribs <- imap(tracks_contrib, ~ trackplot_contribs_BL(
  .x,
  region = region_zoom, 
  facet_label = .y,
  track_label = "Contributions",
  genome = BSgenome.Hsapiens.UCSC.hg38,
  # ymax = 0.25, ymin = -0.039,
  rel_height = 1) + xlab(NULL))
## @ plotting basepair-level contribs for width 305
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
## @ plotting basepair-level contribs for width 305
## 
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
## @ plotting basepair-level contribs for width 305
## 
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
## @ plotting basepair-level contribs for width 305
## 
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
## @ plotting basepair-level contribs for width 305
## 
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
## @ plotting basepair-level contribs for width 305
## 
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
# gene annotation
track_genes <- trackplot_gene(global_bp_obj$transcripts, region) +
  ggplot2::guides(color = "none") +
  highlight_region(region_zoom, alpha = 0.4, color = "yellow")

# hits
hits <- rtracklayer::import.bed(
  glue("{chrombpnet_dir}/02-compendium/hits_unified_motifs/reconciled_per_celltype_peaks/Muscle_c5/{finemo_param}/Muscle_c5__hits_unified.{finemo_param}.reconciled.bed.gz"),
  extraCols = c("pattern_class" = "character"))

track_hits <- trackplot_genome_annotation(loci = hits,
                                          region = region_zoom,
                                          color_by = "score",
                                          show_strand = TRUE,
                                          colors = c("white", "red"), 
                                          label_size = 3,
                                          label_by = "name",
                                          track_label = "Instances")

# scale bar for the top
scale_plot <- trackplot_scalebar(region)
trackplot_combine2(c(list(scale_plot), list(track_cov),
                     track_preds_un_broad,
                     track_preds_broad,
                     list(track_genes),
                     track_preds_zoom,
                     track_contribs,
                     list(track_hits)),
                  title = str_to_pretty(region)) &
  ggplot2::theme(legend.direction = "vertical")

8 Session info

sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: CentOS Linux 7 (Core)
## 
## Matrix products: default
## BLAS/LAPACK: /share/software/user/open/openblas/0.3.10/lib/libopenblas_haswellp-r0.3.10.so
## 
## 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       
## 
## attached base packages:
## [1] grid      stats4    stats     graphics  grDevices utils     datasets 
## [8] methods   base     
## 
## other attached packages:
##  [1] ggthemes_4.2.4                    RColorBrewer_1.1-3               
##  [3] magrittr_2.0.3                    GenomicFeatures_1.46.5           
##  [5] AnnotationDbi_1.56.2              Biobase_2.54.0                   
##  [7] BSgenome.Hsapiens.UCSC.hg38_1.4.4 BSgenome_1.62.0                  
##  [9] rtracklayer_1.54.0                Biostrings_2.62.0                
## [11] XVector_0.34.0                    GenomicRanges_1.46.1             
## [13] GenomeInfoDb_1.30.1               IRanges_2.28.0                   
## [15] S4Vectors_0.32.4                  BiocGenerics_0.40.0              
## [17] ggrastr_1.0.1                     patchwork_1.2.0                  
## [19] BPCells_0.2.0                     ggseqlogo_0.1                    
## [21] ggrepel_0.9.3                     stringr_1.5.0                    
## [23] purrr_1.0.2                       glue_1.8.0                       
## [25] scales_1.3.0                      readr_2.1.4                      
## [27] ggplot2_3.5.1                     tidyr_1.3.0                      
## [29] dplyr_1.1.3                       here_1.0.1                       
## 
## loaded via a namespace (and not attached):
##  [1] bitops_1.0-7                matrixStats_1.0.0          
##  [3] bit64_4.0.5                 filelock_1.0.2             
##  [5] progress_1.2.2              httr_1.4.7                 
##  [7] rprojroot_2.0.3             tools_4.1.2                
##  [9] bslib_0.5.1                 utf8_1.2.3                 
## [11] R6_2.5.1                    vipor_0.4.5                
## [13] DBI_1.1.3                   colorspace_2.1-0           
## [15] withr_2.5.0                 prettyunits_1.1.1          
## [17] tidyselect_1.2.0            curl_5.0.2                 
## [19] bit_4.0.5                   compiler_4.1.2             
## [21] cli_3.6.1                   xml2_1.3.5                 
## [23] DelayedArray_0.20.0         labeling_0.4.3             
## [25] sass_0.4.7                  rappdirs_0.3.3             
## [27] digest_0.6.33               Rsamtools_2.10.0           
## [29] rmarkdown_2.24              pkgconfig_2.0.3            
## [31] htmltools_0.5.6             MatrixGenerics_1.6.0       
## [33] highr_0.10                  dbplyr_2.3.3               
## [35] fastmap_1.1.1               rlang_1.1.1                
## [37] rstudioapi_0.15.0           RSQLite_2.3.1              
## [39] farver_2.1.1                jquerylib_0.1.4            
## [41] BiocIO_1.4.0                generics_0.1.3             
## [43] jsonlite_1.8.7              BiocParallel_1.28.3        
## [45] vroom_1.6.3                 RCurl_1.98-1.12            
## [47] GenomeInfoDbData_1.2.7      Matrix_1.6-3               
## [49] Rcpp_1.0.11                 ggbeeswarm_0.7.2           
## [51] munsell_0.5.0               fansi_1.0.4                
## [53] lifecycle_1.0.3             stringi_1.7.12             
## [55] yaml_2.3.7                  SummarizedExperiment_1.24.0
## [57] zlibbioc_1.40.0             BiocFileCache_2.2.1        
## [59] blob_1.2.4                  parallel_4.1.2             
## [61] crayon_1.5.2                lattice_0.20-45            
## [63] hms_1.1.3                   KEGGREST_1.34.0            
## [65] knitr_1.43                  pillar_1.9.0               
## [67] rjson_0.2.21                biomaRt_2.50.3             
## [69] XML_3.99-0.14               evaluate_0.21              
## [71] vctrs_0.6.3                 png_0.1-8                  
## [73] tzdb_0.4.0                  gtable_0.3.4               
## [75] cachem_1.0.8                xfun_0.40                  
## [77] restfulr_0.0.15             tibble_3.2.1               
## [79] GenomicAlignments_1.30.0    beeswarm_0.4.0             
## [81] memoise_2.0.1