-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
109 lines (84 loc) · 3.46 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
---
title: CelltrackR README
author: Inge Wortel and Johannes Textor
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# CelltrackR
CelltrackR is designed to help with describing, visualizing, and quantifying tracks
of moving objects. Many common measures used in physics and biology are implemented, such
as mean square displacement and autocorrelation. The package also provides a flexible
function to import tracks from text files.
The CelltrackR package has been developed as part of the MotilityLab project.
On the project website (motilitylab.net), a simple GUI frontend to many functions in the
package is implemented, and public datasets are available to download and analyze.
Indeed, the CelltrackR package was formerly called "MotilityLab", but we changed the
name to make this functionality easier to find.
See also: [https://ingewortel.github.io/celltrackR/](https://ingewortel.github.io/celltrackR/)
# Installation
The latest development version of CelltrackR can be installed from GitHub (note: this
requires the `devtools` package):
```{r,eval=FALSE}
devtools::install_github( "ingewortel/celltrackR" )
```
Then the package can be loaded as usual:
```{r}
library(celltrackR)
```
# Examples
Tracks are organized as lists of matrices, and have S3 class `tracks`. Three example
datasets are provided with the package. A `plot` method is implemented and can be used
to visualize these datasets:
```{r}
plot( TCells, col=1 )
plot( BCells, col=2 )
```
To generate a simple mean square displacement plot for the example dataset
`TCells', use:
```{r}
msqd <- aggregate( TCells, squareDisplacement )
plot( msqd, type='l' )
```
This computes the squared displacement (MSD) for over all subtracks of the dataset, and
computes the average stratified by subtrack length. To compute the MSD for non-overlapping
subtracks only, use:
```{r}
msqd <- aggregate( TCells, squareDisplacement, max.overlap=0 )
plot( msqd, type='l' )
```
MSD estimates can be biased in applications with a finite field of view (such as
microscopy), because slower objects remain in the field of view for longer times. This
can complicate comparisons between different populations. We may thus wish to restrict
our comparison to subtracks of a certain (short) length. This can be done as
follows:
```{r}
msqd.t <- aggregate( TCells, squareDisplacement, subtrack.length=1:5, max.overlap=0 )
msqd.b <- aggregate( TCells, squareDisplacement, subtrack.length=1:5, max.overlap=0 )
plot( msqd.t, type='l' )
lines( msqd.b, col=2 )
```
Another common measure to analyze tracks is the autocovariance function; geometrically
speaking,
this is the dot product between pairs of pairs of positions a fixed distance apart.
For random walks, the autocovariance decreases to 0 as the subtrack length increases.
The speed of convergence gives an indication of persistence of
orientation, a feature of many realistic objects. To compare persistence of the
T cells and B cells datasets, we can use:
```{r}
angle.t <- aggregate( TCells, overallDot )
angle.b <- aggregate( BCells, overallDot )
plot( angle.t, type='l' )
lines( angle.b, col=2 )
```
Many other ways to quantify tracks are implemented in the package and described in the
PDF documentation. For an overview of the available commands, use the function
```{r,eval=FALSE}
help( package="celltrackR" )
```