Commit ab551fe5 authored by Christian Arnold's avatar Christian Arnold
Browse files

GRaNIEdev: Added flexibilit for custom TFBS patterns, thanks to Brian for reporting

parent 0950492d
......@@ -846,13 +846,14 @@ addTFBS <- function(GRN, motifFolder, TFs = "all", nTFMax = NULL, filesTFBSPatte
checkmate::assertDirectoryExists(motifFolder)
checkmate::assertCharacter(TFs, min.len = 1)
checkmate::assert(checkmate::testNull(nTFMax), checkmate::testIntegerish(nTFMax, lower = 1))
checkmate::assertCharacter(filesTFBSPattern, len = 1, min.chars = 1)
checkmate::assertCharacter(filesTFBSPattern, len = 1, min.chars = 0)
checkmate::assertCharacter(fileEnding, len = 1, min.chars = 1)
checkmate::assertFlag(forceRerun)
if (is.null(GRN@data$TFs$translationTable) | is.null(GRN@data$TFs$translationTable) | is.null(GRN@config$allTF) | is.null(GRN@config$directories$motifFolder) | forceRerun) {
GRN@config$TFBS_fileEnding = fileEnding
GRN@config$TFBS_fileEnding = fileEnding
GRN@config$TFBS_filePattern = filesTFBSPattern
GRN@data$TFs$translationTable = .getFinalListOfTFs(motifFolder, filesTFBSPattern, fileEnding, TFs, nTFMax, getCounts(GRN, type = "rna", norm = TRUE, permuted = FALSE))
......@@ -868,6 +869,7 @@ addTFBS <- function(GRN, motifFolder, TFs = "all", nTFMax = NULL, filesTFBSPatte
# GRN@config$TF_list[["all_TFBS"]] =GRN@config$allTF
GRN@config$directories$motifFolder = motifFolder
}
GRN
......@@ -940,6 +942,7 @@ addTFBS <- function(GRN, motifFolder, TFs = "all", nTFMax = NULL, filesTFBSPatte
.checkAndLogWarningsAndErrors(NULL, message, isWarning = FALSE)
}
HOCOMOCO_mapping.df.exp
}
......@@ -967,6 +970,15 @@ overlapPeaksAndTFBS <- function(GRN, nCores = 2, forceRerun = FALSE) {
genomeAssembly = GRN@config$parameters$genomeAssembly
seqlengths = .getChrLengths(genomeAssembly)
if (!is.null(GRN@config$TFBS_filePattern)) {
filesTFBSPattern = GRN@config$TFBS_filePattern
} else {
message = "Could not retrieve value from GRN@config$TFBS_filePattern. Please rerun the function addTFBS, as this was added in a recent version of the package."
.checkAndLogWarningsAndErrors(NULL, message, isWarning = FALSE)
}
# Check whether we have peaks on chromosomes not part of the sequence length reference. If yes, discard them
annotation_discared = dplyr::filter(GRN@data$peaks$consensusPeaks, ! chr %in% names(seqlengths))
......@@ -988,7 +1000,7 @@ overlapPeaksAndTFBS <- function(GRN, nCores = 2, forceRerun = FALSE) {
res.l = .execInParallelGen(nCores, returnAsList = TRUE, listNames = GRN@config$allTF,
iteration = seq_len(length(GRN@config$allTF)),
verbose = FALSE,
functionName = .intersectTFBSPeaks, GRN = GRN, consensusPeaks = consensus.gr)
functionName = .intersectTFBSPeaks, GRN = GRN, consensusPeaks = consensus.gr, filesTFBSPattern = filesTFBSPattern)
# Sanity check
......@@ -1028,11 +1040,11 @@ overlapPeaksAndTFBS <- function(GRN, nCores = 2, forceRerun = FALSE) {
#' @import GenomicRanges
.intersectTFBSPeaks <- function(GRN, TFIndex, consensusPeaks, verbose = FALSE) {
.intersectTFBSPeaks <- function(GRN, TFIndex, consensusPeaks, filesTFBSPattern, verbose = FALSE) {
TFCur = GRN@config$allTF[TFIndex]
file_tfbs_in = paste0(GRN@config$directories$motifFolder, "/", TFCur, "_TFBS", GRN@config$TFBS_fileEnding)
file_tfbs_in = paste0(GRN@config$directories$motifFolder, "/", TFCur, filesTFBSPattern, GRN@config$TFBS_fileEnding)
# Intersect consensusPeaks GR with bed file GR
TFBS.df = .readTFBSFile(file_tfbs_in)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment