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", ...)

Arguments

x

A SummarizedExperiment object.

...

Optional arguments passed into mia::addDivergence().

time.col

Character scalar. Specifies a name of the column from colData that identifies the sampling time points for the samples.

assay.type

Character scalar. Specifies which assay values are used in the dissimilarity estimation. (Default: "counts")

time.interval

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)

group

Character scalar. Specifies a name of the column from colData that identifies the grouping of the samples. (Default: NULL)

method

Character scalar. Used to calculate the dissimilarity Method is passed to the function that is specified by dis.fun. (Default: "bray")

name

Character scalar. Specifies a column name for storing divergence results. (Default: "divergence")

name.time

Character scalar. Specifies a column name for storing time differences. (Default: "time_diff")

Value

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.

Details

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).

Examples

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"
    )