workflowTransfer {distantia}R Documentation

Transfers an attribute (time, age, depth) from one sequence to another

Description

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

Usage

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
  )

Arguments

sequences

dataframe with multiple sequences identified by a grouping column generated by prepareSequences.

grouping.column

character string, name of the column in sequences to be used to identify separates sequences within the file.

time.column

character string, name of the column with time/depth/rank data.

exclude.columns

character string or character vector with column names in sequences to be excluded from the analysis.

method

character string naming a distance metric. Valid entries are: "manhattan", "euclidean", "chi", and "hellinger". Invalid entries will throw an error.

transfer.what

character string, column of sequences with the attribute to be transferred. If empty or ill-defined, time.column is used instead if available.

transfer.from

character string, group available in grouping.column identifying the sequence from which to take the attribute values.

transfer.to

character string, group available in grouping.column identifying the sequence to which transfer the attribute values.

mode

character string, one of: "direct" (default), "interpolate".

plot

boolean, if TRUE, plots the distance matrix and the least-cost path.

Value

A dataframe with the sequence transfer.to, with a column named after transfer.what with the attribute values.

Author(s)

Blas Benito <blasbenito@gmail.com>

Examples




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

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




[Package distantia version 1.0.2 Index]