View source: R/find_overlaps.R
find_overlaps | R Documentation |
This function is designed to find and remove segment overlaps from a single target. If we want to know the amount of time when a target was followed by one or more tracks, then we have to be careful to remove overlapping segments before summing. For example, if track 1 followed target A from time = 1 to time = 5 and track 2 followed target A from time = 3 to time = 7, then the final segment (after removing the overlaps) will be from time = 1 to time = 7. The total time tracked should be 6, however if we naively sum the two tracks we would double-count the time when two tracks are on one target.
startList (and stopList) should include the start (stop) times of all segments of all tracks on one target. The start and stop times are to be paired, meaning that startList[1] and stopList[1] refer to the start and stop times of the same segment. For example, if target A was followed by track 1 in two segments (say, from t = 1 to t = 3 and later from t = 7 to t = 10) and by track 2 in three segments (say, t = 2 to t = 4, t = 5 to t = 7, and t = 8 to t = 9), then startList and stopList should each have five values. In this example, startList would be c(1, 7, 2, 5, 8) and stopList would be c(3, 10, 4, 7, 9). These five segments overlap each other in such a way that there are in fact only two segments in which target A is covered by one or more targets. These final segments are from t = 1 to t = 4 and from t = 5 to t = 10. The output would be the list: list(c(1, 5), c(4, 10)). Below we have shown these two examples.
This function is called by timeTracked(), one of the analysis functions. It is not recommended that the user try to use this function as a stand-alone function.
find_overlaps(startList, stopList)
startList |
vector of times when a track began to follow a specific target |
stopList |
vector of times when a track stopped following a specific target |
A list of two numeric vectors. The first vector contains all of the start times of segments and the second vector contains all of the stop times of vectors.
nautilus:::find_overlaps(c(1, 3), c(5, 7))
nautilus:::find_overlaps(c(1, 7, 2, 5, 8), c(3, 10, 4, 7, 9))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.