Plot guides › By field

Plot qPCR data (ΔΔCt fold change)

With the ΔΔCt method, each sample's Ct is normalised to a reference gene (ΔCt), then to the control condition (ΔΔCt), and relative expression is 2^−ΔΔCt. The plot shows mean fold change per condition with the biological replicates on top.

Example plot qpcr data (δδct fold change) made with matplotlib
Rendered from the code below, with example data.

When to use it

Watch out: The ΔΔCt method assumes primer efficiencies close to 100% for the target and reference genes. Check the efficiencies first.

Ask for it in pltchat

Upload your file and type something like:

"compute 2^-ΔΔCt per condition using GAPDH as reference and control as baseline, bar + points, log2 y axis"

pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.

The matplotlib code

Self-contained with example data; swap in pd.read_csv(...) or pd.read_excel(...) for your own file.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

rng = np.random.default_rng(30)
rows = []
for cond, shift in [("Control", 0), ("Treatment 1", -1.6), ("Treatment 2", -0.7)]:
    for rep in range(4):
        ref = 18 + rng.normal(0, 0.2)
        rows.append({"condition": cond, "rep": rep, "gene": "GAPDH", "ct": ref})
        rows.append({"condition": cond, "rep": rep, "gene": "IL6",
                     "ct": ref + 8 + shift + rng.normal(0, 0.3)})
df = pd.DataFrame(rows)

wide = df.pivot_table(index=["condition", "rep"], columns="gene", values="ct")
wide["dct"] = wide["IL6"] - wide["GAPDH"]
control_mean = wide.loc["Control", "dct"].mean()
wide["fold"] = 2 ** -(wide["dct"] - control_mean)
summary = wide.groupby(level="condition", sort=False)["fold"].agg(["mean", "std"])

fig, ax = plt.subplots(figsize=(4.8, 4))
x = np.arange(len(summary))
ax.bar(x, summary["mean"], yerr=summary["std"], capsize=5,
       color="lightgray", edgecolor="k", width=0.6)
for i, cond in enumerate(summary.index):
    pts = wide.loc[cond, "fold"]
    ax.scatter(i + rng.uniform(-0.1, 0.1, len(pts)), pts, color="k", s=14, zorder=3)
ax.axhline(1, color="gray", ls="--", lw=0.8)
ax.set_yscale("log", base=2)
ax.set_xticks(x, summary.index)
ax.set_ylabel("IL6 relative expression (2^−ΔΔCt)")
ax.spines[["top", "right"]].set_visible(False)
plt.tight_layout()
plt.show()

Make this with your data

Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.

Related plots