R/AllGenerics.R
, R/getStepwiseDivergence.R
addStepwiseDivergence.Rd
Calculates sample dissimilarity between consecutive time points along with time difference.
getStepwiseDivergence(x, ...)
addStepwiseDivergence(x, ...)
# S4 method for class 'ANY'
getStepwiseDivergence(
x,
time.col,
assay.type = "counts",
time.interval = 1L,
group = NULL,
method = "bray",
...
)
# S4 method for class 'SummarizedExperiment'
addStepwiseDivergence(x, name = "divergence", name.time = "time_diff", ...)
A
SummarizedExperiment
object.
Optional arguments passed into
mia::addDivergence()
.
Character scalar
. Specifies a name of the column from
colData
that identifies the sampling time points for the samples.
Character scalar
. Specifies which assay values are
used in the dissimilarity estimation. (Default: "counts"
)
Integer scalar
. Indicates the increment between
time steps. By default, the function compares each sample to the
previous one. If you need to take every second, every third, or so, time
step, then increase this accordingly. (Default: 1L
)
Character scalar
. Specifies a name of the column from
colData
that identifies the grouping of the samples.
(Default: NULL
)
Character scalar
. Used to calculate the dissimilarity
Method is passed to the function that is specified by dis.fun
.
(Default: "bray"
)
Character scalar
. Specifies a column name for storing
divergence results. (Default: "divergence"
)
Character scalar
. Specifies a column name for storing
time differences. (Default: "time_diff"
)
getStepwiseDivergence
returns DataFrame
object
containing the sample dissimilarity and corresponding time difference between
samples. addStepwiseDivergence
, on the other hand, returns a
SummarizedExperiment
object with these results in its colData
.
These functions calculate time-wise divergence, meaning each sample is
compared to the previous i-th sample, where i is the specified time
interval (see time.interval
). By default, the function calculates
divergence by comparing all samples with each other. However, it is often
more meaningful to calculate divergence within a specific patient or group
(see the group
parameter).
library(miaTime)
data(hitchip1006)
tse <- transformAssay(hitchip1006, method = "relabundance")
# Calculate divergence
tse <- addStepwiseDivergence(
tse,
group = "subject",
time.interval = 1,
time.col = "time",
assay.type = "relabundance"
)