FRApp Package Vignette: Analyzing FRAP Data

Gioia Di Credico1

February 21, 2025

FRApp is an R package designed to streamline the analysis of Fluorescence Recovery After Photobleaching (FRAP) experiments, specifically focusing on actin dynamics in dendritic spines. This vignette provides a comprehensive guide on using FRApp for fitting nonlinear mixed-effects regression models and analyzing the results, briefly describing the analysis of the example data included in the package.

However, it is important to note that FRApp is not limited to the analysis of FRAP experiments only. The package offers a versatile framework for fitting any nonlinear mixed-effects models with an asymptotic exponential functional relationship to hierarchical data in various domains. Whether you are dealing with experimental data in biology, ecology, or any other field where hierarchical structures are present, FRApp can be a valuable tool for efficient model fitting and visualization.

In the FRAP experimental paradigm, the estimation of recovery curves over time is integrated with a nested data structure of spines belonging to neurons and neurons belonging to cultures. In the mixed-effects model framework, this structure is modeled through random effects.

Moreover, the effect of an experimental condition, e.g., the downregulation of the actin-binding protein CAP2 on the actin dynamics, can be evaluated at different levels, including interactions with fixed and random effects and the variance coefficient. The autocorrelation structure over time can also be modeled by an autoregressive model.

Installating the app

To install FRApp, you can use the following command

install.packages("FRApp")

Load the library with the command

library("FRApp")

You must execute this command every time you restart Rstudio.

Data Organization and preprocessing

Users need to check that their data comply with a suitable structure for the analysis. FRApp expects hierarchical data organized with grouping levels that uniquely identify the hierarchical structure.

Data should be organized with hierarchical levels that, when combined, distinctively identify the units at the lowest level of the hierarchy.

Experimental conditions, if any, should be included in naming the highest level of the hierarchy where they are applied.

As an example, the FRApp package includes sample FRAP data, which can be loaded in R using the following code:

data(FRAPdata)

The function prints the first six lines of the dataset.

head(FRAPdata)
#>   Culture id genetic id neuron spine ID time         y
#> 1          1        SCR  SCR.1        1 0.00 0.2453582
#> 2          1        SCR  SCR.1        1 1.56 0.3325155
#> 3          1        SCR  SCR.1        1 3.12 0.3627754
#> 4          1        SCR  SCR.1        1 4.68 0.3762651
#> 5          1        SCR  SCR.1        1 6.24 0.3555686
#> 6          1        SCR  SCR.1        1 7.80 0.3649364

The FRAP dataset uses the following naming convention to identify spines grouped in the three nested levels:

Please note that using this naming convention, spines can be identified only specifying the complete hierarchical structure, i.e. culture/neuron/spine. Therefore, if you want to fit a model including random effects at spine level only, you have to assign a unique name to each spine, otherwise they will not be uniquely identified.

When data are ready, they can be exported in a csv file format. Make sure that the first line of the csv file contains variable names and take note of the field and decimal separators, to allow for a proper upload of the dataset for the analysis.

Fitting Nonlinear Mixed-Effects Regression Models

Launch the FRApp application with the command

FRApp()
FRApp front page: mixed-effects model tab
FRApp front page: mixed-effects model tab

The application automatically opens in the browser. While the application is running, it is not possible to have access to the console. To close the application and get access to the R console again, you have to close the application by clicking on the red stop button located in the top right corner of the frame of the R console.

The application allows for:

Loading the data

The FRApp application accepts the csv files format. By default, it uses the semicolon as the field separator and the period as the decimal separator, but you can select different separators from the drop-down menu.

The first line of the file must contain the variable names.

The Browse… button allows you to load your own data file to be analyzed. Check that your import is correct by looking on the right at the summary description of the variables and number of observations imported.

Please, double-check variable types:

For response and explanatory variables, factor variable type is not allowed.

Alternatively, to showcase the functionality and usability of FRApp, the Load example data button allows you to load the dataset analyzed in the paper and automatically selects the specification of the final selected model.

In the case of the example data, the response variable y, the fluorescence intensity, and the explanatory variable, time, are numeric.

FRApp front page: loading the example data
FRApp front page: loading the example data

Estimating and comparing exponential mixed-effects models

The following list highlights the main characteristics of an exponential mixed-effects model that can be implemented in FRApp and within our FRAP example.

Model fitting is perfomed with the nlme function.

Fixed effects
For each unit, the response variable \(y\) is modeled through an asymptotic regression function on time \(t\), that is, \[y_i = Asym+(R0−Asym)exp(−exp(lrc)t_i)+\epsilon_i,\quad \text{for } i = 1,...,n\] This asymptotic function is characterized by three parameters: \(R0\), the response \(y\) at time \(t = 0\), the horizontal asymptote \(Asym\) (reached for \(t \rightarrow \infty\)) and the log rate constant \(lrc\).

Random effects
Mixed-effects models combine fixed effects describing the population mean and random effects accounting for variation among groups. When the data show a nested structure, the hierarchy can be easily handled specifying random effects for each level of the hierarchy. In the FRApp, random effects are assumed to be independent and normally distributed.

Variance and temporal dependence
When model residuals, which are the difference between fitted and observed values, show a non constant behavior, several variance functions can be evaluated to account for their heteroscedasticity. The temporal dependence among data can be also modeled by introducing an autoregressive (AR) additional step.

Interactions
Interactions with an experimental condition can be included with different model components: random effects, fixed effects, and the variance structure. Interactions allow to estimate specific effects for each experimental condition.

It’s advisable to move from simplest structures towards greater model complexity by exploring model diagnostics including residual plots, random effects normality, and serial correlation.

You can save models for model comparison. Saved models must have different names. When multiple models are saved, the table at the bottom of the page displays comparisons among saved models as based on AIC, BIC, and likelihood ratio tests.

The Reset model list button allows you to delete the saved models from the list.

Printing a model report and exporting the data and the model

From the drop-down menu in the Download section, you can select a saved model from the list and download a report and some model’s objects.

You can download the model report using the Download report button. It includes the output shown in the app after model fitting, i.e. model summary, diagnostic plots (scatterplot of residuals vs. estimated values and quantile-quantile plot of the residuals), and the approximate 95% confidence intervals.

The Download RData button allows you to export an RData file containing six objects:

You can open the Rdata file with RStudio, and use the included objects to create further plots including curves estimated at the different hierarchical levels (using the pred object), plots of residuals (with resid) or random effects (with raneff).

FRAP example data analysis

In this section, we walk through our example analysis of the FRAP dataset using FRApp.

Model 1. We start by fitting a model with three random effects at culture level and one random effect on the \(Asym\) parameter for the neuron and spine levels. We consider a constant variance function and no temporal dependence on the error term. Also we do not evaluate interactions with the genetic condition.

At the end of the estimation process, we obtain:

We save this model as “Model 1” with the button Add to model list.

FRApp front page: Model 1
FRApp front page: Model 1

Model 2. We update the random effect structure by fitting a model with the final random effects structure selected in the paper: three random effects at culture and spine levels and one random effect on the R0 parameter at the neuron level.
We save this model as “Model 2” with the button Add to model list.

Under the confidence intervals, a table showing AIC, BIC, and likelihood ratio test criteria appears. According to the showed criteria, Model 2 outperforms Model 1. However, the residuals plot shows the presence of heteroscedasticity.

FRApp front page: Model comparison
FRApp front page: Model comparison

Model 3. We fit the final model selected in the paper, by choosing the exponential function on the variance interacting with the experimental condition, and by adding an AR model of order one.
We save this model with the name “Model 3” by pressing the Add to model list button. According to the criteria in the comparison table, Model 3 outperforms Model 2.

FRApp front page: Model 3
FRApp front page: Model 3

We download the Model 3 report using the Download report button.

References

As a reference for the construction of the model and the different options to specify, we refer to the book: Pinheiro, J., & Bates, D. (2006). Mixed-effects models in S and S-PLUS. Springer science & business media.

As a reference for the FRAP data analysis example: Di Credico, G., Pelucchi, S., Pauli, F. et al. Nonlinear mixed-effects models to analyze actin dynamics in dendritic spines. Scientific Reports 15, 5790 (2025). https://doi.org/10.1038/s41598-025-87154-w


  1. University of Trieste, ↩︎