| Title: | RNA-Binding Protein Competitive Binding Simulation |
|---|---|
| Description: | Simulates competitive binding of N RBPs to RNA sequences using an equilibrium binding model. Supports single sequences, concentration grids, and transcriptome-wide analysis. Designed for Bioconductor. |
| Authors: | Soon Yi [aut, cre] (ORCID: <https://orcid.org/0000-0002-4535-6532>), National Institutes of Health [fnd] (T32 GM152319) |
| Maintainer: | Soon Yi <[email protected]> |
| License: | GPL-3 |
| Version: | 0.99.4 |
| Built: | 2026-10-24 06:22:44 UTC |
| Source: | https://github.com/bioc/RBPEqBind |
Identifies peak regions based on binding occupancy. If the transcript headers contain genomic coordinates (e.g. "chr1:1000-2000(+)"), it appends translated genomic coordinate columns (chrom, genomic_start, genomic_end, strand).
callPeaks( results, rbp_primary, rbp_reference = NULL, method = c("competitive", "local", "global"), threshold = 2, min_width = 3, window_size = 50 )callPeaks( results, rbp_primary, rbp_reference = NULL, method = c("competitive", "local", "global"), threshold = 2, min_width = 3, window_size = 50 )
results |
data.table of simulation results. |
rbp_primary |
Name of the primary RBP. |
rbp_reference |
Name of the reference RBP (for competitive advantage) (default NULL). |
method |
Method: "competitive" (default), "local", or "global". |
threshold |
Threshold (ratio for competitive, occupancy for others) (default 2.0). |
min_width |
Minimum width of peak to report (default 3). |
window_size |
Window size for local background (default 50). |
A data.table of peaks with start, end, scores, and optionally genomic coordinates.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGUACGUUUUUACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" peaks <- callPeaks(results, rbp_primary = "HH", method = "global", threshold = 1.1) head(peaks)model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGUACGUUUUUACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" peaks <- callPeaks(results, rbp_primary = "HH", method = "global", threshold = 1.1) head(peaks)
Simple BED export for ranges exceeding threshold. If the transcript headers contain genomic coordinates (e.g. "chr1:1000-2000(+)"), it translates transcript-relative peak coordinates into genomic coordinates.
exportBed(results, output_file, rbp, threshold = 0)exportBed(results, output_file, rbp, threshold = 0)
results |
data.table. |
output_file |
File path. |
rbp |
RBP name to export. |
threshold |
Threshold for score/occupancy. |
Invisibly returns NULL. Called for side effect of writing BED file.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" tmp_bed <- tempfile(fileext = ".bed") unlink(tmp_bed)model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" tmp_bed <- tempfile(fileext = ".bed") unlink(tmp_bed)
Exports simulation results to JSON or CSV.
exportResults( results, output_file, format = c("json", "csv"), include_sequence = TRUE )exportResults( results, output_file, format = c("json", "csv"), include_sequence = TRUE )
results |
data.table of results. |
output_file |
Output file path. |
format |
"json" or "csv". |
include_sequence |
Logical, include sequence in output (default TRUE). |
Invisibly returns NULL. Called for side effect of writing file.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) # Export JSON tmp_json <- tempfile(fileext = ".json") exportResults(results, tmp_json, format = "json") unlink(tmp_json) # Export CSV tmp_csv <- tempfile(fileext = ".csv") exportResults(results, tmp_csv, format = "csv") unlink(tmp_csv)model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) # Export JSON tmp_json <- tempfile(fileext = ".json") exportResults(results, tmp_json, format = "json") unlink(tmp_json) # Export CSV tmp_csv <- tempfile(fileext = ".csv") exportResults(results, tmp_csv, format = "csv") unlink(tmp_csv)
Generates a random RNA sequence with specified nucleotide frequencies.
generateRNA(L, A = 0.25, G = 0.25, C = 0.25, U = 0.25)generateRNA(L, A = 0.25, G = 0.25, C = 0.25, U = 0.25)
L |
Length of the sequence. |
A |
Frequency of Adenine. |
G |
Frequency of Guanine. |
C |
Frequency of Cytosine. |
U |
Frequency of Uracil. |
A character string representing the RNA sequence.
set.seed(42) generateRNA(100)set.seed(42) generateRNA(100)
Reads previously exported simulation results from a JSON or CSV file.
importResults(input_file)importResults(input_file)
input_file |
Path to JSON or CSV file (exported by exportResults). |
A data.table with the imported results.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) # JSON Example tmp_json <- tempfile(fileext = ".json") exportResults(results, tmp_json, format = "json") results_json <- importResults(tmp_json) unlink(tmp_json) # CSV Example tmp_csv <- tempfile(fileext = ".csv") exportResults(results, tmp_csv, format = "csv") results_csv <- importResults(tmp_csv) unlink(tmp_csv)model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) # JSON Example tmp_json <- tempfile(fileext = ".json") exportResults(results, tmp_json, format = "json") results_json <- importResults(tmp_json) unlink(tmp_json) # CSV Example tmp_csv <- tempfile(fileext = ".csv") exportResults(results, tmp_csv, format = "csv") results_csv <- importResults(tmp_csv) unlink(tmp_csv)
Reads a CSV file containing RBP binding affinities/scores. The file should have a 'Motif' column and one or more RBP score columns.
loadModel(file, k = NULL, rbp = NULL)loadModel(file, k = NULL, rbp = NULL)
file |
Path to the CSV file. |
k |
Optional integer. If provided, filters for k-mers of this length. |
rbp |
Optional character vector of RBP names to load. If NULL, loads all. |
A named list of data.tables, each with 'motif' and 'score' columns.
# Load sample model from package model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") raw_models <- loadModel(model_file) names(raw_models) # Load specific RBPs raw_models <- loadModel(model_file, rbp = c("HH", "HL"))# Load sample model from package model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") raw_models <- loadModel(model_file) names(raw_models) # Load specific RBPs raw_models <- loadModel(model_file, rbp = c("HH", "HL"))
Converts simulation results to a SummarizedExperiment object.
makeSE(results, rbp_models = NULL)makeSE(results, rbp_models = NULL)
results |
data.table from simulateBinding or simulateBindingFasta. |
rbp_models |
Optional named list of RBP models (for colData metadata). |
A SummarizedExperiment with assays and row/col metadata.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) # Create density columns for the mock results to enable makeSE results[, HH_density := HH / sum(HH)] results[, HL_density := HL / sum(HL)] results[, HH_density_fc := HH_density * 8] results[, HL_density_fc := HL_density * 8] results[, HH_occupancy_fc := HH / mean(HH)] results[, HL_occupancy_fc := HL / mean(HL)] se <- makeSE(results, rbp_models) semodel_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGU", rbp_models, c(HH = 100, HL = 100)) # Create density columns for the mock results to enable makeSE results[, HH_density := HH / sum(HH)] results[, HL_density := HL / sum(HL)] results[, HH_density_fc := HH_density * 8] results[, HL_density_fc := HL_density * 8] results[, HH_occupancy_fc := HH / mean(HH)] results[, HL_occupancy_fc := HL / mean(HL)] se <- makeSE(results, rbp_models) se
Extracts genomic coordinates from a UCSC-style header string, e.g. "chr1:1000-2000" or "chr1:1000-2000(-)".
parseGenomicHeader(h)parseGenomicHeader(h)
h |
Character string. |
A list with chrom, start, end, and strand, or NULL.
Plots the binding profile for one or more RBPs.
plotBinding( results, rbp, transcript = NULL, metric = c("occupancy", "density", "density_fc", "occupancy_fc"), ylim = NULL, xlim = NULL, xaxis_type = c("nucleotide", "position", "both"), rna_conc = NULL, protein_conc = NULL, window = NULL )plotBinding( results, rbp, transcript = NULL, metric = c("occupancy", "density", "density_fc", "occupancy_fc"), ylim = NULL, xlim = NULL, xaxis_type = c("nucleotide", "position", "both"), rna_conc = NULL, protein_conc = NULL, window = NULL )
results |
data.table of simulation results. |
rbp |
Character vector of RBP names to plot. |
transcript |
Optional transcript name to filter (default NULL). |
metric |
Type of metric: "occupancy" (default), "density", "density_fc", or "occupancy_fc". |
ylim |
Optional y-axis limits (default NULL). |
xlim |
Optional x-axis limits (default NULL). |
xaxis_type |
Type of x-axis labels: "nucleotide" (default), "position", or "both". |
rna_conc |
Optional numeric. Filter by RNA concentration (default NULL). |
protein_conc |
Optional named numeric vector. Filter by protein concentration (default NULL). |
window |
Optional integer. Applies K-mer sliding window average (default NULL). |
A ggplot object.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" plotBinding(results, rbp = c("HH", "HL"))model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" plotBinding(results, rbp = c("HH", "HL"))
Visualizes binding across a concentration grid.
plotGrid( results, rbp1, rbp2, roi_range, metric = c("occupancy", "density", "density_fc", "occupancy_fc"), rbp1_concs = NULL )plotGrid( results, rbp1, rbp2, roi_range, metric = c("occupancy", "density", "density_fc", "occupancy_fc"), rbp1_concs = NULL )
results |
data.table from simulateGrid. |
rbp1 |
Name of first RBP (subdivides each cell). |
rbp2 |
Name of second RBP (X-axis). |
roi_range |
Numeric vector (start, end) for region of interest. |
metric |
"occupancy" (default), "density", "density_fc", or "occupancy_fc". |
rbp1_concs |
Optional vector of RBP1 concentrations to include (default NULL). |
A ggplot object.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateGrid( sequence = "ACGUACGU", rbp_models = rbp_models, protein_conc_grid = list(HH = c(10, 100), HL = c(10, 100)), rna_conc_grid = 10 ) plotGrid(results, rbp1 = "HH", rbp2 = "HL", roi_range = c(1, 8))model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateGrid( sequence = "ACGUACGU", rbp_models = rbp_models, protein_conc_grid = list(HH = c(10, 100), HL = c(10, 100)), rna_conc_grid = 10 ) plotGrid(results, rbp1 = "HH", rbp2 = "HL", roi_range = c(1, 8))
Plots a heatmap of binding for multiple RBPs.
plotHeatmap( results, transcript, rbps = NULL, xlim = NULL, xaxis_type = c("nucleotide", "position", "both"), metric = c("occupancy", "density", "density_fc", "occupancy_fc"), window = NULL, zlim = NULL )plotHeatmap( results, transcript, rbps = NULL, xlim = NULL, xaxis_type = c("nucleotide", "position", "both"), metric = c("occupancy", "density", "density_fc", "occupancy_fc"), window = NULL, zlim = NULL )
results |
data.table of simulation results. |
transcript |
Transcript name to filter (required). |
rbps |
Optional vector of RBP names to include (default NULL, infers all). |
xlim |
Optional x-axis limits (default NULL). |
xaxis_type |
Type of x-axis labels: "nucleotide" (default), "position", or "both". |
metric |
Type of metric: "occupancy" (default), "density", "density_fc", or "occupancy_fc". |
window |
Optional integer for K-mer sliding window average (default NULL). |
zlim |
Optional numeric vector for color scale limits (default NULL). |
A ggplot object.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" plotHeatmap(results, transcript = "test_transcript")model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBinding("ACGUACGUACGU", rbp_models, c(HH = 100, HL = 100)) results$transcript <- "test_transcript" plotHeatmap(results, transcript = "test_transcript")
Converts a model's normalized scores to Kd values using affinity scaling. Score is assumed to be proportional to affinity (Ka), so Kd = 1/Ka.
setModel(models, max_affinity = 100, min_affinity = 1e-05)setModel(models, max_affinity = 100, min_affinity = 1e-05)
models |
Named list of models (from loadModel), each with 'motif' and 'score'. |
max_affinity |
Named numeric vector of max Ka per RBP, or single default (100). |
min_affinity |
Named numeric vector of min Ka per RBP, or single default (0.00001). |
A named list of data.tables, each with 'motif' and 'Kd' columns.
# Load and process model model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") raw_models <- loadModel(model_file) rbp_models <- setModel(raw_models, max_affinity = 100) # Check Kd values head(rbp_models[[1]])# Load and process model model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") raw_models <- loadModel(model_file) rbp_models <- setModel(raw_models, max_affinity = 100) # Check Kd values head(rbp_models[[1]])
Simulates competitive binding of multiple RBPs to a single RNA sequence.
simulateBinding(sequence, rbp_models, protein_concs, rna_conc = 10, k = 5)simulateBinding(sequence, rbp_models, protein_concs, rna_conc = 10, k = 5)
sequence |
RNA sequence string. |
rbp_models |
Named list of data.frames/data.tables with 'motif' and 'Kd'. |
protein_concs |
Named numeric vector of total protein concentrations. |
rna_conc |
Total RNA concentration (default 10). |
k |
K-mer size (default 5). |
A data.table containing per-position binding probabilities/occupancies.
# Load and process model model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") raw_models <- loadModel(model_file, rbp = c("HH", "HL")) rbp_models <- setModel(raw_models, max_affinity = 100) # Simulate binding on a short sequence seq <- "ACGUACGUACGUACGUACGU" results <- simulateBinding(seq, rbp_models, c(HH = 100, HL = 100), rna_conc = 10) head(results)# Load and process model model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") raw_models <- loadModel(model_file, rbp = c("HH", "HL")) rbp_models <- setModel(raw_models, max_affinity = 100) # Simulate binding on a short sequence seq <- "ACGUACGUACGUACGUACGU" results <- simulateBinding(seq, rbp_models, c(HH = 100, HL = 100), rna_conc = 10) head(results)
Simulates competitive binding for all sequences in one or more FASTA files.
Concurrency is controlled by the user's active plan (default is sequential).
simulateBindingFasta( fasta_file, rbp_models, protein_concs, rna_conc = 10, k = 5 )simulateBindingFasta( fasta_file, rbp_models, protein_concs, rna_conc = 10, k = 5 )
fasta_file |
Character vector of path(s) to FASTA files. |
rbp_models |
Named list of RBP models. |
protein_concs |
Named numeric vector of protein concentrations. |
rna_conc |
RNA concentration (default 10). |
k |
K-mer size (default 5). |
A data.table with combined results, including a transcript column.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") fasta_file <- system.file("extdata", "test_transcripts.fa", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBindingFasta(fasta_file, rbp_models, c(HH = 100, HL = 100)) head(results)model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") fasta_file <- system.file("extdata", "test_transcripts.fa", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateBindingFasta(fasta_file, rbp_models, c(HH = 100, HL = 100)) head(results)
Runs simulations across a grid of protein/RNA concentrations.
Concurrency is controlled by the user's active plan (default is sequential).
simulateGrid(sequence, rbp_models, protein_conc_grid, rna_conc_grid, k = 5)simulateGrid(sequence, rbp_models, protein_conc_grid, rna_conc_grid, k = 5)
sequence |
RNA sequence string. |
rbp_models |
Named list of RBP models. |
protein_conc_grid |
List of numeric vectors for each RBP concentration. |
rna_conc_grid |
Numeric vector of RNA concentrations to sweep. |
k |
K-mer size (default 5). |
A data.table with results for all grid combinations.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) grid <- simulateGrid("ACGUACGU", rbp_models, protein_conc_grid = list(HH = c(10, 100), HL = c(10, 100)), rna_conc_grid = 10) head(grid)model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) grid <- simulateGrid("ACGUACGU", rbp_models, protein_conc_grid = list(HH = c(10, 100), HL = c(10, 100)), rna_conc_grid = 10) head(grid)
Simulates competitive binding for all sequences in one or more FASTA files across a concentration grid.
Concurrency is controlled by the user's active plan (default is sequential).
simulateGridFasta( fasta_file, rbp_models, protein_conc_grid, rna_conc_grid, k = 5 )simulateGridFasta( fasta_file, rbp_models, protein_conc_grid, rna_conc_grid, k = 5 )
fasta_file |
Character vector of path(s) to FASTA files. |
rbp_models |
Named list of RBP models. |
protein_conc_grid |
List of numeric vectors for each RBP concentration. |
rna_conc_grid |
Numeric vector of RNA concentrations to sweep. |
k |
K-mer size (default 5). |
A data.table with combined results, including a transcript column.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") fasta_file <- system.file("extdata", "test_transcripts.fa", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateGridFasta( fasta_file = fasta_file, rbp_models = rbp_models, protein_conc_grid = list(HH = c(10, 100), HL = c(10, 100)), rna_conc_grid = 10, k = 5 ) head(results)model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") fasta_file <- system.file("extdata", "test_transcripts.fa", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file, rbp = c("HH", "HL"))) results <- simulateGridFasta( fasta_file = fasta_file, rbp_models = rbp_models, protein_conc_grid = list(HH = c(10, 100), HL = c(10, 100)), rna_conc_grid = 10, k = 5 ) head(results)
Creates a histogram of Kd or Ka distributions for RBP models.
viewModel( rbp_models, rbp = NULL, metric = c("Kd", "Ka"), bins = 50, colors = NULL, alpha = 0.5, log_scale = FALSE )viewModel( rbp_models, rbp = NULL, metric = c("Kd", "Ka"), bins = 50, colors = NULL, alpha = 0.5, log_scale = FALSE )
rbp_models |
Named list of RBP model data.tables (from setModel). |
rbp |
Character vector of RBP names to plot (default NULL, plots all). |
metric |
Display metric: "Kd" (default) or "Ka" (affinity = 1/Kd). |
bins |
Number of histogram bins (default 50). |
colors |
Named vector of colors per RBP (default NULL, uses Okabe-Ito palette). |
alpha |
Transparency of histogram bars (default 0.5). |
log_scale |
Logical, use log10 scale for x-axis (default FALSE). |
A ggplot object.
model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file)) viewModel(rbp_models, metric = "Kd")model_file <- system.file("extdata", "model_RBP.csv", package = "RBPEqBind") rbp_models <- setModel(loadModel(model_file)) viewModel(rbp_models, metric = "Kd")