Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: R-CMD-check-bioc

on:
push:
branches:
- main
- master
- devel
pull_request:

jobs:
run-check:
uses: bioc-package-rescue/workflows/.github/workflows/check-bioc.yml@main
11 changes: 7 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ Title: RcisTarget Identify transcription factor binding motifs enriched on a
list of genes or genomic regions
Version: 1.23.1
Date: 2024-03-02
Author: Sara Aibar, Gert Hulselmans, Stein Aerts. Laboratory of Computational Biology.
VIB-KU Leuven Center for Brain & Disease Research. Leuven, Belgium
Maintainer: Gert Hulselmans <Gert.Hulselmans@kuleuven.be>
Authors@R: c(
person("Sara", "Aibar", role = "aut"),
person("Gert", "Hulselmans", email = "Gert.Hulselmans@kuleuven.be", role = c("aut", "cre")),
person("Stein", "Aerts", role = "aut"),
person("Laboratory of Computational Biology. VIB-KU Leuven Center for Brain & Disease Research. Leuven, Belgium", role = "cph")
)
Description: RcisTarget identifies transcription factor binding
motifs (TFBS) over-represented on a gene list.
In a first step, RcisTarget selects DNA motifs that are significantly
Expand All @@ -31,6 +34,7 @@ Imports:
dplyr,
tibble,
GSEABase,
igraph,
methods,
R.utils,
stats,
Expand All @@ -48,7 +52,6 @@ Suggests:
foreach,
gplots,
rtracklayer,
igraph,
knitr,
RcisTarget.hg19.motifDBs.cisbpOnly.500bp,
rmarkdown,
Expand Down
2 changes: 1 addition & 1 deletion R/02_addMotifAnnotation.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ addMotifAnnotation <- function(auc, nesThreshold=3.0, digits=3,

if(!is.null(motifAnnot)) {
motifAnnot_subset <- motifAnnot[(motifAnnot[[idColumn]] %in% aucTable[[idColumn]])
& (motifAnnot$TF %in% TFs), ][,c(idColumn, "TF", "annotationSource"),with=F]
& (motifAnnot$TF %in% TFs), ][,c(idColumn, "TF", "annotationSource"),with=FALSE]
motifAnnot_subset <- split(motifAnnot_subset, motifAnnot_subset[[idColumn]])
for(motifName in names(motifAnnot_subset))
{
Expand Down
4 changes: 2 additions & 2 deletions R/aux_addLogo.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ showLogo <- function(motifEnrDT,
stop("Please indicate the column containing the motif id (argument 'motifCol') or set it to NULL.")
}
# TODO
met <- met[grep("transfac_pro__", met[[motifCol]], invert = T),]
met <- met[grep("transfac_pro__", met[[motifCol]], invert = TRUE),]
}

# For numeric columns, show only the number of significant digits...
Expand All @@ -106,7 +106,7 @@ showLogo <- function(motifEnrDT,
if(!is.null(colsToShow)) {
colsToShow <- unique(unname(unlist(colsToShow)))
colsToShow <- colsToShow[which(colsToShow %in% colnames(met))]
met <- met[, colsToShow, with=F]
met <- met[, colsToShow, with=FALSE]
}

# Show...
Expand Down
12 changes: 7 additions & 5 deletions R/aux_convertToTargetRegions.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
#' \code{vignette("RcisTarget")}
#'
#' @examples
#' \dontrun{
#' ## To apply on a list of regionSets:
#' regionSets_db <- lapply(regionSets, function(x)
#' convertToTargetRegions(queryRegions=x, targetRegions=dbRegionsLoc))
#' }
#' # Create mock query and target regions
#' library(GenomicRanges)
#' queryRegions <- GRanges("chr1", IRanges(start = c(10, 100), end = c(50, 150)))
#' targetRegions <- GRanges("chr1", IRanges(start = c(5, 80, 200), end = c(45, 120, 250)))
#'
#' # Convert query regions to target regions
#' convertToTargetRegions(queryRegions = queryRegions, targetRegions = targetRegions)
#' @rdname convertToTargetRegions
#' @importFrom methods isClass
#' @importFrom GenomeInfoDb keepSeqlevels
Expand Down
22 changes: 18 additions & 4 deletions R/aux_getDbRegionsLoc.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,24 @@
#' \code{vignette("RcisTarget")}
#'
#' @examples
#' \dontrun{
#' featherFilePath <- "~/databases/dm6-regions-11species.mc9nr.feather"
#' dbRegionsLoc <- getDbRegionsLoc(featherFilePath)
#' }
#' library(arrow)
#' # Create a dummy data frame with drosophila-style region column names
#' df <- data.frame(
#' features = c("motif1", "motif2"),
#' `motif1__chr3L:1000-2000` = c(1, 2),
#' `motif2__chr3L:3000-4000` = c(3, 4),
#' check.names = FALSE
#' )
#'
#' # Write to a temporary feather file
#' tmpFile <- tempfile(fileext = ".feather")
#' write_feather(df, tmpFile)
#'
#' # Get the region locations
#' getDbRegionsLoc(tmpFile)
#'
#' # Clean up
#' file.remove(tmpFile)
#' @rdname getDbRegionsLoc
#' @importFrom GenomeInfoDb sortSeqlevels seqlevels
#' @importFrom GenomicRanges GRanges
Expand Down
2 changes: 1 addition & 1 deletion R/priv_calcErn.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
maxRankExtra <- maxRank+nMean
gsRankings.asMat <- as.matrix(gsRankings) # Much faster!
gsRankings.asMat[gsRankings.asMat>maxRankExtra] <- NA
globalMat <- matrix(0, nrow=max(nrow(gsRankings),max(gsRankings.asMat, na.rm=T)), ncol=maxRankExtra) # nrow=nrow(gsRankings): can be out of range, add extra rows and subset at the end
globalMat <- matrix(0, nrow=max(nrow(gsRankings),max(gsRankings.asMat, na.rm=TRUE)), ncol=maxRankExtra) # nrow=nrow(gsRankings): can be out of range, add extra rows and subset at the end

# x <- x[seq_len(min(length(x), nrow(globalMat)))] # or: # if(nrow(globalMat) < length(x)) x <- x[seq_len(nrow(globalMat))] # cannot be in the loop... too slow!
for(i in 1:nrow(gsRankings)) # (TO DO: Paralellize?)
Expand Down
7 changes: 4 additions & 3 deletions inst/examples/example_addSignificantGenes.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ motifEnr_wIncidMat <- addSignificantGenes(motifEnrichmentTable,
genesFormat = "incidMatrix")

motifEnr_wIncidMat <- as.data.frame(motifEnr_wIncidMat)
which(colnames(motifEnr_wIncidMat) == "rankAtMax")
rankAtMaxIdx <- match("rankAtMax", colnames(motifEnr_wIncidMat))
if(is.na(rankAtMaxIdx)) stop("Column 'rankAtMax' not found in results.")

incidMat <- motifEnr_wIncidMat[,8:ncol(motifEnr_wIncidMat)]
incidMat <- as.matrix(motifEnr_wIncidMat[, (rankAtMaxIdx + 1):ncol(motifEnr_wIncidMat)])
rownames(incidMat) <- motifEnr_wIncidMat[,"motif"]
incidMat <- incidMat[, colSums(incidMat)>0, drop=FALSE]

# Plot as network
par(mfrow=c(1,1))
library(igraph)
plot(graph.incidence(incidMat))
plot(graph_from_incidence_matrix(incidMat))
Comment thread
lwaldron marked this conversation as resolved.

###############################################################
# Alternative method: getSignificantGenes()
Expand Down
45 changes: 20 additions & 25 deletions inst/examples/example_workflow.R
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
# RcisTarget workflow for advanced users:
# Running the workflow steps individually

\dontrun{

##################################################
#### Load your gene sets
# As example, the package includes an Hypoxia gene set:
txtFile <- paste(file.path(system.file('examples', package='RcisTarget')),
"hypoxiaGeneSet.txt", sep="/")
geneLists <- list(hypoxia=read.table(txtFile, stringsAsFactors=FALSE)[,1])

#### Load databases
## Motif rankings: Select according to organism and distance around TSS
## (See the vignette for URLs to download)
motifRankings <- importRankings("~/databases/hg38_10kbp_up_10kbp_down_full_tx_v10_clust.genes_vs_motifs.rankings.feather")

## Motif - TF annotation:
data("motifAnnotations_hgnc") # human TFs (for motif collection 10)
##################################################

#### Run RcisTarget
# Since the suggested database package is in Suggests,
# we guard the example to avoid hard failures if it is not installed:
if (requireNamespace("RcisTarget.hg19.motifDBs.cisbpOnly.500bp", quietly = TRUE)) {

# Load rankings database
data(hg19_500bpUpstream_motifRanking_cispbOnly, package="RcisTarget.hg19.motifDBs.cisbpOnly.500bp")
motifRankings <- hg19_500bpUpstream_motifRanking_cispbOnly

# Step 1. Calculate AUC
motifs_AUC <- calcAUC(geneLists, motifRankings)
# Load motif annotations
data(motifAnnotations_hgnc_v9) # human TFs (for motif collection 9)
motifAnnotation <- motifAnnotations_hgnc_v9

# Step 2. Select significant motifs, add TF annotation & format as table
motifEnrichmentTable <- addMotifAnnotation(motifs_AUC,
motifAnnot=motifAnnotations)
# Step 1. Calculate AUC
motifs_AUC <- calcAUC(geneLists, motifRankings)

# Step 3 (optional). Identify genes that have the motif significantly enriched
# (i.e. genes from the gene set in the top of the ranking)
motifEnrichmentTable_wGenes <- addSignificantGenes(motifEnrichmentTable,
geneSets=geneLists,
rankings=motifRankings,
method="aprox")
# Step 2. Select significant motifs, add TF annotation & format as table
motifEnrichmentTable <- addMotifAnnotation(motifs_AUC,
motifAnnot=motifAnnotation)

# Step 3 (optional). Identify genes that have the motif significantly enriched
motifEnrichmentTable_wGenes <- addSignificantGenes(motifEnrichmentTable,
geneSets=geneLists,
rankings=motifRankings,
method="aprox")
}
15 changes: 8 additions & 7 deletions man/addSignificantGenes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 25 additions & 30 deletions man/calcAUC.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions man/convertToTargetRegions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions man/getDbRegionsLoc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.