The files condition2_normalized.rds and condition2_inputfree_normalized.rds were generated by applying crupR::normalize to the test BAM files also provided with this package.
The files condition2_predictions.rds and condition1_predictions.rds were generated by crupR::getPredictions. The file differential_enhancers.rds was generated using the crupR::getDynamics.
The files RegulatoryUnits.rds and RegulatoryUnitsNearestGene.rds were generated using crupR::getTargets. The detailed code for every of these files can be found in the vignette.                                                                                          

To generate the gene expression matrix that is used in the vignette and the examples for crupR::getTargets(), the code of the function get_bamOverlaps in the file functions.R (https://github.com/VerenaHeinrich/CRUP/blob/master/BIN/functions.R) was used:
get_bamOverlaps <- function(files, IDs, txdb, singleEnd){
  # gives information about path of bam and bai file (Object)
  bf = BamFileList(unlist(files))
  # gives length of different chromosomes (SeqInfo class)
  si = seqinfo(bf)
  # get exons and genes
  expr.gr <- genes(txdb)
  seqlevels(expr.gr) = paste0("chr", gsub("chr","",seqlevels(expr.gr)))
  exons <- exonsBy(txdb, by = "gene")
  exons <- exons[which((names(exons) %in% mcols(expr.gr)$gene_id) == T)]
  # fix chromosome prefix:
  seqlevels(exons) <- gsub("chr","",seqlevels(exons))
  if (grepl("chr",seqlevels(si)[1])) {
    seqlevels(exons) <- paste0("chr", seqlevels(exons))
  }
  se <- summarizeOverlaps(exons,
                          bf,
			  mode="Union",
                          singleEnd = singleEnd,
                          fragments = setdiff(c(FALSE,TRUE), singleEnd))
  # get counts and summarize per gene:
  counts.per.exon <- data.frame(assays(se)$counts,
                                gene = rownames(assays(se)$counts))
  counts.split <- split(counts.per.exon,
                        counts.per.exon$gene)
  counts.per.gene <- (do.call(rbind,lapply(counts.split, function(x) colSums(x[,-dim(x)[2]]))))
  # create new symmarized experiment object:
  se0 <- SummarizedExperiment( assays = SimpleList(counts = counts.per.gene),
                               colData = names(bf)
  )
  
  # stabilize the variance across the mean:
  # (The transformed data should be approximated variance stabilized
  # and also includes correction for size factors or normalization factors)
  dds <- suppressMessages(DESeqDataSet(se0, ~ 1))
  vsd <- varianceStabilizingTransformation(	dds,
						blind = TRUE)
  counts_vst <- assay(vsd)
  counts_raw <- assay(dds)
  expr_raw.gr <- expr.gr
  for (i in 1:dim(counts_vst)[2]) {
        mcols(expr.gr)[,unlist(IDs)[i]] <- counts_vst[,i]
        mcols(expr_raw.gr)[,unlist(IDs)[i]] <- counts_raw[,i]
  }
  expr.gr <- expr.gr[which(rowVars(counts_vst) > 0)]
  expr_raw.gr <- expr_raw.gr[which(rowVars(counts_vst) > 0)]
  return(list(raw = expr_raw.gr, vst = expr.gr))
} 

The inputs for the function are a vector containing the file names of the RNAseq BAMs (files), another vector containing the IDs of the samples which is a combination of the condition and the replicate ("COND_REP") and matches the sample names given in the getDynamics() output (IDs), the TxDb object for the genome of interest (txdb) and a logical variable denoting the type of sequencing (singleEnd, FALSE means paired-end). For the test data following command was used:
expression = get_bamOverlaps(files = c("TEST/DATA/RNAseq/Condition1.bam", "TEST/DATA/RNAseq/Condition2.bam"),
					   IDs = c("cond1_1", "cond2_1"),
					   txdb = TxDb.Mmusculus.UCSC.mm10.knownGene::TxDb.Mmusculus.UCSC.mm10.knownGene,
					   singleEnd = FALSE)

The function returns a list with the raw and the normalized counts. For the test file the normalized version was used:
expr = expression[["vst"]]






