knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(data.table) library(ARCOS) library(ggplot2) library(ggthemes) library(ggnewscale)
Using ARCOS to detect collective activation events in biological systems requires identification of active objects, i.e., objects that will be passed to the clustering algorithm. In practice the single-cell activity obtained from image segmentation needs to be thresholded and binarised. ARCOS offers several approaches to perform such approaches that will be covered below.
Time-series data obtained, for example, from image segmentation should be in long format. Here we use a sample dataset of single-cell ERK activity from MCF10A WT epithelial cells. See the associated publication on bioRxiv for more details about biological problems that can be analysed with ARCOS.
# define column names lCols = list() lCols$frame = 'frame' lCols$trackid = 'trackid' lCols$posx = 'x' lCols$posy = 'y' lCols$meas = 'meas' # Load from file dts = fread(system.file('testdata/sampleTS.csv.gz', package = 'ARCOS')) # create an ARCOS ts object ARCOS::arcosTS(dts, colPos = c(lCols$posx, lCols$posy), colMeas = lCols$meas, colFrame = lCols$frame, colIDobj = lCols$trackid) knitr::kable(head(dts, 4), digits = 2)
The measurement may contain missing values or NAs, which can be interpolated using the ARCOS::interpolMeas
function.
# interpolate dts = ARCOS::interpolMeas(dts)
Point outliers in the measurement can be clipped using the ARCOS::clipMeas
function.
ARCOS::histMeas(dts, clip = c(0.001, 0.999), quant = TRUE) + ggthemes::theme_clean()
ARCOS::clipMeas(dts, clip = c(0.001, 0.999), quant = TRUE)
De-trending is based on a running median, therefore, it requires time series that are approximately at least 4 times longer than the length of the de-trending median filter.
ARCOS::histTrackLen(dts, binwidth = 10)
Length of time series in frames. Frames acquired every 1 minute.
dts = ARCOS::selTrackLen(dts, lenmin = 660) knitr::kable( dts[, .N, by = trackid])
Regions of measurement activity identified with several methods available in the ARCOS::binMeas
function.
This approach uses a short-term smoothing filter to remove noise from time series and a long-term filter to remove trends.
# binarise the measurement ARCOS::binMeas(dts, biasMet = "runmed", smoothK = 5L, biasK = 501L, peakThr = 0.05, binThr = 0.1)
The ARCOS::binMeas
function adds meas.resc
and meas.bin
columns to the original dataset. Below is a plot of the original time series compared to de-trended/rescaled and binarised output. The meas.bin
column should be used to filter the rows such that only active cells are used to detect collective events, i.e., ARCOS::trackColl(dts[meas.bin > 0])
.
knitr::kable(head(dts), digits = 2)
p1 = ARCOS::plotBinMeas(dts, ntraj = 0L, xfac = 1 / 60., plotResc = TRUE, inSeed = 3L) + geom_hline(yintercept = 0.1, color = "#F28E2B", linetype = "dashed") + ggthemes::theme_few() + xlab("Time [h]") + ylab("C/N ERK-KTR") p1
In this approach, a fit to a linear function is used to de-trend the time series.
# binarise the measurement ARCOS::binMeas(dts, biasMet = "lm", smoothK = 5L, peakThr = 0.05, polyDeg = 5L, binThr = 0.2) ARCOS::plotBinMeas(dts, ntraj = 0L, xfac = 1 / 60., plotResc = TRUE, inSeed = 3L) + geom_hline(yintercept = 0.2, color = "#F28E2B", linetype = "dashed") + ggthemes::theme_few() + xlab("Time [h]") + ylab("C/(C+N) ERK-KTR")
In this approach a fixed threshold is applied to rescaled time series.
# binarise the measurement ARCOS::binMeas(dts, biasMet = "none", smoothK = 5L, binThr = 0.3) ARCOS::plotBinMeas(dts, ntraj = 0L, xfac = 1 / 60., plotResc = TRUE, inSeed = 3L) + geom_hline(yintercept = 0.3, color = "#F28E2B", linetype = "dashed") + ggthemes::theme_few() + xlab("Time [h]") + ylab("C/(C+N) ERK-KTR")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.