Type: Package
Title: qPCR Data Analysis
Version: 2.1.0
Description: Amplification efficiency estimation, statistical analysis, and graphical representation of quantitative real-time PCR (qPCR) data using one or more specified reference genes is handled by 'rtpcr' package. By accounting for amplification efficiency values, 'rtpcr' was developed using a general calculation method described by Ganger et al. (2017) <doi:10.1186/s12859-017-1949-5> and Taylor et al. (2019) <doi:10.1016/j.tibtech.2018.12.002>, covering both the Livak and Pfaffl methods. Based on the experimental conditions, the functions of the 'rtpcr' package use t-test (for experiments with a two-level factor), analysis of variance (ANOVA), analysis of covariance (ANCOVA) or analysis of repeated measure data to analyse the relative expression (Delta Delta Ct method or Delta Ct method). The functions further provide standard errors and confidence intervals for means, apply statistical mean comparisons and present significance.
URL: https://github.com/mirzaghaderi/rtpcr
License: GPL-3
Imports: multcomp, multcompView, ggplot2, lmerTest, purrr, reshape2, tidyr, dplyr, grid, emmeans
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.3.3
NeedsCompilation: no
Packaged: 2025-12-18 19:59:55 UTC; GM
Depends: R (≥ 3.5.0)
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
Author: Ghader Mirzaghaderi [aut, cre, cph]
Maintainer: Ghader Mirzaghaderi <gh.mirzaghaderi@uok.ac.ir>
Repository: CRAN
Date/Publication: 2025-12-19 10:20:02 UTC

Relative expression analysis using the \Delta C_T method with ANOVA

Description

The ANOVA_DCt function performs analysis of variance (ANOVA) on relative expression values calculated using the \Delta C_T method. Expression levels are normalized using one or more reference genes and analyzed across all combinations of experimental factor levels.

Usage

ANOVA_DCt(x, numberOfrefGenes, block, alpha = 0.05, adjust = "none")

Arguments

x

A data frame structured as described in the package vignette, containing experimental condition columns, amplification efficiency (E) and Ct values for target and reference genes. Each Ct value should represent the mean of technical replicates.

NOTE: Each row corresponds to a separate biological individual, reflecting a non-repeated-measures experimental design.

numberOfrefGenes

Integer specifying the number of reference genes used for normalization (must be \ge 1).

block

Character string or NULL. If provided, this specifies the column name in x corresponding to a blocking factor (e.g. qPCR plate). Blocking is used to reduce technical variation arising from experimental conditions such as plate-to-plate differences.

alpha

Significance level used for compact letter display (CLD); default is 0.05.

adjust

P-value adjustment method passed to emmeans and cld.

Details

Relative expression (RE) values are calculated using the \Delta C_T method, where Ct values of target genes are normalized to reference gene(s). The resulting weighted Delta Ct (wDCt) values are then analyzed using ANOVA.

The function supports uni- and multi-factorial experimental designs. Blocking factors (e.g. qPCR plates) can optionally be included to account for technical variation. Each row of the input data represents an independent biological individual, corresponding to a non-repeated-measures experiment.

Value

A list containing the following components:

Final_data

Input data frame augmented with weighted Delta Ct (wDCt) values.

lm

Fitted linear model object, including ANOVA results.

ANOVA

ANOVA table based on a completely randomized design (CRD).

Result

Result table containing treatment and factor levels, relative expression (RE), log2 fold change (log2FC), confidence limits (LCL, UCL), compact letter display for pairwise comparisons, and standard errors with corresponding lower and upper limits.

Author(s)

Ghader Mirzaghaderi

References

Livak, K. J. and Schmittgen, T. D. (2001). Analysis of Relative Gene Expression Data Using Real-Time Quantitative PCR and the Double Delta CT Method. Methods, 25(4), 402–408. doi:10.1006/meth.2001.1262

Ganger, M. T., Dietz, G. D., and Ewing, S. J. (2017). A common base method for analysis of qPCR data and the application of simple blocking in qPCR experiments. BMC Bioinformatics, 18, 1–11.

Yuan, J. S., Reed, A., Chen, F., and Stewart, N. (2006). Statistical Analysis of Real-Time PCR Data. BMC Bioinformatics, 7, 85.

Examples

# If the data include technical replicates, calculate means first:
# df <- meanTech(data_3factor, groups = 1:3)

# One-factor or multi-factor ANOVA without blocking
ANOVA_DCt(
  data_3factor,
  numberOfrefGenes = 1,
  block = NULL
)

# ANOVA with blocking factor
ANOVA_DCt(
  data_2factorBlock,
  numberOfrefGenes = 1,
  block = "Block"
)

Relative expression analysis using the \Delta\Delta C_T method with ANOVA and ANCOVA

Description

The ANOVA_DDCt function performs relative expression (RE) analysis based on the \Delta\Delta C_T method using analysis of variance (ANOVA) or analysis of covariance (ANCOVA). It supports uni- and multi-factorial qPCR experimental designs.

Bar plots of relative expression (RE) or log2 fold change (log2FC), together with standard errors and confidence intervals, are optionally returned.

Usage

ANOVA_DDCt(
  x,
  numberOfrefGenes = 1,
  mainFactor.column = 1,
  analysisType = "anova",
  mainFactor.level.order = NULL,
  block = NULL,
  x.axis.labels.rename = "none",
  p.adj = "none",
  plot = TRUE,
  plotType = "RE"
)

Arguments

x

A data frame containing experimental conditions, biological replicates, amplification efficiency (E), and Ct values for target and reference genes. Each Ct value should represent the mean of technical replicates.

NOTE: Each row corresponds to a different biological individual, reflecting a non-repeated-measures experimental design. See the package vignette for details on data structure and column arrangement.

numberOfrefGenes

Integer specifying the number of reference genes used for normalization (must be \ge 1).

mainFactor.column

Column index or name of the factor for which relative expression is calculated. When analysisType = "ancova", remaining factors are treated as covariates.

analysisType

Character string specifying the analysis type; one of "anova" (default) or "ancova".

mainFactor.level.order

Optional character vector specifying the order of levels for the main factor. If NULL, the first observed level is used as the calibrator. If provided, the first element of the vector is used as the calibrator level.

block

Optional column name specifying a blocking factor. Blocking is commonly used to account for variation between qPCR plates. Block effects are treated as random, and interactions with main effects are not considered.

x.axis.labels.rename

Optional character vector used to relabel the x-axis in bar plots.

p.adj

Method for p-value adjustment.

plot

Logical; if FALSE, plots are not generated.

plotType

Plot scale to use: "RE" for relative expression or "log2FC" for log2 fold change.

Details

The function calculates weighted Delta Ct (wDCt) values using as many specified reference genes and then performs statistical analysis on the resulting relative expression values.

For multi-factorial experiments, relative expression is calculated for the levels of the factor specified by mainFactor.column.

If analysisType = "anova", a full factorial ANOVA model is fitted by default.

If analysisType = "ancova", relative expression is calculated for the levels of mainFactor.column, while the remaining factor(s), if any, are treated as covariates. In such cases, the ANCOVA table should be examined carefully: a significant interaction between the main factor and a covariate indicates that ANCOVA assumptions are violated and the model may be inappropriate.

ANCOVA is typically used when gene expression is influenced by one or more uncontrolled quantitative variables. For example, gene expression may depend on temperature while the primary interest is in treatment or stress effects.

The function also supports single-factor experiments, in which case ANOVA reduces to a one-way analysis.

Value

A list containing the following components:

Final_data

Input data frame augmented with weighted Delta Ct (wDCt) values.

lm_ANOVA

Linear model object for ANOVA analysis (if applicable).

lm_ANCOVA

Linear model object for ANCOVA analysis (if applicable).

ANOVA_table

ANOVA table.

ANCOVA_table

ANCOVA table.

Expression_Table

Table of RE values, log2FC, p-values, significance codes, confidence intervals, standard errors, and lower/upper SE limits.

RE_Plot

Bar plot of relative expression values for main factor levels.

log2FC_Plot

Bar plot of log2 fold change values for main factor levels.

Author(s)

Ghader Mirzaghaderi

References

Livak, K. J. and Schmittgen, T. D. (2001). Analysis of Relative Gene Expression Data Using Real-Time Quantitative PCR and the Double Delta CT Method. Methods, 25(4), 402–408. doi:10.1006/meth.2001.1262

Ganger, M. T., Dietz, G. D., and Ewing, S. J. (2017). A common base method for analysis of qPCR data and the application of simple blocking in qPCR experiments. BMC Bioinformatics, 18, 1–11.

Yuan, J. S., Reed, A., Chen, F., and Stewart, N. (2006). Statistical Analysis of Real-Time PCR Data. BMC Bioinformatics, 7, 85.

Examples

ANOVA_DDCt(data_1factor,
  numberOfrefGenes = 1,
  mainFactor.column = 1,
  block = NULL
)

ANOVA_DDCt(data_2factor,
  numberOfrefGenes = 1,
  mainFactor.column = 2,
  analysisType = "ancova",
  block = NULL
)

df <- meanTech(Lee_etal2020qPCR, groups = 1:3)

ANOVA_DDCt(df,
  numberOfrefGenes = 1,
  analysisType = "ancova",
  mainFactor.column = 2,
  plotType = "log2FC",
  block = NULL
)

Sample data (with technical replicates)

Description

A sample data for calculating biological replicated. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

Lee_etal2020qPCR

Format

A data frame with 72 observations and 8 variables:

factor1

experimental factor

DS

DS

biolRep

biological replicate

techRep

technical replicates

E_APOE

Amplification efficiency of APOE gene

Ct_APOE

Ct of APOE gene

E_GAPDH

Amplification efficiency of GAPDH gene

Ct_GAPDH

Ct of GAPDH gene

Source

Lee et al, (2020) <doi:10.12688/f1000research.23580.2>


Relative expression (\Delta \Delta C_T) analysis using a fitted model

Description

Performs relative expression (fold change) analysis based on the \Delta \Delta C_T method using a fitted model object produced by ANOVA_DDCt() or REPEATED_DDCt().

Usage

Means_DDCt(model, specs, p.adj = "none")

Arguments

model

A fitted model object (typically an lmer or lm object) created by ANOVA_DDCt() or REPEATED_DDCt().

specs

A character string or character vector specifying the predictors or combinations of predictors over which fold change values are desired. This argument follows the specification syntax used by emmeans::emmeans() (e.g., "Factor", "Factor1 | Factor2").

p.adj

Character string specifying the method for adjusting p-values. See p.adjust for available options.

Details

The Means_DDCt function calculates fold change (FC) values using estimated marginal means derived from a fitted model. For ANOVA models, FC values can be obtained for main effects, interactions, and sliced (simple) effects. For ANCOVA models returned by the rtpcr package, only simple effects are supported.

Internally, this function relies on the emmeans package to compute marginal means and contrasts, which are then back-transformed to fold change values using the \Delta \Delta C_T framework.

Value

A data frame containing estimated fold change values, confidence intervals, p-values, and significance levels derived from the fitted model.

Author(s)

Ghader Mirzaghaderi

Examples


# Obtain a fitted model from ANOVA_DDCt
res <- ANOVA_DDCt(
  data_3factor,
  numberOfrefGenes = 1,
  mainFactor.column = 1,
  block = NULL
)

# Fold change values for Type main effect
Means_DDCt(res$lm_ANOVA, specs = "Type")

# Fold change values for Concentration main effect
Means_DDCt(res$lm_ANOVA, specs = "Conc")

# Fold change values for Concentration sliced by Type
Means_DDCt(res$lm_ANOVA, specs = "Conc | Type")

# Fold change values for Concentration sliced by Type and SA
Means_DDCt(res$lm_ANOVA, specs = "Conc | Type * SA")

Fold change (\Delta\Delta C_T) analysis of repeated-measure qPCR data

Description

The REPEATED_DDCt function performs fold change (FC) analysis using the \Delta\Delta C_T method for qPCR data obtained from repeated measurements over time. Data may originate from uni- or multi-factorial experimental designs.

In addition to numerical results, bar plots of relative expression (RE) or log2 fold change values with associated uncertainty are optionally produced.

Usage

REPEATED_DDCt(
  x,
  numberOfrefGenes,
  factor,
  calibratorLevel,
  block,
  x.axis.labels.rename = "none",
  p.adj = "none",
  plot = TRUE,
  plotType = "RE"
)

Arguments

x

A data frame in which the first column is the individual identifier (id), followed by one or more factor columns (including time). Expression-related columns (time, target gene, reference gene(s)) must appear at the end of the data frame in the required order.

numberOfrefGenes

Integer specifying the number of reference genes (must be \ge 1).

factor

Character string specifying the factor for which fold changes are analysed (commonly "time").

calibratorLevel

A level of factor to be used as the calibrator (reference level).

block

Optional blocking factor column name. If supplied, block effects are treated as random effects.

x.axis.labels.rename

Optional character vector used to replace x-axis labels in the bar plot.

p.adj

Method for p-value adjustment (passed to emmeans).

plot

Logical; if FALSE, plots are not produced.

plotType

Either "RE" (relative expression) or "log2FC" (log2 fold change).

Details

The analysis is carried out using a linear mixed-effects model in which repeated measurements are accounted for by a random effect of individual (id). The factor of interest (e.g. time or treatment) is specified via the factor argument. The first level of this factor (or the level specified by calibratorLevel) is used as the calibrator.

The function supports one or more reference genes. When multiple reference genes are supplied, their contributions are averaged when computing weighted \Delta C_T values.

Value

A list with the following components:

Final_data

Input data frame augmented with weighted \Delta C_T values.

lm

Fitted linear mixed-effects model object.

ANOVA_table

ANOVA table for fixed effects.

Relative_Expression_table

Table containing RE values, log2FC, p-values, significance codes, confidence intervals, and standard errors.

RE_Plot

Bar plot of relative expression values (if requested).

log2FC_Plot

Bar plot of log2 fold change values (if requested).

Author(s)

Ghader Mirzaghaderi

Examples

REPEATED_DDCt(
  data_repeated_measure_1,
  numberOfrefGenes = 1,
  factor = "time",
  calibratorLevel = "1",
  block = NULL
)

REPEATED_DDCt(
  data_repeated_measure_2,
  numberOfrefGenes = 1,
  factor = "time",
  calibratorLevel = "1",
  block = NULL
)

Expression analysis of target genes using the \Delta\Delta C_T method and t-test

Description

The TTEST_DDCt function performs fold change expression analysis based on the \Delta\Delta C_T method using Student's t-test. It supports analysis of one or more target genes evaluated under two experimental conditions (e.g. control vs treatment).

Usage

TTEST_DDCt(
  x,
  numberOfrefGenes,
  Factor.level.order = NULL,
  paired = FALSE,
  var.equal = TRUE,
  p.adj = "BH",
  order = "none",
  plotType = "RE"
)

Arguments

x

A data frame containing experimental conditions, biological replicates, and amplification efficiency and Ct values for target and reference genes. The number of biological replicates must be equal across genes. See the package vignette for details on the required data structure.

numberOfrefGenes

Integer specifying the number of reference genes used for normalization (must be \ge 1).

Factor.level.order

Optional character vector specifying the order of factor levels. If NULL, the first level of the factor column is used as the calibrator.

paired

Logical; if TRUE, a paired t-test is performed.

var.equal

Logical; if TRUE, equal variances are assumed and a pooled variance estimate is used. Otherwise, Welch's t-test is applied.

p.adj

Method for p-value adjustment. One of "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", or "none".

order

Optional character vector specifying the order of genes in the output plot.

plotType

Plot scale to use: "RE" for relative expression or "log2FC" for log2 fold change.

Details

Fold change values are computed using one or more reference genes for normalization. Both paired and unpaired experimental designs are supported.

Paired samples in quantitative PCR refer to measurements collected from the same individuals under two different conditions (e.g. before vs after treatment), whereas unpaired samples originate from different individuals in each condition. Paired designs allow within-individual comparisons and typically reduce inter-individual variability.

The function returns numerical summaries as well as bar plots based on either relative expression (RE) or log2 fold change (log2FC).

Value

A list with the following components:

Result

Table containing RE values, log2FC, p-values, significance codes, confidence intervals, standard errors, and lower/upper SE limits.

RE_Plot

Bar plot of relative expression values.

log2FC_Plot

Bar plot of log2 fold change values.

Author(s)

Ghader Mirzaghaderi

References

Livak, K. J. and Schmittgen, T. D. (2001). Analysis of Relative Gene Expression Data Using Real-Time Quantitative PCR and the Double Delta CT Method. Methods, 25(4), 402–408. doi:10.1006/meth.2001.1262

Ganger, M. T., Dietz, G. D., and Ewing, S. J. (2017). A common base method for analysis of qPCR data and the application of simple blocking in qPCR experiments. BMC Bioinformatics, 18, 1–11.

Yuan, J. S., Reed, A., Chen, F., and Stewart, N. (2006). Statistical Analysis of Real-Time PCR Data. BMC Bioinformatics, 7, 85.

Examples

# Example data structure
data_1factor_one_ref

# Unpaired t-test
TTEST_DDCt(
  data_1factor_one_ref,
  paired = FALSE,
  var.equal = TRUE,
  numberOfrefGenes = 1
)

# With amplification efficiencies
data_1factor_one_ref_Eff

TTEST_DDCt(
  data_1factor_one_ref_Eff,
  paired = FALSE,
  var.equal = TRUE,
  numberOfrefGenes = 1
)

# Two reference genes
TTEST_DDCt(
  data_1factor_Two_ref,
  numberOfrefGenes = 2,
  var.equal = TRUE,
  p.adj = "BH"
)

Sample data (one factor three levels)

Description

A sample dataset. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

data_1factor

Format

A data frame with 9 observations and 6 variables:

SA

An experimental factor here called SA

Rep

Biological replicates

E_PO

Mean amplification efficiency of PO gene

Ct_PO

Ct values of PO gene. Each is the mean of technical replicates

E_GAPDH

Mean amplification efficiency of GAPDH gene

Ct_GAPDH

Ct values of GAPDH gene. Each is the mean of technical replicates

Source

Not applicable


Sample qPCR data (one target and two reference genes under two different conditions)

Description

Sample qPCR data (one target and two reference genes under two different conditions)

Usage

data_1factor_Two_ref

Format

A data frame with 6 observations and 8 variables:

Condition

Experimental conditions

Rep

Biological replicates

E_DER5

amplification efficiency of DER5 gene

Ct_DER5

Ct values of DER5 gene. Each is the mean of technical replicates

E_Actin

Amplification efficiency of Actin gene

Ct_Actin

Ct values of Actin gene. Each is the mean of technical replicates

E_HPRT

Amplification efficiency of HPRT gene

Ct_HPRT

Ct values of HPRT gene

Source

Not applicable


Sample qPCR data (two different conditions)

Description

Sample qPCR data (two different conditions)

Usage

data_1factor_one_ref

Format

A data frame with 6 observations and 10 variables:

Condition

Experimental conditions

Rep

Biological replicates

C2H2_26_E

amplification efficiency of C2H2_26 gene

C2H2_26_Ct

Ct values of C2H2_26 gene. Each is the mean of technical replicates

C2H2_01_E

Amplification efficiency of C2H2_01 gene

C2H2_01_Ct

Ct values of C2H2_01 gene. Each is the mean of technical replicates

C2H2_12_E

Amplification efficiency of C2H2_12 gene

C2H2_12_Ct

Ct values of C2H2_12 gene

ref_E

Amplification efficiency of ref gene

ref_Ct

Ct values of ref gene

Source

University of Kurdistan


Sample qPCR data (two different conditions)

Description

Sample qPCR data (two different conditions)

Usage

data_1factor_one_ref_Eff

Format

A data frame with 6 observations and 6 variables:

Con

Experimental conditions

r

Biological replicates

target_E

Amplification efficiency of target gene

target_Ct

Ct values of target gene

Actin_E

Amplification efficiency of reference gene

Actin_Ct

Ct values of reference gene

Source

University of Kurdistan


Sample data (two factor)

Description

A sample dataset. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

data_2factor

Format

A data frame with 18 observations and 7 variables:

Genotype

First experimental factor

Drought

Second experimental factor

Rep

Biological replicates

E_PO

Mean amplification efficiency of PO gene

Ct_PO

Ct values of PO gene. Each is the mean of technical replicates

E_GAPDH

Mean amplification efficiency of GAPDH gene

Ct_GAPDH

Ct values of GAPDH gene. Each is the mean of technical replicates

Source

Not applicable


Sample data in (two factor with blocking factor)

Description

A sample qPCR data set with blocking factor. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

data_2factor3ref

Format

A data frame with 18 observations and 8 variables:

factor1

First experimental factor

factor2

Second experimental factor

Rep

Biological replicates

E_PO

Mean amplification efficiency of PO gene

Ct_PO

Ct values of PO gene. Each is the mean of technical replicates

E_GAPDH

Mean amplification efficiency of GAPDH gene

Ct_GAPDH

Ct values of GAPDH gene. Each is the mean of technical replicates

ref2E

Mean amplification efficiency of ref2 gene

ref2Ct

Ct values of ref2 gene. Each is the mean of technical replicates

ref3E

Mean amplification efficiency of ref3 gene

ref3Ct

Ct values of GAPDH gene. Each is the mean of technical replicates

Source

Not applicable


Sample data in (two factor with blocking factor)

Description

A sample qPCR data set with blocking factor. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

data_2factorBlock

Format

A data frame with 18 observations and 8 variables:

factor1

First experimental factor

factor2

Second experimental factor

block

Second experimental factor

Rep

Biological replicates

E_PO

Mean amplification efficiency of PO gene

Ct_PO

Ct values of PO gene. Each is the mean of technical replicates

E_GAPDH

Mean amplification efficiency of GAPDH gene

Ct_GAPDH

Ct values of GAPDH gene. Each is the mean of technical replicates

Source

Not applicable


Sample data in (two factor with blocking factor and 3 reference genes)

Description

A sample qPCR data set with blocking factor and 3 reference genes. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

data_2factorBlock3ref

Format

A data frame with 18 observations and 8 variables:

factor1

First experimental factor

factor2

Second experimental factor

block

blocking factor

Rep

Biological replicates

E_PO

Mean amplification efficiency of PO gene

Ct_PO

Ct values of PO gene. Each is the mean of technical replicates

E_GAPDH

Mean amplification efficiency of GAPDH gene

Ct_GAPDH

Ct values of GAPDH gene. Each is the mean of technical replicates

ref2E

Mean amplification efficiency of ref2 gene

ref2Ct

Ct values of ref2 gene. Each is the mean of technical replicates

ref3E

Mean amplification efficiency of ref3 gene

ref3Ct

Ct values of GAPDH gene. Each is the mean of technical replicates

Source

Not applicable


Sample data (three factor)

Description

A sample dataset. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

data_3factor

Format

A data frame with 36 observations and 8 variables:

Type

First experimental factor

Conc

Second experimental factor

SA

Third experimental factor

Replicate

Biological replicates

E_PO

Mean amplification efficiency of PO gene

Ct_PO

Ct values of PO gene. Each is the mean of technical replicates

E_GAPDH

Mean amplification efficiency of GAPDH gene

Ct_GAPDH

Ct values of GAPDH gene. Each is the mean of technical replicates

Source

Not applicable


Sample qPCR data: amplification efficiency

Description

A sample qPCR dataset for demonstrating efficiency calculation.

Usage

data_efficiency

Format

A data frame with 21 observations and 4 variables:

dilutions

Dilution factor

C2H2.26

Target gene 1

C2H2.01

Target gene 2

GAPDH

Reference gene

Source

Where the data comes from (if applicable)


Repeated measure sample data

Description

A repeated measure sample data in which 3 individuals have been analysed. In the "id" column, a unique number is assigned to each individual, e.g. all the three number 1 indicate one individual. samples are taken or measurements are scored over different time points (time column) from each individual.

Usage

data_repeated_measure_1

Format

A data frame with 9 observations and 6 variables:

id

experimental factor

time

time course levels

E_target

Amplification efficiency of target gene

Ct_target

Ct of target gene

E_ref

Amplification efficiency of reference gene

Ct_ref

Ct of reference gene

Source

NA


Repeated measure sample data

Description

A repeated measure sample data in which 6 individuals have been analysed. In the "id" column, a unique number is assigned to each individual, e.g. all the three number 1 indicate one individual. samples are taken or measurements are scored over different time points (time column) from each individual.

Usage

data_repeated_measure_2

Format

A data frame with 18 observations and 7 variables:

id

experimental factor

treatment

treatment

time

time course levels

E_target

Amplification efficiency of target gene

Ct_target

Ct of target gene

E_ref

Amplification efficiency of reference gene

Ct_ref

Ct of reference gene

Source

NA


Sample data (with technical replicates)

Description

A sample data for calculating biological replicated. Each line belongs to a separate individual (non-repeated measure experiment).

Usage

data_withTechRep

Format

A data frame with 18 observations and 9 variables:

factor1

experimental factor

factor2

experimental factor

factor3

experimental factor

biolrep

biological replicate

techrep

technical replicates

E_target

Amplification efficiency of target gene

Ct_target

Ct of target gene

E_ref

Amplification efficiency of reference gene

Ct_ref

Ct of reference gene

Source

Not applicable


Amplification efficiency statistics and standard curves

Description

The efficiency function calculates amplification efficiency (E) and related statistics, including slope and coefficient of determination (R^2), and generates standard curves for qPCR assays.

Usage

efficiency(df)

Arguments

df

A data frame containing dilution series and corresponding Ct values. The first column should represent dilution levels, and the remaining columns should contain Ct values for different genes.

Details

Amplification efficiency is estimated from standard curves generated by regressing Ct values against the logarithm of template dilution. For each gene, the function reports the slope of the standard curve, amplification efficiency (E), and R^2 as a measure of goodness of fit. The function also provides graphical visualization of the standard curves.

Value

A list with the following components:

efficiency

A data frame containing slope, amplification efficiency (E), and R^2 statistics for each gene.

Slope_compare

A table comparing slopes between genes.

plot

A ggplot2 object showing standard curves for all genes.

Author(s)

Ghader Mirzaghaderi

Examples


# Load example efficiency data
data_efficiency

# Calculate amplification efficiency and generate standard curves
efficiency(data_efficiency)

Internal global variables

Description

These objects are declared to avoid R CMD check notes about non-standard evaluation (e.g., in ggplot2).


Calculate mean of technical replicates

Description

Computes the arithmetic mean of technical replicates for each sample or group. This is often performed before ANOVA or other statistical analyses to simplify comparisons between experimental groups.

Usage

meanTech(x, groups)

Arguments

x

A raw data frame containing technical replicates.

groups

An integer vector or character vector specifying the column(s) to group by before calculating the mean of technical replicates.

Details

The meanTech function calculates the mean of technical replicates based on one or more grouping columns. This reduces the dataset to a single representative value per group, facilitating downstream analysis such as fold change calculation or ANOVA.

Value

A data frame with the mean of technical replicates for each group.

Author(s)

Ghader Mirzaghaderi

Examples


# Example input data frame with technical replicates
data_withTechRep

# Calculate mean of technical replicates using first four columns as groups
meanTech(data_withTechRep, groups = 1:4)

# Another example using different dataset and grouping columns
meanTech(Lee_etal2020qPCR, groups = 1:3)

Combine multiple ggplot objects into a single layout

Description

The multiplot function arranges multiple ggplot2 objects into a single plotting layout with a specified number of columns.

Usage

multiplot(..., cols = 1)

Arguments

...

One or more ggplot2 objects.

cols

Integer specifying the number of columns in the layout.

Details

Multiple ggplot2 objects can be provided either as separate arguments via .... The function uses the grid package to control the layout.

Value

A grid object displaying multiple plots arranged in the specified layout.

Author(s)

Pedro J. (adapted from https://gist.github.com/pedroj/ffe89c67282f82c1813d)

Examples


# Example using output from TTEST_DDCt
a <- TTEST_DDCt(
  data_1factor_one_ref,
  numberOfrefGenes = 1,
  plotType = "log2FC"
)
p1 <- a$plot

# Example using output from ANOVA_DCt
out2 <- ANOVA_DCt(
  data_1factor,
  numberOfrefGenes = 1,
  block = NULL
)$Result

p2 <- plotOneFactor(
  out2,
  x_col = 1,
  y_col = 2,
  Lower.se_col = 7,
  Upper.se_col = 8,
  letters_col = 11
)

# Combine plots into a single layout
multiplot(p1, p2, cols = 2)

multiplot(p1, p2, cols = 1)

Bar plot of gene expression for single-factor experiments

Description

Creates a bar plot of relative gene expression (fold change) values from a single-factor experiment, including standard error or confidence interval error bars and statistical significance.

Usage

plotOneFactor(
  data,
  x_col,
  y_col,
  Lower.se_col,
  Upper.se_col,
  letters_col = NULL,
  letters_d = 0.2,
  col_width = 0.8,
  err_width = 0.15,
  fill_colors = "grey40",
  alpha = 1,
  base_size = 12,
  legend_position = "none",
  ...
)

Arguments

data

Data frame

x_col

Numeric. Column index for x-axis

y_col

Numeric. Column index for bar height

Lower.se_col

Numeric. Column index for lower SE

Upper.se_col

Numeric. Column index for upper SE

letters_col

Optional column index for grouping letters

letters_d

Numeric. Vertical offset for letters (default 0.2)

col_width

Numeric. Width of bars (default 0.8)

err_width

Numeric. Width of error bars (default 0.15)

fill_colors

Optional vector of fill colors

alpha

Numeric. Transparency of bars (default 1)

base_size

Numeric. Base font size for theme (default 12)

legend_position

Character. Legend position (default "right")

...

Additional valid ggplot2 layer arguments

Details

The plotOneFactor function generates a bar plot of fold change values for target genes using the output expression tables produced by functions such as ANOVA_DDCt() or ANOVA_DCt(). Error bars can represent either standard error (SE) or 95% confidence intervals, and optional grouping letters from post hoc statistical comparisons can be displayed above the bars.

Value

ggplot2 plot object

Author(s)

Ghader Mirzaghaderi

Examples


a <- ANOVA_DCt(
data_1factor,
numberOfrefGenes = 1,
block = NULL
)
data <- a$Results

plotOneFactor(
  data,
  x_col = 1,
  y_col = 2,
  Lower.se_col = 7,
  Upper.se_col = 8,
  letters_col = 11,
  letters_d = 0.1,
  col_width = 0.7,
  err_width = 0.15,
  fill_colors = "skyblue",
  alpha = 1,
  base_size = 16
)




Bar plot of gene expression for three-factor experiments

Description

Creates a bar plot of relative gene expression (fold change) values from a three-factor experiment, including error bars and statistical significance annotations.

Usage

plotThreeFactor(
  data,
  x_col,
  y_col,
  group_col,
  facet_col,
  Lower.se_col,
  Upper.se_col,
  letters_col = NULL,
  letters_d = 0.2,
  dodge_width = 0.9,
  col_width = 0.8,
  err_width = 0.15,
  fill_colors = NULL,
  alpha = 1,
  base_size = 12,
  legend_position = "right",
  ...
)

Arguments

data

A data frame containing expression results, typically obtained from ANOVA_DDCt() or ANOVA_DCt().

x_col

Integer specifying the column number used for the x-axis factor.

y_col

Integer specifying the column number used for the bar height (relative expression or fold change).

group_col

Integer specifying the column number used for grouping bars (fill aesthetic).

facet_col

Integer specifying the column number used for faceting the plot.

Lower.se_col

Integer specifying the column number used for the lower limit of the error bar.

Upper.se_col

Integer specifying the column number used for the upper limit of the error bar.

letters_col

Integer specifying the column number containing grouping letters from statistical comparisons.

letters_d

Numeric specifying the distance between sig letters and error bar.

dodge_width

Numeric. Width of the dodge position adjustment for grouped bars.

col_width

Numeric. Width of bars (default 0.8)

err_width

Numeric. Width of error bars (default 0.15)

fill_colors

Optional vector of fill colors

alpha

Numeric. Transparency of bars (default 1)

base_size

Numeric. Base font size (default 12)

legend_position

Character or numeric vector. Position of legend (default "right")

...

Additional ggplot2 layer arguments (e.g., fill, alpha, color)

Details

The plotThreeFactor function generates a bar plot of average fold change (relative expression) values for target genes using the output expression tables produced by functions such as ANOVA_DDCt() or ANOVA_DCt(). One factor is mapped to the x-axis, one to bar grouping (fill), and one to faceting. Error bars represent standard error (SE) or 95% confidence intervals, and optional grouping letters from post hoc statistical comparisons can be displayed.

Value

A ggplot object

Author(s)

Ghader Mirzaghaderi

Examples


# Perform analysis first
res <- ANOVA_DCt(
  data_3factor,
  numberOfrefGenes = 1,
  block = NULL
)

data <- res$Result

# Generate three-factor bar plot
p <- plotThreeFactor(
  data,
  x_col = 3,        # x-axis factor
  y_col = 5,        # bar height
  group_col = 1,    # grouping (fill)
  facet_col = 2,    # faceting factor
  Lower.se_col = 11,
  Upper.se_col = 12,
  letters_col = 13,
  letters_d = 0.3,
  col_width = 0.7, 
  dodge_width = 0.7,# controls spacing
  fill_colors = c("blue", "brown"),
  base_size = 16, 
  alpha = 1,
  legend_position = c(0.1, 0.2)
)

library(ggplot2)
p + theme(
  panel.border = element_rect(color = "black", fill = NA, linewidth = 0.5)
)

Bar plot of gene expression for two-factor experiments

Description

Creates a bar plot of relative gene expression (fold change) values from a two-factor experiment, including error bars and statistical significance annotations.

Usage

plotTwoFactor(
  data,
  x_col,
  y_col,
  group_col,
  Lower.se_col,
  Upper.se_col,
  letters_col = NULL,
  letters_d = 0.2,
  dodge_width = 0.8,
  col_width = 0.8,
  err_width = 0.15,
  fill_colors = NULL,
  alpha = 1,
  base_size = 12,
  legend_position = "right",
  ...
)

Arguments

data

A data frame containing expression results, typically obtained from ANOVA_DDCt() or ANOVA_DCt().

x_col

Integer specifying the column number used for the x-axis factor.

y_col

Integer specifying the column number used for the bar height (relative expression or fold change).

group_col

Integer specifying the column number used for grouping bars (fill aesthetic).

Lower.se_col

Integer specifying the column number used for the lower limit of the error bar.

Upper.se_col

Integer specifying the column number used for the upper limit of the error bar.

letters_col

Integer specifying the column number containing grouping letters from statistical comparisons.

letters_d

Numeric specifying the distance between sig letters and error bar.

dodge_width

Numeric. Width of the dodge position adjustment for grouped bars.

col_width

Numeric. Width of bars (default 0.8)

err_width

Numeric. Width of error bars (default 0.15)

fill_colors

Optional vector of fill colors

alpha

Numeric. Transparency of bars (default 1)

base_size

Numeric. Base font size (default 12)

legend_position

Character or numeric vector. Position of legend (default "right")

...

Additional ggplot2 layer arguments (e.g., fill, alpha, color)

Details

The plotTwoFactor function generates a bar plot of average fold change (relative expression) values for target genes using expression tables produced by functions such as ANOVA_DDCt() or ANOVA_DCt(). One factor is mapped to the x-axis and the second factor is used to group the bars (fill aesthetic). Error bars represent standard error (SE) or 95% confidence intervals (CI). Optional grouping letters from post hoc statistical comparisons can be displayed.

Value

A ggplot object

Author(s)

Ghader Mirzaghaderi

Examples


a <- ANOVA_DCt(data_2factorBlock, block = "Block", numberOfrefGenes = 1)
data <- a$Results

p1 <- plotTwoFactor(
  data = data,
  x_col = 2,
  y_col = 3,
  group_col = 1,
  Lower.se_col = 8,
  Upper.se_col = 9,
  letters_col = 12,
  letters_d = 0.2,
  fill_colors = c("aquamarine4", "gold2"),
  alpha = 1,
  col_width = 0.7,
  dodge_width = 0.7,
  base_size = 16, 
  legend_position = c(0.2, 0.8)
)
p1


p2 <- plotTwoFactor(
  data = data,
  x_col = 2,
  y_col = 4,
  group_col = 1,
  Lower.se_col = 10,
  Upper.se_col = 11,
  letters_col = 12,
  letters_d = 0.2,
  fill_colors = c("aquamarine4", "gold2"),
  alpha = 1,
  col_width = 0.7,
  dodge_width = 0.7,
  base_size = 16, 
  legend_position = c(0.2, 0.8)
)
p2