selComponentTracks {sojourner} | R Documentation

## selComponentTracks

### Description

Select trajectory based on component fitting on diffusion coefficient.

### Usage

    selComponentTracks(trackll,fit,likelihood=0.9,dcoef,
    log.transformed=FALSE,output=FALSE)

### Arguments

`trackll` | a list of track lists.
`fit` | Component fitting result form fitNormDistr() function.
`likelihood` | The likelihood of a trajecotry to be in fitted group. This parameter specifies the strigency of selecting trajectories to be in the fitted group and therefore influence the number of trajectories been selected.
`dcoef` | Diffusion coefficent calcualted by Dcoef, which provide the link between trajecotry index and diffusion coefficent.
`log.transformed` | A flag indicating if the fitting is been log transformed, select TRUE if fitting was done in fitNormDistr (log.transform = TRUE,..). This parameter will be removed in later version by directly read the info from the output of fitNormalDistr() function.
`output` | A logical indicating if output of selected trajectory index, which can be used for plot individual trajectory using plotTrack.

### Value

- combined list of trackll The result is a combined list of selected trajectories. The list is one level higher than trackll, use subsetting to output trackll.e.g. trackll[[1]], or trackll[['SWR1']].

### Examples

    ## selComponentTracks() usage
    # 1. select componentTracks per folder (cross movie) using compareFolders
    # 2. select componentTracks per movie base, use plotComponentTracks to plot
    # component tracks back to initial Nuclei image.

    ## 1. select componentTracks per folder (cross movie) by using
    ## compareFolders
    folder1=system.file('extdata','SWR1',package='sojourner')
    folder2=system.file('extdata','HTZ1',package='sojourner')
    trackll=compareFolder(folders=c(folder1,folder2), input=3)
    MSD=msd(trackll=trackll)
    dcoef=Dcoef(MSD,dt=6,plot=FALSE,output=FALSE)
    # fit dcoef
    # for replication purpose set seed to fix number
    set.seed(484)
    fit=fitNormDistr(dcoef,components=2,log.transform=TRUE,combine.plot=FALSE,
                     output=FALSE)

    # select component tracks from fitting
    trackll.sel=selComponentTracks(trackll=trackll,fit=fit,likelihood=0.9,
    dcoef=dcoef,log.transformed=TRUE,output=FALSE)
    # subset component tracks to further analyze msd, dcoef
    trackll.swr1=trackll.sel[['SWR1']]
    msd(trackll.swr1,plot=FALSE)
    msd(trackll.swr1,summarize=TRUE,plot=FALSE)
    Dcoef(trackll=trackll.swr1,plot=FALSE)
    plotTrackOverlay(trackll.swr1)

    # plotNucTrackOverlay(folder=folder1, trackll=trackll.swr1)
    dwellTime(trackll.swr1)

    # Output trajectory index to plot individually
    trackll.sel=selComponentTracks(trackll=trackll,fit=fit,likelihood = 0.9,
    dcoef = dcoef,log.transformed=TRUE, output=FALSE)
    # specify index file path.
    index.file=system.file('extdata','INDEX',
                           'componentTrackID-SWR1.comp.1.csv',
                           package='sojourner')
    index.file2=system.file('extdata','INDEX',
                            'componentTrackID-SWR1.comp.2.csv',
                            package='sojourner')
    movie.folder=system.file('extdata','SWR1_2',package='sojourner')
    plotTrackFromIndex(index.file=index.file,movie.folder = movie.folder,
                       input = 3)
    plotTrackFromIndex(index.file=index.file2,movie.folder = movie.folder,
                       input = 3)

    ## 2. select componentTracks per movie base, use plotComponentTracks to
    ##plot component tracks back to initial Nuclei image.
    ## plotComponentTrackOverlay
    folder3=system.file('extdata','SWR1_2',package='sojourner')
    trackll=createTrackll(folder=folder3, input=3)

    ## use merge=TRUE for per folder comparison,
    ## the analsyis result can't be plot back to original image
    ## To see component tracks on original nuclei image, set merge=FALSE (for
    ## per movie analysis)
    ## may not make much sense to msd on individual movie,
    ##however for plot component track back to original nuclei image.

    ## compute MSD
    MSD=msd(trackll=trackll,plot=FALSE)
    msd(trackll=trackll,summarize=TRUE,plot=FALSE)

    ## calculate Dcoef
    dcoef=Dcoef(MSD=MSD,method='static',plot=FALSE)

    ## fit normal distribution to define component
    ## set seed to reproduce results (see fitNormalDistr() for details on seed)
    set.seed(484)
    fit=fitNormDistr(dcoef,components=2,log.transform=TRUE,combine.plot=FALSE,
                     output=FALSE)

    ## select component tracks based on fitting
    trackll.sel=selComponentTracks(trackll=trackll,fit=fit,likelihood = 0.9,
                                   dcoef)
    ## plot component tracks
    plotComponentTrackOverlay(folder=folder3,trackll.sel=trackll.sel)

[Package sojourner version 1.1.1 Index]