Learn R Programming

MotilityLab (version 0.2-5)

as.tracks.data.frame: Convert from Data Frame to Tracks

Description

Get cell tracks from a data.frame. Data are expected to be organized as follows. One column contains a track identifier, which can be numeric or a string, and determines which points belong to the same track. Another column is expected to contain a time index or a time period (e.g. number of seconds elapsed since the beginning of the track, or since the beginning of the experiment). Input of dates is not (yet) supported, as absolute time information is frequently not available. Further columns contain the spatial coordinates. If there are three or less spatial coordinates, their names will by "x", "y", and "z" (depending on whether the tracks are 1D, 2D or 3D). If there are four or more spatial coordinates, their names will be "x1", "x2", and so on. The names or indices of these columns in the data.frame are given using the corresponding parameters (see below). Names and indices can be mixed, e.g. you can specify id.column="Parent" and pos.columns=1:3

Usage

"as.tracks"(x, id.column = 1, time.column = 2, pos.columns = c(3, 4, 5), scale.t = 1, scale.pos = 1, ...)

Arguments

x
the data frame to be coerced to a tracks object.
id.column
index or name of the column that contains the track ID.
time.column
index or name of the column that contains elapsed time.
pos.columns
vector containing indices or names of the columns that contain the spatial coordinates. If this vector has two entries and the second entry is NA, e.g. c('x',NA) or c(5,NA) then all columns from the indicated column to the last column are used. This is useful when reading files where the exact number of spatial dimensions is not known beforehand.
scale.t
a value by which to multiply each time point. Useful for changing units, or for specifying the time between positions if this is not contained in the file itself.
scale.pos
a value, or a vector of values, by which to multiply each spatial position. Useful for changing units.
...
further arguments to be passed to read.csv, for instance sep="\t" can be useful for tab-separated files.