In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

This Server has been upgraded to GitLab release 14.2.6

Commit afbab618 authored by majpark21's avatar majpark21
Browse files

Auxfun: calculate average PSD through groups

parent a8f6e87c
......@@ -206,6 +206,44 @@ LOCcalcTrajCI = function(in.dt, in.col.meas, = NULL, in.type = c('norm
#' Calculate the power spectrum density for time-series
#' @param in.dt Data table in long format
#' @param in.col.meas Name of the column with the measurement
#' @param Name of the column with the unique series identifier
#' @param Column names for grouping (default NULL - no grouping). PSD of individual trajectories will be averaged within a group.
#' @param in.method Name of the method for PSD estimation, must be one of c("pgram", "ar"). Default to "pgram*.
#' @param in.return.period Wheter to return densities though periods (1/frequencies) instead of frequencies.
#' @param ... Other paramters to pass to stats::spectrum()
#' @return Datatable with columns: (frequency or period), spec (the density) and grouping column
#' @export
#' @import data.table
#' @examples
LOCcalcPSD <- function(in.dt,
in.method = "pgram",
in.return.period = TRUE,
if(!in.method %in% c("pgram", "ar")){
stop('Method should be one of: c("pgram", "ar"')
dt_spec <- copy(in.dt)
dt_spec[, c("frequency", "spec") := (spectrum(get(in.col.meas), plot = FALSE, method = in.method, ...)[c("freq", "spec")]), by =]
dt_agg <- dt_spec[, .(spec = mean(spec)), by = c(, "frequency")]
dt_agg[, period := 1/frequency]
dt_agg[, frequency := NULL]
#' Generate synthetic CellProfiler output with single cell time series
......@@ -644,7 +682,7 @@ LOCplotTrajRibbon = function(dt.arg, # input data table
# Plot average power spectrum density per facet
# Plots a scatter plot with marginal histograms
# Points are connected by a line (grouping by cellID)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment