Package 'anibehavr'

Title: Analyse Animal Behaviours
Description: What the package does (one paragraph).
Authors: Mikkel Roald-Arbøl [aut, cre]
Maintainer: Mikkel Roald-Arbøl <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-11-02 04:12:48 UTC
Source: https://github.com/roaldarbol/anibehavr

Help Index


Add logticks

Description

Add logticks

Usage

add_logticks(
  base = 10,
  sides = "bl",
  scaled = TRUE,
  short = unit(0.1, "cm"),
  mid = unit(0.2, "cm"),
  long = unit(0.3, "cm"),
  colour = "black",
  size = 0.5,
  linetype = 1,
  alpha = 1,
  color = NULL,
  data = data.frame(x = NA),
  ...
)

Arguments

base

Base

sides

Sides

scaled

Scaled

short

Short

mid

Mid

long

Long

colour

Colour

size

Size

linetype

Linetype

alpha

Alpha

color

Color

data

Data

...

Other

Value

Added logticks


Assign video

Description

Assign video

Usage

assign_video(track_list, animal_ids, tracker = c("trex", "idtrackerai"))

Arguments

track_list

List from video files

animal_ids

Animal ids

Value

track_list


Classify states Across Time-scales

Description

Classify states Across Time-scales

Usage

classify_states(data, movement_var, window_widths, .keep = FALSE)

Arguments

data

Data frame

movement_var

Binary (1/0) variable to be used for the classification

window_widths

Window width for the filter

.keep

Keep both intermediate filter components (forward/backward)

Value

Data frame with classifications


Compress observations

Description

Get an average of your data where the output is n rows (approximately).

Arguments

data

Data

n_observations

Number of observations in output data frame

group

grouping variable

Value

Smaller data frame where values are means of N observations


Compress observations2

Description

Get an average of your data where the output is n rows (approximately).

Arguments

data

Data

vars

Variables to mean

n_observations

Number of observations in output data frame

group

grouping variable

Value

Smaller data frame where values are means of N observations


Correct time

Description

Correct time

Usage

correct_time(data)

Arguments

data

Value

A data frame where times are added.


csv_clean

Description

csv_clean

Usage

csv_clean(df, tracker = c("trex", "idtrackerai"))

Arguments

df

Raw TRex csv file

Value

df


Filter Classifications

Description

Filter Classifications

Usage

filter_classifications(data, window_widths)

Arguments

data

Data frame

window_widths

Minimum duration of bout

Value

Filtered data frame


Forward-backward Filter

Description

Forward-backward Filter

Usage

filter_forward_backward(data, movement_var, window_width)

Arguments

data

Data frame

group

Find position

Description

Find position

Usage

find_position(df, exp_setup = c("wellplate", "tube"), animal_ids)

Arguments

df

track_list of data frames.

exp_setup

Experimental setup, eith "wellplate " or "tube".

animal_ids

Vector of animal IDs, as strings.

Value

A single tibble


Generate bout numbers for binary variable

Description

Generate bout numbers for binary variable

Usage

generete_state_numbers(data, var, .keep = FALSE)

Arguments

data

Data frame

var

Variable name (in quotes)

.keep

Keep both intermediate filter components (forward/backward)

Value

Data frame with classifications


IDENTIFY PERIODS OF INTEREST

Description

IDENTIFY PERIODS OF INTEREST

Usage

identify_periods(data, var, newvar, threshold = "minmax", as_factor = FALSE)

Arguments

data

Data frame

var

Variable to be identified

newvar

New variable name

threshold

Method for thresholding. Either "minmax", "mediansd" or a number.

as_factor

Whether an output should be returned as factor

Value

Thresholded data frame


Title

Description

Title

Usage

inf_remove(df)

Arguments

df

Data frame

Value

A data frame without Inf values


inverse_ecdf

Description

inverse_ecdf

Usage

inverse_ecdf(data, col, min_length, rest_state = FALSE)

Arguments

data

A data frame (e.g. a tibble)

col

Variable to make the density function for.

min_length

Minimal starting duration in frames

rest_state

Whether to make the ecdf for resting or active periods. TRUE or FALSE (default)

Value

Inverse ECDF


is_moving

Description

is_moving

Usage

is_moving(df, type, n_frames = 50)

Arguments

df

Data frame.

type

Use mean or median.

n_frames

Number of frames used to generate rolling average.

Value

Data frame with a value for whether the animal is moving


Ensure that grouping levels match across data frames - add an error/warning if not.

Description

Ensure that grouping levels match across data frames - add an error/warning if not.

Usage

join_timeseries(
  .x,
  y,
  by = NULL,
  group = NULL,
  method = NA,
  copy = FALSE,
  suffix = c("", ".y"),
  keep = NULL
)

Merge videos

Description

Merges data sets for consecutive videos for each animal.

Usage

merge_videos(df_list)

Arguments

df_list

List of data frames

Value

Merged data frame from list


Min-max normalisation

Description

Min-max normalisation

Usage

min_max_norm(x)

Arguments

x

Value

Normalisation


Non-numeric mode

Description

Non-numeric mode

Usage

mode_nonnumeric(x)

Arguments

x

Vector to find the mode over

Value

Mode


Title

Description

Title

Usage

read_align_all_data(filenames, bin_seconds)

Arguments

filenames

Filenames

bin_seconds

Bin duration in seconds

Value

Aligned data frame


Title

Description

Title

Usage

read_align_data(data, bin_seconds, time, animal_id)

Arguments

bin_seconds

Bin duration in seconds

filename

Filenames

Value

Aligned data frame


Title

Description

Title

Usage

read_switch_data(filenames, bin_seconds, time_radius = FALSE)

Arguments

filenames

Filenames

bin_seconds

Bin duration in seconds

time_radius

Radius around change

Value

Switch data


Subset Around Event

Description

Subset Around Event

Usage

subset_around_event(data, var, from, time_var, time_radius = FALSE)

Arguments

data

Data frame

var

Variable to center around

from

Reference point (e.g. "Day"/"Night")

time_var

Which variable represents time

time_radius

Time around point

Value

Subset of data frame around point in time


Sync time

Description

Sync time

Usage

sync_time(.data, data2, x, y)

Arguments

.data

Data frame or tibble

data2

The second data frame

x

Parameter used to merge (often time)

y

Variable to be synced along with x

Value

Tibble