workflowTransfer.Rd
Transfers an attribute (generally time/age, but any others are possible) from one sequence (defined by the argument transfer.from
) to another (defined by the argument transfer.to
) lacking it. The transference of the attribute is based on the following assumption: similar samples have similar attributes. This assumption might not hold for noisy multivariate time-series. Attribute transference can be done in two different ways (defined by the mode
argument):
Direct: transfers the selected attribute between samples with the maximum similarity. This option will likely generate duplicated attribute values in the output.
Interpolate: obtains new attribute values through weighted interpolation, being the weights derived from the distances between samples
workflowTransfer(
sequences = NULL,
grouping.column = NULL,
time.column = NULL,
exclude.columns = NULL,
method = "manhattan",
transfer.what = NULL,
transfer.from = NULL,
transfer.to = NULL,
mode = "direct",
plot = FALSE
)
dataframe with multiple sequences identified by a grouping column generated by prepareSequences
.
character string, name of the column in sequences
to be used to identify separates sequences within the file.
character string, name of the column with time/depth/rank data.
character string or character vector with column names in sequences
to be excluded from the analysis.
character string naming a distance metric. Valid entries are: "manhattan", "euclidean", "chi", and "hellinger". Invalid entries will throw an error.
character string, column of sequences
with the attribute to be transferred. If empty or ill-defined, time.column
is used instead if available.
character string, group available in grouping.column
identifying the sequence from which to take the attribute values.
character string, group available in grouping.column
identifying the sequence to which transfer the attribute values.
character string, one of: "direct" (default), "interpolate".
boolean, if TRUE
, plots the distance matrix and the least-cost path.
A dataframe with the sequence transfer.to
, with a column named after transfer.what
with the attribute values.
# \donttest{
#loading sample dataset
data(pollenGP)
#subset pollenGP to make a shorter dataset
pollenGP <- pollenGP[1:50, ]
#generating a subset of pollenGP
set.seed(10)
pollenX <- pollenGP[sort(sample(1:50, 40)), ]
#we separate the age column
pollenX.age <- pollenX$age
#and remove the age values from pollenX
pollenX$age <- NULL
pollenX$depth <- NULL
#removing some samples from pollenGP
#so pollenX is not a perfect subset of pollenGP
pollenGP <- pollenGP[-sample(1:50, 10), ]
#prepare sequences
GP.X <- prepareSequences(
sequence.A = pollenGP,
sequence.A.name = "GP",
sequence.B = pollenX,
sequence.B.name = "X",
grouping.column = "id",
time.column = "age",
exclude.columns = "depth",
transformation = "none"
)
#> Warning: I couldn't find 'time.column' in 'sequenceB'. Added one and filled it with NA.
#transferring age
X.new <- workflowTransfer(
sequences = GP.X,
grouping.column = "id",
time.column = "age",
method = "manhattan",
transfer.what = "age",
transfer.from = "GP",
transfer.to = "X",
mode = "interpolated"
)
# }