Description Usage Arguments Details Value See Also Examples
View source: R/functions_signal_operations.R
applySpline
Is intended for two-dimensional tidy data.tables, as
retured by ssvFetchBigwig
1 | applySpline(dt, n, x_ = "x", y_ = "y", by_ = "", splineFun = stats::spline)
|
dt |
a tidy data.table containing two-dimensional data |
n |
the number of interpolation points to use per input point, see
|
x_ |
the variable name of the x-values |
y_ |
the variable name of the y-values |
by_ |
optionally, any variables that provide grouping to the data. default is none. see details. |
splineFun |
a function that accepts x, y, and n as arguments and
returns a list of length 2 with named elements x and y.
|
by_ is quite powerful. If by_ = c('gene_id', 'sample_id')
,
splines
will be calculated individually for each gene in each sample. alternatively
if by_ = c('gene_id')
a newly derived data.table that is n
times longer than
original.
1 2 3 4 5 6 7 8 9 10 11 | #data may be blockier than we'd like
ggplot(CTCF_in_10a_profiles_dt[, list(y = mean(y)), by = list(sample, x)]) +
geom_line(aes(x = x, y = y, color = sample))
#can be smoothed by applying a spline (think twice about doing so,
#it may look prettier but may also be deceptive or misleading)
splined_smooth = applySpline(CTCF_in_10a_profiles_dt, n = 10,
y_ = 'y', by_ = c('id', 'sample'))
ggplot(splined_smooth[, list(y = mean(y)), by = list(sample, x)]) +
geom_line(aes(x = x, y = y, color = sample))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.