msd {sojourner} | R Documentation

## msd

### Description

calculate mean square displacement for individual trajectory or summarize on trajectories.

### Usage

    msd(trackll,dt=6,resolution=0.107,summarize=FALSE,cores=1,
    plot=FALSE,output=FALSE,filter=c(min=7,max=Inf))
      msd.track.vecdt(trackll,vecdt=NULL,resolution=0.107,output=FALSE)
      msd.perc(trackll,percentage=0.25,filter=c(min=7,max=Inf),
    trimmer=c(min=1,max=31),resolution=0.107,output=FALSE)

### Arguments

`dt` | Time intervals. Default 6.
`resolution` | ratio of pixel to uM.
`trackll` | Track list output from createTrackll().
`summarize` | An logical indicate if MSD should be calculated on individual trajectories (Default) or summarized on all trajectories.
`filter` | a vector specifies the minimum and max length of trajecotries to be analyzed. Take only trajectories that has number of frames greater than (>=) min and less than (<) max.
`cores` | Number of cores used for parallel computation. This can be the cores on a workstation, or on a cluster. Tip: the computation on each file will be parallel assigned to each CPU core.
`plot` | An logical indicate if plot should be generated. See Values for detail.
`output` | An logical indicate if output should be generated. See Values for detail.
`vecdt` | A list containing varying dt values.
`percentage` | compute msd based on (tierd) percentage of its total length.
`trimmer` | vector used for trimming via trimTrack()

### Details

msd() calculate track (/trajectory)'s mean square displacement as a function of time (dt). For a track of N steps, at each dt, there are N-dt number of sub-trajectory/sub-tracks, mean of dt-wise sub-trajectories/ step-wise sub tracks average subtracks into one number at each dt.

the dt number of su-btracks each contains N:N-dt steps. Because minimum step is 1 (N-dt > = 1), so the maxium dt is N-1 (dt < = N-1). As dt increase, the number of steps used to generate that mean decrease with the maxmum dt (dt=N-1) generated from one step.

if one wants to focus on a group of trajectory's evolution, he can simply filter on a number that is bigger than the dt he wanted to plot MSD.

by assinging cores, computation is paralelled on each each list of trackll (corresponding to one movie file).

### Value

- SummarizedMSD MSD summarized over all trajectories as a function of dt.

- InidvidualMSD MSD of individual trajectories at specified dt. Row number corresponding to its dt. Notice only the trajectories that satisfies the specified dt is output, trajectories that does not satisfy (i.e. trajectories satisfies 1:(dt-1)) is not output here.

- StandardError Standard Error of the sample mean measures the variations of sample mean to underlying mean, it is estimated as SE=SD/sqrt(N).

- SampleSize The sample size (number of tracks/trajectories) used for calculating the msd and standard error.

- Trackll The msd function also returns the processed trackll. If passed to a variable, one can then export the trackll with this variable.

### Examples

    # read in using createTrackll()
    folder=system.file("extdata","SWR1",package="sojourner")
    trackll=createTrackll(folder=folder, input=3)

    # filter track based length
    trackll.flt=filterTrack(trackll,filter=c(min=5,max=Inf))
    msd=msd(trackll.flt,dt=6,summarize=TRUE,plot=TRUE)
    str(msd)

    # focus on a group of trajectory by setting filter greater than dt
    trackll.flt2=filterTrack(trackll,filter=c(min=7,max=Inf))
    msd2=msd(trackll.flt2,dt=6,summarize=FALSE,plot=TRUE) # individual
    msd2=msd(trackll.flt2,dt=6,summarize=TRUE,plot=TRUE) # summarized

[Package sojourner version 1.4.2 Index]