fraping-doc

newDataFrap

# Function: newDataFrap
#
# Description: Create a new instance of the "frapclass" class.
#
# Parameters:
#   - name: Name of the FRAP object.
#   - bleach: Percentage of sample bleaching.
#
# Returns: An instance of the "frapclass" class.
#
# Usage:
#   frap_obj <- newDataFrap(name, bleach)
A <- newDataFrap("Neurites", 80)
B <- newDataFrap("Secondary.Neurites", 80)
C <- newDataFrap("Dendrites", 80)

plotRecover

# Function: plotRecover
#
# Description: Plot the fluorescence recovery curves.
#
# Parameters:
#   - ...: Additional parameters for the plot function.
#   - index: Index or indices of the FRAP objects to plot.
#   - type: Type of recovery curve to plot (default: "RCB").
#   - area: Whether to include area normalization in the plot (default: TRUE).
#   - stand: Whether to standardize the recovery curve (default: TRUE).
#   - AB: Whether to include only the recovery phase of the curve (default: FALSE).
#   - new.plot: Whether to create a new plot (default: TRUE).
#   - plot.lines: Whether to plot lines (default: FALSE).
#   - plot.points: Whether to plot points (default: FALSE).
#   - plot.shadow: Whether to plot shadowed areas (default: FALSE).
#   - plot.mean: Whether to plot the mean curve (default: FALSE).
#   - col: Color of the curves (default: NULL).
#   - getGroup: Whether to return the group information (default: FALSE).
#
# Usage:
#   plotRecover(..., index = NA, type = "RCB", area = TRUE, stand = TRUE, AB = FALSE,
#               new.plot = TRUE, plot.lines = FALSE, plot.points = FALSE, plot.shadow = FALSE,
#               plot.mean = FALSE, col = NULL, getGroup = FALSE)
# Example 1: Plotting fluorescence recovery curves for FRAP objects A, B, and C.
plotRecover(A, B, C, plot.lines = TRUE, col = c("blue", "red", "green"))

# Example 2: Plotting specific indices of recovery curves.
plotRecover(A, B, C, index = c(1, 3), plot.points = TRUE, col = "purple")

# Example 3: Customizing the plot with shadowed areas and mean curve.
plotRecover(A, B, C, plot.lines = TRUE, plot.shadow = TRUE, plot.mean = TRUE)

# Example 4: Plotting standardized recovery curves without area normalization.
plotRecover(A, B, C, area = FALSE, stand = TRUE, plot.lines = TRUE, col = "orange")

# Example 5: Plotting recovery curves from different FRAP objects in the same plot.
plotRecover(A, Exp, plot.lines = TRUE, col = "blue")
plotRecover(B, Gam, new.plot = FALSE, plot.lines = TRUE, col = "red")
plotRecover(C, Wei, new.plot = FALSE, plot.lines = TRUE, col = "green")

newFit

# Function: newFit
#
# Description: Create a new instance of the "fitclass" class for FRAP data fitting.
#
# Parameters:
#   - name: Name of the fitting model.
#   - fun: Fitting function.
#   - param: Names of the fitting parameters.
#   - interval: Interval for each fitting parameter.
#
# Usage:
#   newFit(name, fun, param, interval)
# Example 1: Creating a new fitting model using the Exponential function.
Exp <- newFit("Exponential", pexp, "rate", list(c(0, 1)))

# Example 2: Creating a new fitting model using the Gamma function.
Gam <- newFit("Gamma", pgamma, c("shape", "rate"), list(c(0, 5), c(0, 5)))

# Example 3: Creating a new fitting model using the Weibull function.
Wei <- newFit("Weibull", pweibull, c("shape", "scale"), list(c(0, 5), c(0, 2000)))

# Example 4: Creating a new fitting model with custom parameters and intervals.
fit_custom <- newFit("Custom", myfitfunction, c("param1", "param2", "param3"),
    list(c(0, 10), c(-1, 1), c(0, 100)))

compareFit

# Function: compareFit
#
# Description: Compare the goodness of fit between data and multiple fits.
#
# Parameters:
#   - data: Data to compare (numeric vector or data frame).
#   - fit: List of fits to compare (list of numeric vectors or data frames).
#   - col.lines: Color palette for the fit lines (default: NULL).
#   - lty.lines: Line type for the fit lines (default: 1).
#   - lwd.lines: Line width for the fit lines (default: 1).
#   - lwd.mean: Line width for the mean fit line (default: 1).
#   - digits: Number of digits to round the fit statistics (default: 4).
#   - ...: Additional parameters for the plot function.
#
# Usage:
#   compareFit(data, fit, col.lines = NULL, lty.lines = 1, lwd.lines = 1, lwd.mean = 1,
#              digits = 4, ...)
# Example 1: Comparing the goodness of fit for different models using pre-loaded data
compareFit(B, list(Exp, Wei), col.lines = c("red", "yellow"), lty.lines = c(2, 1),
           lwd.lines = 2, lwd.mean = 2)

# Example 2: Comparing the goodness of fit for different models with custom colors and line types
compareFit(B, list(Exp, Gam, Wei), col.lines = c("blue", "green", "purple"),
           lty.lines = c(1, 3, 2), lwd.lines = 2, lwd.mean = 2)

plotFit

# Function: plotFit
#
# Description: Plot the fit of fluorescence recovery curves.
#
# Parameters:
#   - ...: Additional parameters for the plot function.
#   - fit: Fit objects obtained from the newFit function.
#   - index: Index or indices of the fit objects to plot.
#   - type: Type of recovery curve to plot (default: "RCB").
#   - area: Whether to include area normalization in the plot (default: TRUE).
#   - stand: Whether to standardize the recovery curve (default: TRUE).
#   - simulated: Whether to include simulated recovery curves (default: FALSE).
#   - Nsim: Number of simulated curves to generate (default: 50).
#   - seed: Seed value for reproducibility of simulated curves (default: NA).
#   - npoints: Number of points to generate in simulated curves (default: 100).
#   - displacement: Whether to add random displacement to simulated curves (default: FALSE).
#   - new.plot: Whether to create a new plot (default: TRUE).
#   - plot.lines: Whether to plot lines (default: FALSE).
#   - plot.points: Whether to plot points (default: FALSE).
#   - plot.shadow: Whether to plot shadowed areas (default: FALSE).
#   - plot.mean: Whether to plot the mean curve (default: FALSE).
#   - col: Color of the curves (default: NULL).
#
# Usage:
#   plotFit(..., fit, index = NA, type = "RCB", area = TRUE, stand = TRUE, simulated = FALSE,
#           Nsim = 50, seed = NA, npoints = 100, displacement = FALSE,
#           new.plot = TRUE, plot.lines = FALSE, plot.points = FALSE, plot.shadow = FALSE,
#           plot.mean = FALSE, col = NULL)
# Example 1: Plotting the fit of fluorescence recovery curves for objects B and C with Exp fit
plotFit(B, C, fit = Exp, plot.lines = TRUE, col = c("blue", "red", "green"),
        ylim = c(0.2, 1), xdigits = 0)

# Example 2: Plotting the fit for object B with Gam fit
plotFit(B, fit = Gam, plot.lines = TRUE, col = c("blue", "red", "green"),
        ylim = c(0.2, 1), xdigits = 0)

# Example 3: Plotting fits for objects B and C with multiple fits and points
plotFit(B, C, fit = c(Exp, Gam), plot.lines = TRUE, plot.points = TRUE,
        col = c("blue", "red", "green"), ylim = c(0.2, 1), xdigits = 0)

# Example 4: Plotting fit for object C with Wei fit and shadowed areas
plotFit(C, fit = Wei, plot.lines = TRUE, plot.shadow = TRUE,
        col = c("blue", "red", "green"), ylim = c(0.2, 1), xdigits = 0)

compareParam

# Function: compareParam
#
# Description: Compare parameter estimates between two datasets based on the fit results.
#
# Parameters:
#   - data1: First dataset of fluorescence recovery curves.
#   - data2: Second dataset of fluorescence recovery curves.
#   - fit: Fit object containing the results of fitting the data.
#   - param: Parameter to compare between the datasets.
#   - type: Type of recovery curve to consider (default: "RCB").
#   - area: Whether to include area normalization in the comparison (default: TRUE).
#   - stand: Whether to standardize the recovery curves (default: TRUE).
#   - simulated: Whether to use simulated data for the comparison (default: FALSE).
#   - Nsim: Number of simulated datasets to generate (default: 50).
#   - seed: Seed value for reproducible simulations (default: NA).
#   - saveable: Whether to enable saving of simulation results (default: TRUE if seed is specified).
#   - conf.level: Confidence level for the comparison (default: 0.95).
#   - alternative: Type of alternative hypothesis for the comparison (default: "two.sided").
#   - return: Whether to return the comparison results (default: FALSE).
#   - new.plot: Whether to create a new plot (default: TRUE).
#   - plot.lines: Whether to plot lines in the comparison plot (default: TRUE).
#   - plot.points: Whether to plot points in the comparison plot (default: FALSE).
#   - col: Color of the curves in the comparison plot (default: NULL).
#   - ...: Additional parameters for the comparison plot.
#
# Usage:
#   compareParam(data1, data2, fit, param, type = "RCB", area = TRUE, stand = TRUE,
#                simulated = FALSE, Nsim = 50, seed = NA, conf.level = 0.95,
#                alternative = "two.sided", return = FALSE, new.plot = TRUE,
#                plot.lines = TRUE, plot.points = FALSE, col = NULL, ...)
# Example 1: Comparing the parameter "MF" between datasets B and C using the Wei fit
compareParam(B, C, fit = Wei, param = "MF", lwd.lines = 2, col.lines = "#9084c9",
             simulated = TRUE, seed = 516)

# Example 2: Comparing the parameter "UF" between datasets B and C using the Wei fit
# with a different confidence level and alternative hypothesis
compareParam(B, C, fit = Wei, param = "UF", lwd.lines = 2, col.lines = "#d65b22",
             simulated = TRUE, seed = 6544, conf.level = 0.99, alternative = "greater")

# Example 3: Comparing the parameter "alpha" between datasets B and B using the Exp and Wei fits
# and returning the comparison results
results <- compareParam(B, B, fit = c(Exp, Wei), param = "alpha", lwd.lines = 2,
                         col.lines = "#2e337e", simulated = TRUE, seed = 44648)

# Example 4: Comparing the parameter "MF" between datasets B and C using the Gamma fit
# and customizing the comparison plot
compareParam(B, C, fit = Gam, param = "MF", simulated = TRUE, seed = 5959, return = TRUE)
    ## 
    ##  Welch Two Sample t-test
    ## 
    ## data:  MF_GammaSim_Secondary.Neurites and MF_GammaSim_Dendrites
    ## t = 1.773, df = 93.713, p-value = 0.07948
    ## alternative hypothesis: true difference in means is not equal to 0
    ## 95 percent confidence interval:
    ##  -0.005227574  0.092406709
    ## sample estimates:
    ## mean of x mean of y 
    ## 0.8700160 0.8264265

compareMean

# Function: compareMean
#
# Description: Compare the mean values between two datasets using FRAP fits.
#
# Parameters:
#   - data1: Dataset 1 for comparison.
#   - data2: Dataset 2 for comparison.
#   - fit: FRAP fit object(s) to use for the comparison.
#   - type: Type of recovery curve to use for the comparison (default: "RCB").
#   - area: Whether to include area normalization in the comparison (default: TRUE).
#   - stand: Whether to standardize the recovery curves for comparison (default: TRUE).
#   - simulated: Whether to perform simulated comparisons (default: FALSE).
#   - Nsim: Number of simulated comparisons to perform (default: 50).
#   - seed: Seed value for reproducible simulations (default: NA).
#   - saveable: Whether to enable saving of simulation results (default: TRUE if seed is specified).
#   - conf.level: Confidence level for the comparison (default: 0.95).
#   - alternative: Type of alternative hypothesis for the comparison (default: "two.sided").
#   - return: Whether to return the comparison results (default: FALSE).
#   - p.value: Whether to include p-values in the comparison results (default: TRUE).
#   - npoints: Number of points to use for plotting the comparison curve (default: 100).
#   - new.plot: Whether to create a new plot (default: TRUE).
#   - plot.lines: Whether to plot lines for the comparison curve (default: TRUE).
#   - plot.points: Whether to plot points for the comparison curve (default: FALSE).
#   - col: Color of the comparison curve (default: NULL).
#   - ...: Additional parameters for the plot function.
#
# Usage:
#   compareMean(data1, data2, fit, type = "RCB", area = TRUE, stand = TRUE,
#               simulated = FALSE, Nsim = 50, seed = NA, saveable = !is.na(seed),
#               conf.level = 0.95, alternative = "two.sided", return = FALSE,
#               p.value = TRUE, npoints = 100, new.plot = TRUE, plot.lines = TRUE,
#               plot.points = FALSE, col = NULL, ...)
# Example 1: Comparing the mean values of FRAP fits between datasets B and C using multiple fits
compareMean(B, C, fit = c(Exp, Gam), lwd.lines = 2,
            col.lines = c("red", "green", "purple"))

# Example 2: Comparing the mean values using the Gam fit and customizing the plot
compareMean(B, C, fit = Gam, lwd.lines = 2, col.lines = "orange",
             plot.lines = TRUE, plot.points = TRUE)

# Example 3: Comparing the mean values using the Wei fit
compareMean(B, C, fit = Wei, lwd.lines = 2, lty.lines = c(2, 1),
            ylim = c(0, 0.2), col.lines = c("red", "#C65153"),
            xdigits = 0, ydigits = 4)
compareMean(B, C, fit = Wei, lwd.lines = 2, col.lines = "#79189F",
            simulated = TRUE, seed = 486, new.plot = FALSE)

# Example 4: Comparing the mean values using the Exp fit
compareMean(B, C, fit = Exp, lwd.lines = 2, col.lines = "blue", return = T)[[2]]

simFit

# Function: simFit
#
# Description: Simulate fluorescence recovery curves based on a given FRAP fit.
#
# Parameters:
#   - fit: FRAP fit object to use for simulation.
#   - Nsim: Number of simulations to perform (default: 50).
#   - seed: Seed for random number generation (default: NA).
#   - saveable: Whether the simulation results can be saved (default: !is.na(seed)).
#
# Usage:
#   simFit(fit, Nsim = 50, seed = NA, saveable = !is.na(seed))
# Example 1: Simulate fluorescence recovery curves based on the Wei fit with 100 simulations
simFit(Wei(B), Nsim = 100)

# Example 2: Simulate fluorescence recovery curves based on the Exp fit with a specific seed
simFit(Exp(C), seed = 12345)

# Example 3: Simulate fluorescence recovery curves based on the Gam fit and save the results
simFit(Gam(B), saveable = TRUE)

tableFit

# Function: tableFit
#
# Description: Create a table summarizing the fit results for multiple FRAP objects.
#
# Parameters:
#   - ...: Multiple FRAP objects or a list of FRAP objects.
#   - fit: FRAP fit objects to include in the table.
#   - digits: Number of digits to round the table values (default: 4).
#
# Usage:
#   tableFit(..., fit, digits = 4)
# Example 1: Create a table summarizing the fit results for objects A, B, and C using the Wei fit
tableFit(A, B, C, fit = Wei)

# Example 2: Create a table summarizing the fit results for objects B and C using multiple fits
tableFit(B, C, fit = c(Exp, Gam, Wei))

# Example 3: Create a table summarizing the fit results for objects B, C, and D using custom digits
tableFit(B, C, D, fit = Exp, digits = 2)