Skip to content

Instantly share code, notes, and snippets.

@halflearned
Created March 5, 2023 23:12
Show Gist options
  • Save halflearned/a97b343213411a4ff43355b20a936e99 to your computer and use it in GitHub Desktop.
Save halflearned/a97b343213411a4ff43355b20a936e99 to your computer and use it in GitHub Desktop.
Relative expression plot in python
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_excel("/Users/halflearned/Downloads/qPCR.xlsx")
# Rename expression column to something sensible
df = df.rename(columns={"2^(-ΔΔCq)": "expression"})
# Create the column that will be our horizontal axis
df["group"] = df["Sample"].str.split("-", expand=True)[0]
df["group"] = df["group"].str.replace("+12", ".5", regex=False)
# Plot plot plot
with sns.plotting_context("paper", font_scale=1.2):
ax = sns.pointplot(
data=df,
hue="Type",
x="group",
y="expression",
capsize=.1, # size of the horizontal thing at the extremity of the error bars
markers=".",
palette=["k", "C0", "C1"],
)
ax.set_ylabel("Relative expression (NR2F2)")
ax.set_xlabel("Time points")
ax.legend(frameon=False)
sns.despine()
ax.get_figure().savefig("/Users/halflearned/Desktop/relative_expression.jpeg", dpi=600)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment