| Title: | Quantification of DNA Methylation Signatures in TFBS |
|---|---|
| Description: | methylTFR is an extensive R package designed specifically for analyzing DNA methylation signatures within transcription factor binding sites (TFBS) across diverse genomic annotations. It enhances methylation analysis by calculating a bias-corrected 'deviation' in methylation levels, leveraging GC bias distribution and frequency data. This package offers a variety of functions that facilitate the motif activity exhibiting diverse methylation patterns across distinct samples or cells. |
| Authors: | Irem B. Gündüz [aut, cre] (ORCID: <https://orcid.org/0000-0003-2641-0916>), Sarath Kumar Murugan [aut] (ORCID: <https://orcid.org/0000-0001-7378-7869>), Fabian Mueller [aut] (ORCID: <https://orcid.org/0000-0001-5809-2321>), ERA-NET Transcan-Neu III - EPILUNAR [fnd] (Grant 01KT2409), Saarland University [fnd] (NanoBioMed Young Investigator Grant) |
| Maintainer: | Irem B. Gündüz <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.12 |
| Built: | 2026-11-20 21:33:17 UTC |
| Source: | https://github.com/bioc/methylTFR |
Assign each methylation site to the GC bin of the genomic window it falls in, and compute the average methylation per GC bin.
addGCBinToMethylome(msites, gcdist, ignoreStrand = TRUE)addGCBinToMethylome(msites, gcdist, ignoreStrand = TRUE)
msites |
A |
gcdist |
A |
ignoreStrand |
Logical. If |
The result describes how methylation depends on local GC
content in this sample. computeDeviation combines it with
the per-motif GC profile in gcfreqs to obtain the methylation
expected at the binding sites from sequence composition alone.
A matrix with one row per GC bin and the columns
gcbin and avg_mscore. Pass it as binMsites to
computeDeviation.
Irem Gunduz
computeDeviation, readMethylome
load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) bin_meth <- addGCBinToMethylome(msites, gcdist) bin_methload(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) bin_meth <- addGCBinToMethylome(msites, gcdist) bin_meth
Combine methylTFRdeviations objects by column.
## S4 method for signature 'methylTFRdeviations' cbind(..., deparse.level = 1)## S4 method for signature 'methylTFRdeviations' cbind(..., deparse.level = 1)
... |
methylTFRdeviations objects. |
deparse.level |
passed to the underlying method. |
Defined explicitly rather than left to inheritance. Although
methylTFRdeviations extends SummarizedExperiment,
whether that class's cbind method is found for a subclass
defined in another package depends on the search path and on the
Bioconductor version: dispatch can fall through to the
S4Vectors method, which then fails with "unable to find an
inherited method for function 'bindCOLS'".
The objects are therefore coerced to SummarizedExperiment
explicitly, combined there, and re-wrapped. This is defined with
setMethod on the existing generic rather than
setGeneric, so it does not shadow the base function and any
number of objects can be combined.
A methylTFRdeviations object.
load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) load(system.file("extdata", "tc_naive.rda", package = "methylTFR")) devs <- cbind(tc_mem, tc_naive)load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) load(system.file("extdata", "tc_naive.rda", package = "methylTFR")) devs <- cbind(tc_mem, tc_naive)
Compute the bias-corrected deviation score of one motif in one sample.
computeDeviation( motif, msites, tf_bindsites, gcfreqs, enhancer = NULL, ignoreStrand = TRUE, binMsites, extendBy = 130, windowBreaks = c(-250, -200, -25, 25, 200, 250) )computeDeviation( motif, msites, tf_bindsites, gcfreqs, enhancer = NULL, ignoreStrand = TRUE, binMsites, extendBy = 130, windowBreaks = c(-250, -200, -25, 25, 200, 250) )
motif |
Name of the motif, one of |
msites |
A |
tf_bindsites |
A |
gcfreqs |
A named |
enhancer |
An optional |
ignoreStrand |
Logical. If |
binMsites |
The matrix returned by |
extendBy |
Number of base pairs added to the width of each binding site before overlapping it with the methylation sites, split evenly between both sides. Default 130. |
windowBreaks |
Six strictly increasing distances from the site
centre, in base pairs, that define the five distance bins. Bins 1 and 5
are the outer flanks and bin 3 is the centre. Default
|
Each binding site is widened by extendBy base pairs and every CpG
inside it is placed by its distance to the site centre. The distances
are cut into five bins at windowBreaks: an outer left flank, an
inner left region, the centre, an inner right region and an outer right
flank. The observed score is the mean methylation in the centre bin
divided by the mean of the two outer flank bins. The same ratio is
computed for the methylation expected from GC content (see
addGCBinToMethylome), and the deviation is the observed
minus the expected ratio. If the centre or either outer flank bin holds
no CpG, the score is NA.
Every CpG counts once, whatever its read coverage: the bin means are
unweighted means of the per-CpG methylation fractions. Coverage only
enters through the cov_threshold filter applied when the data are
read.
A data.table with one row and the columns dev
(bias-corrected deviation) and exp_dev (expected deviation).
runMethylTFR to score all motifs and samples at
once, plotMotifFootprint to see the profile behind the
score.
load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) bin_meth <- addGCBinToMethylome(msites, gcdist, TRUE) computeDeviation( motif = "BATF", msites = msites, tf_bindsites = tf_bindsites, gcfreqs = gcfreqs, enhancer = NULL, ignoreStrand = TRUE, binMsites = bin_meth )load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) bin_meth <- addGCBinToMethylome(msites, gcdist, TRUE) computeDeviation( motif = "BATF", msites = msites, tf_bindsites = tf_bindsites, gcfreqs = gcfreqs, enhancer = NULL, ignoreStrand = TRUE, binMsites = bin_meth )
Identify transcription factor motifs whose methylTFR activity varies across samples more than expected by chance.
computeZScoreVariability( object, method = c("robust", "gaussian"), bootstrap = FALSE, niterations = 1000L, conf_level = 0.95, padjMethod = "BH" )computeZScoreVariability( object, method = c("robust", "gaussian"), bootstrap = FALSE, niterations = 1000L, conf_level = 0.95, padjMethod = "BH" )
object |
A |
method |
Either |
bootstrap |
logical, if TRUE bootstrap confidence bounds for the variability estimates are computed by resampling samples with replacement. |
niterations |
Number of bootstrap iterations, used only when
|
conf_level |
Confidence level for the bootstrap bounds. |
padjMethod |
Method for p-value adjustment, passed to
|
Variability is defined as the standard deviation, across samples, of
calibrated deviation scores. Calibration is what makes the number
interpretable: deviation scores are first standardised against a
within-sample null estimated across all motifs (see
calibrateDeviations), so that a calibrated score of 1 corresponds to
one unit of sample-level noise. A motif with variability greater than 1
therefore varies across samples by more than the background spread, and
variability near 1 is what a motif carrying no signal is expected to show.
Under the null hypothesis that a motif's calibrated scores are independent
draws from a standard normal distribution, follows a
chi-squared distribution with degrees of freedom, where
is the observed variability and the number of samples with a
non-missing score for that motif. P-values are obtained from the upper tail
of that distribution and adjusted for multiple testing across motifs.
Note that this function must not be applied to the z assay returned
by deviationZScores. Those are row-wise Z-scores computed for
visualisation, and their standard deviation across samples is 1 for every
motif by construction, which would make the test degenerate. The default
input is therefore the deviations assay.
The approach is analogous to chromVAR::computeVariability, with one
difference: chromVAR calibrates each motif against a set of GC- and
width-matched background peak sets, whereas here the null is estimated
across motifs within each sample. The latter needs no additional deviation
computations and can be applied to existing results, at the cost of
assuming that most motifs are inactive in any given sample.
A data.frame with one row per motif and the columns
motifs, variability, p_value and
p_value_adjusted, plus bootstrap_lower_bound and
bootstrap_upper_bound when bootstrap is TRUE. Rows are
returned in the order of the input.
Irem Gunduz
differentialDeviationTest for testing activity
differences between predefined groups.
# Load example data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) load(system.file("extdata", "tc_naive.rda", package = "methylTFR")) devs <- cbind(tc_mem, tc_naive) # Rank motifs by how much their activity varies across samples var_res <- computeZScoreVariability(devs) head(var_res[order(-var_res$variability), ])# Load example data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) load(system.file("extdata", "tc_naive.rda", package = "methylTFR")) devs <- cbind(tc_mem, tc_naive) # Rank motifs by how much their activity varies across samples var_res <- computeZScoreVariability(devs) head(var_res[order(-var_res$variability), ])
Function to get deviations from a methylTFRdeviations object.
deviations(x)deviations(x)
x |
A methylTFRdeviations object. |
A matrix of deviations.
# Load example data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviations deviations(tc_mem)# Load example data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviations deviations(tc_mem)
Extract bias corrected deviations from methylTFRdeviations object.
## S4 method for signature 'methylTFRdeviations' deviations(x)## S4 method for signature 'methylTFRdeviations' deviations(x)
x |
methylTFRdeviations object. |
A matrix of bias corrected deviations.
# Load the data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviations deviations(tc_mem)# Load the data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviations deviations(tc_mem)
Function to get deviation Z-scores from a methylTFRdeviations object.
deviationZScores(x)deviationZScores(x)
x |
A methylTFRdeviations object. |
A matrix of deviation Z-scores.
# Load example data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviation Z-scores deviationZScores(tc_mem)# Load example data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviation Z-scores deviationZScores(tc_mem)
Extract deviation Z-scores from methylTFRdeviations object.
## S4 method for signature 'methylTFRdeviations' deviationZScores(x)## S4 method for signature 'methylTFRdeviations' deviationZScores(x)
x |
methylTFRdeviations object. |
A matrix of deviation Z-scores.
# Load the data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviation Z-scores deviationZScores(tc_mem)# Load the data load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) # Get deviation Z-scores deviationZScores(tc_mem)
Test which motifs have different deviation scores between
groups of samples. Adapted from chromVAR::differentialDeviations.
differentialDeviationTest( deviations, groups = NULL, motifs = rownames(deviations), alternative = c("two.sided", "less", "greater"), parametric = TRUE, padjMethod = "BH" )differentialDeviationTest( deviations, groups = NULL, motifs = rownames(deviations), alternative = c("two.sided", "less", "greater"), parametric = TRUE, padjMethod = "BH" )
deviations |
A |
groups |
A vector with one group label per sample. If |
motifs |
Motif names, by default |
alternative |
The alternative hypothesis of the two-group tests,
one of |
parametric |
Logical. If |
padjMethod |
Method for p-value adjustment, passed to
|
With two groups, a Welch t-test (parametric = TRUE) or a
Wilcoxon rank sum test is used; with more groups, a one-way ANOVA or a
Kruskal-Wallis test.
A data.frame with one row per motif and the columns
motifs, p_value, p_value_adjusted and
mean_difference. For two groups, mean_difference is the
mean of the first group minus the mean of the second; for more groups,
it is the range of the group means.
computeZScoreVariability for ranking motifs
without group labels.
load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) load(system.file("extdata", "tc_naive.rda", package = "methylTFR")) devs <- cbind(tc_mem, tc_naive) # Construct group labels from sample names groups <- sub("\\.bedGraph.*$", "", vapply( strsplit(colnames(devs), split = "_"), `[`, character(1), 1L )) tc_result <- differentialDeviationTest( deviations = devs, groups = groups, alternative = "two.sided", parametric = TRUE, padjMethod = "BH" ) head(tc_result)load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) load(system.file("extdata", "tc_naive.rda", package = "methylTFR")) devs <- cbind(tc_mem, tc_naive) # Construct group labels from sample names groups <- sub("\\.bedGraph.*$", "", vapply( strsplit(colnames(devs), split = "_"), `[`, character(1), 1L )) tc_result <- differentialDeviationTest( deviations = devs, groups = groups, alternative = "two.sided", parametric = TRUE, padjMethod = "BH" ) head(tc_result)
Class for storing results from
runMethylTFR and runMethylTFRFromRnBeads.
This class inherits from
SummarizedExperiment, and most methods
for that class should work for objects of this class as well. Additionally,
two accessor functions are defined for extracting bias corrected
deviations (deviations)
and deviation Z-scores
(
deviationZScores).
Plot the observed methylation profile around the binding sites of one motif together with the profile expected from GC content.
plotExpectedFootprint( motif, tf_bindsites, msites, sample_name = NULL, gc_dist, gcfreqs, enhancer = NULL, returnPlotData = FALSE )plotExpectedFootprint( motif, tf_bindsites, msites, sample_name = NULL, gc_dist, gcfreqs, enhancer = NULL, returnPlotData = FALSE )
motif |
Name of the motif, one of |
tf_bindsites |
A |
msites |
A |
sample_name |
Optional sample label used in the plot title.
Default |
gc_dist |
A |
gcfreqs |
A named |
enhancer |
An optional |
returnPlotData |
Logical. If |
A ggplot object, or, if returnPlotData is
TRUE, a list with the elements plot and plotDF.
plotMotifFootprint for the bias-corrected
profile, computeDeviation for the score it summarises.
load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) p <- plotExpectedFootprint( motif = "BATF", tf_bindsites = tf_bindsites, msites = msites, sample_name = "Sample1", gc_dist = gcdist, gcfreqs = gcfreqs, enhancer = NULL, returnPlotData = FALSE )load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) p <- plotExpectedFootprint( motif = "BATF", tf_bindsites = tf_bindsites, msites = msites, sample_name = "Sample1", gc_dist = gcdist, gcfreqs = gcfreqs, enhancer = NULL, returnPlotData = FALSE )
Plot the bias-corrected methylation profile around the binding sites of one motif in one sample.
plotMotifFootprint( motif, tf_bindsites, msites, sample_name = NULL, gc_dist, gcfreqs, enhancer = NULL, method = "division", flankNorm = 50 )plotMotifFootprint( motif, tf_bindsites, msites, sample_name = NULL, gc_dist, gcfreqs, enhancer = NULL, method = "division", flankNorm = 50 )
motif |
Name of the motif, one of |
tf_bindsites |
A |
msites |
A |
sample_name |
Optional sample label used in the plot title.
Default |
gc_dist |
A |
gcfreqs |
A named |
enhancer |
An optional |
method |
How observed and expected profiles are combined, either
|
flankNorm |
Width in base pairs of the outer flanking window used
to normalise the curve. Default 50; |
A ggplot object.
plotExpectedFootprint for the two profiles
before correction.
load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) p <- plotMotifFootprint( motif = "BATF", tf_bindsites = tf_bindsites, msites = msites, sample_name = "Sample1", gc_dist = gcdist, gcfreqs = gcfreqs, enhancer = NULL, method = "division" )load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) p <- plotMotifFootprint( motif = "BATF", tf_bindsites = tf_bindsites, msites = msites, sample_name = "Sample1", gc_dist = gcdist, gcfreqs = gcfreqs, enhancer = NULL, method = "division" )
Combine methylTFRdeviations objects by row.
## S4 method for signature 'methylTFRdeviations' rbind(..., deparse.level = 1)## S4 method for signature 'methylTFRdeviations' rbind(..., deparse.level = 1)
... |
methylTFRdeviations objects. |
deparse.level |
passed to the underlying method. |
See cbind for why this is defined explicitly
rather than inherited.
A methylTFRdeviations object.
load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) devs <- rbind(tc_mem[seq_len(2), ], tc_mem[3:4, ])load(system.file("extdata", "tc_mem.rda", package = "methylTFR")) devs <- rbind(tc_mem[seq_len(2), ], tc_mem[3:4, ])
Import single-sample methylation calls into a
GRanges object.
readMethylome(filename, type, cov_threshold = 1)readMethylome(filename, type, cov_threshold = 1)
filename |
Path to the methylation call file. Gzipped files are read directly. |
type |
Format of the file, one of |
cov_threshold |
Numeric. Sites with fewer reads than this are dropped. Default 1. |
A GRanges object with one range per CpG and the metadata
columns score (methylation fraction between 0 and 1) and
coverage (read count). This is the msites input of
computeDeviation, addGCBinToMethylome and
the footprint plots.
Irem Gunduz
runMethylTFR, which calls this function for every
sample.
# Read bissnp file bissnp_path <- system.file( "extdata", "bissnp.tsv.gz", package = "methylTFR" ) bissnp <- readMethylome(bissnp_path, "bissnp")# Read bissnp file bissnp_path <- system.file( "extdata", "bissnp.tsv.gz", package = "methylTFR" ) bissnp <- readMethylome(bissnp_path, "bissnp")
Compute bias-corrected deviation scores for every motif and every sample listed in a sample annotation file.
runMethylTFR( sample_ann, sample_dir, tf_bindsites = NULL, gcfreqs = NULL, gc_dist = NULL, sampleColName = "bedFile", chunkSize = 20, full_path = FALSE, annfile = NULL, threads = 1, enhancer = NULL, filetype = NULL, ignoreStrand = TRUE, cov_threshold = 1, tempDir = file.path(tempdir(), "methylTFR") )runMethylTFR( sample_ann, sample_dir, tf_bindsites = NULL, gcfreqs = NULL, gc_dist = NULL, sampleColName = "bedFile", chunkSize = 20, full_path = FALSE, annfile = NULL, threads = 1, enhancer = NULL, filetype = NULL, ignoreStrand = TRUE, cov_threshold = 1, tempDir = file.path(tempdir(), "methylTFR") )
sample_ann |
Name of a tab-separated ( |
sample_dir |
Directory holding the methylation call files (and, usually, the sample annotation file). |
tf_bindsites |
A |
gcfreqs |
A named |
gc_dist |
A |
sampleColName |
Name of the column in |
chunkSize |
Number of motifs processed together in one block. Default 20. |
full_path |
Logical. If |
annfile |
Optional path to the sample annotation file. If given,
it is used instead of |
threads |
Number of workers used to process the motifs of a chunk in parallel. Default 1 (serial). |
enhancer |
An optional |
filetype |
Format of the methylation call files, one of
|
ignoreStrand |
Logical. If |
cov_threshold |
Numeric. Sites with fewer reads than this are dropped. Default 1. |
tempDir |
Directory for the temporary HDF5 files written during a
run. Default is a folder under |
Each sample is read with readMethylome, binned by
GC content with addGCBinToMethylome and scored per motif
with computeDeviation.
A methylTFRdeviations object with the assays
deviations, z and expected, motifs in rows and
samples in columns.
runMethylTFRFromRnBeads for running methylTFR
directly on a preprocessed RnBeads object, deviations and
deviationZScores to extract the scores.
# A minimal end-to-end run on the BATF example data bundled with the # package. The annotation objects cover a single motif, so the result # has one row. load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) # runMethylTFR() reads per-sample calls from disk, so the bundled sites # are written out as a bismarkCov file first. sample_dir <- tempfile("methylTFR_example") dir.create(sample_dir) n_meth <- round(msites$score * msites$coverage) write.table( data.frame( chr = as.character(GenomicRanges::seqnames(msites)), start = GenomicRanges::start(msites), end = GenomicRanges::end(msites), percent = msites$score * 100, meth = n_meth, unmeth = msites$coverage - n_meth ), file.path(sample_dir, "sample_1.cov"), sep = "\t", row.names = FALSE, col.names = FALSE, quote = FALSE ) write.table( data.frame(sampleName = "sample_1", bedFile = "sample_1.cov"), file.path(sample_dir, "samples.tsv"), sep = "\t", row.names = FALSE, quote = FALSE ) devs <- runMethylTFR( sample_ann = "samples.tsv", sample_dir = sample_dir, tf_bindsites = tf_bindsites, gcfreqs = gcfreqs, gc_dist = gcdist, filetype = "bismarkCov" ) deviations(devs) unlink(sample_dir, recursive = TRUE)# A minimal end-to-end run on the BATF example data bundled with the # package. The annotation objects cover a single motif, so the result # has one row. load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) # runMethylTFR() reads per-sample calls from disk, so the bundled sites # are written out as a bismarkCov file first. sample_dir <- tempfile("methylTFR_example") dir.create(sample_dir) n_meth <- round(msites$score * msites$coverage) write.table( data.frame( chr = as.character(GenomicRanges::seqnames(msites)), start = GenomicRanges::start(msites), end = GenomicRanges::end(msites), percent = msites$score * 100, meth = n_meth, unmeth = msites$coverage - n_meth ), file.path(sample_dir, "sample_1.cov"), sep = "\t", row.names = FALSE, col.names = FALSE, quote = FALSE ) write.table( data.frame(sampleName = "sample_1", bedFile = "sample_1.cov"), file.path(sample_dir, "samples.tsv"), sep = "\t", row.names = FALSE, quote = FALSE ) devs <- runMethylTFR( sample_ann = "samples.tsv", sample_dir = sample_dir, tf_bindsites = tf_bindsites, gcfreqs = gcfreqs, gc_dist = gcdist, filetype = "bismarkCov" ) deviations(devs) unlink(sample_dir, recursive = TRUE)
Run the methylTFR workflow directly on a preprocessed RnBeads object, without exporting per-sample BED files first.
runMethylTFRFromRnBeads( rnb_set, tf_bindsites = NULL, gcfreqs = NULL, gc_dist = NULL, chunkSize = 20, threads = 1, enhancer = NULL, ignoreStrand = TRUE, cov_threshold = 1, dpval_threshold = 0.05, sample_ann = NULL, tempDir = file.path(tempdir(), "methylTFR") )runMethylTFRFromRnBeads( rnb_set, tf_bindsites = NULL, gcfreqs = NULL, gc_dist = NULL, chunkSize = 20, threads = 1, enhancer = NULL, ignoreStrand = TRUE, cov_threshold = 1, dpval_threshold = 0.05, sample_ann = NULL, tempDir = file.path(tempdir(), "methylTFR") )
rnb_set |
A preprocessed |
tf_bindsites |
A |
gcfreqs |
A named |
gc_dist |
A |
chunkSize |
Number of motifs processed together in one block. Default 20. |
threads |
Number of workers used to process the motifs of a chunk in parallel. Default 1 (serial). |
enhancer |
An optional |
ignoreStrand |
Logical. If |
cov_threshold |
Numeric, minimum coverage of a retained site. Used only for sequencing sets. Default 1. |
dpval_threshold |
Numeric, maximum detection p-value of a retained probe. Used only for array sets. Default 0.05. |
sample_ann |
Optional |
tempDir |
Directory for the temporary HDF5 files written during a
run. Default is a folder under |
Methylation calls are read at single-cytosine resolution. Sequencing
sets (RnBiseqSet) are filtered by coverage, array sets
(RnBeadSet) by detection p-value. The number of sites retained
per sample is reported through logger.
A methylTFRdeviations object with the assays
deviations, z and expected, motifs in rows and
samples in columns.
runMethylTFR for running methylTFR from
per-sample BED files.
# A minimal end-to-end run on the BATF example data bundled with the # package. The bundled calls are wrapped in an RnBiseqSet so that the # example exercises the same code path as a preprocessed RnBeads object. load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) if (requireNamespace("RnBeads", quietly = TRUE) && requireNamespace("RnBeads.hg38", quietly = TRUE)) { # identifiers.column is a session option, not a property of the object, # so it has to be set before the set is built or samples() falls back # to row numbers and methylTFR cannot name the columns it returns old_ids <- RnBeads::rnb.getOption("identifiers.column") RnBeads::rnb.options(identifiers.column = "sampleName") sites <- data.frame( chr = as.character(GenomicRanges::seqnames(msites)), start = GenomicRanges::start(msites), strand = "*", stringsAsFactors = FALSE ) rnb_set <- RnBeads::RnBiseqSet( pheno = data.frame(sampleName = "sample_1"), sites = sites, meth = matrix(msites$score, ncol = 1, dimnames = list(NULL, "sample_1")), covg = matrix(msites$coverage, ncol = 1, dimnames = list(NULL, "sample_1")), assembly = "hg38", summarize.regions = FALSE ) devs <- runMethylTFRFromRnBeads( rnb_set = rnb_set, tf_bindsites = tf_bindsites, gcfreqs = gcfreqs, gc_dist = gcdist ) RnBeads::rnb.options(identifiers.column = old_ids) deviations(devs) }# A minimal end-to-end run on the BATF example data bundled with the # package. The bundled calls are wrapped in an RnBiseqSet so that the # example exercises the same code path as a preprocessed RnBeads object. load(system.file("extdata", "example_data.rda", package = "methylTFR")) load(system.file("extdata", "BATF_tf_bindsites.rda", package = "methylTFR")) load(system.file("extdata", "BATF_gcfreqs.rda", package = "methylTFR")) load(system.file("extdata", "gcdist_subset.rda", package = "methylTFR")) if (requireNamespace("RnBeads", quietly = TRUE) && requireNamespace("RnBeads.hg38", quietly = TRUE)) { # identifiers.column is a session option, not a property of the object, # so it has to be set before the set is built or samples() falls back # to row numbers and methylTFR cannot name the columns it returns old_ids <- RnBeads::rnb.getOption("identifiers.column") RnBeads::rnb.options(identifiers.column = "sampleName") sites <- data.frame( chr = as.character(GenomicRanges::seqnames(msites)), start = GenomicRanges::start(msites), strand = "*", stringsAsFactors = FALSE ) rnb_set <- RnBeads::RnBiseqSet( pheno = data.frame(sampleName = "sample_1"), sites = sites, meth = matrix(msites$score, ncol = 1, dimnames = list(NULL, "sample_1")), covg = matrix(msites$coverage, ncol = 1, dimnames = list(NULL, "sample_1")), assembly = "hg38", summarize.regions = FALSE ) devs <- runMethylTFRFromRnBeads( rnb_set = rnb_set, tf_bindsites = tf_bindsites, gcfreqs = gcfreqs, gc_dist = gcdist ) RnBeads::rnb.options(identifiers.column = old_ids) deviations(devs) }