Skip to content

Commit

Permalink
Merge pull request #51 from pratikunterwegs/develop
Browse files Browse the repository at this point in the history
rename atl_thin_data option to "subsample"
  • Loading branch information
pratikunterwegs authored Feb 17, 2021
2 parents 448dbbf + 3e02c55 commit ac57d2c
Show file tree
Hide file tree
Showing 24 changed files with 476 additions and 368 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: atlastools
Title: Tools for Pre-Processing High-Throughput Animal Tracking Data
Version: 0.9.9000
Version: 1.0.0000
Authors@R:
c(person(given = "Pratik",
family = "Gupte",
Expand Down
16 changes: 8 additions & 8 deletions R/fun_thin_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#' Both options make two important assumptions:
#' (1) that timestamps are named `time', and
#' (2) all columns except the identity columns can be averaged in \code{R}.
#' While the `resample' option returns a thinned dataset with all columns from
#' While the `subsample' option returns a thinned dataset with all columns from
#' the input data, the `aggregate' option drops the column \code{COVXY}, since
#' this cannot be propagated to the averaged position.
#' Both options handle the column `time' differently: while `resample' returns
#' Both options handle the column `time' differently: while `subsample' returns
#' the actual timestamp (in UNIX time) of each sample, `aggregate' returns the
#' mean timestamp (also in UNIX time).
#' In both cases, an extra column, \code{time_agg}, is added which has a uniform
Expand All @@ -28,7 +28,7 @@
#' @param interval The interval in seconds over which to aggregate.
#' @param id_columns Column names for grouping columns.
#' @param method Should the data be thinned by subsampling or aggregation.
#' If resampling (\code{method = "resample"}), the first position of each group
#' If resampling (\code{method = "subsample"}), the first position of each group
#' is taken. If aggregation (\code{method = "aggregate"}), the group positions'
#' mean is taken.
#'
Expand All @@ -49,7 +49,7 @@ atl_thin_data <- function(data,
interval = 60,
id_columns = NULL,
method = c(
"resample",
"subsample",
"aggregate"
)) {
time <- SD <- VARX <- VARY <- COVXY <- NULL
Expand All @@ -62,10 +62,10 @@ atl_thin_data <- function(data,

# check that type is a character and within scope
assertthat::assert_that(method %in% c(
"resample",
"subsample",
"aggregate"
),
msg = "thin_data: type must be 'resample' or \\
msg = "thin_data: type must be 'subsample' or \\
'aggregate'"
)

Expand Down Expand Up @@ -128,8 +128,8 @@ atl_thin_data <- function(data,
new = c("VARX", "VARY"),
skip_absent = TRUE
)
} else if (method == "resample") {
# resample the first observation per rounded interval
} else if (method == "subsample") {
# subsample the first observation per rounded interval
data <- data[, c(lapply(.SD, data.table::first),
count = length(x)
),
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
`atlastools` is an `R` package to pre-process high frequency animal tracking data.
It is written and maintained by [Pratik Gupte](https://www.rug.nl/staff/p.r.gupte), at the [University of Groningen's Theoretical Biology Group](https://www.rug.nl/research/gelifes/tres/). While aimed at data from ATLAS systems, it works with any `X, Y, TIME` data.

`atlastools` use with animal tracking data is extensively documented here: https://github.com/pratikunterwegs/atlas-best-practices
## Package documentation

The package functions are conveniently documented at the package website: https://pratikunterwegs.github.io/atlastools/

## A Guide to Pre-procesing High-throughput Animal Tracking Data

Using `atlastools` to clean data before making biological inferences is covered in depth in the preprint _Gupte et al. (2020)_ on bioRxiv: https://www.biorxiv.org/content/10.1101/2020.12.15.422876v2

## Installation

Expand Down
6 changes: 3 additions & 3 deletions docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ac57d2c

Please sign in to comment.