-
Notifications
You must be signed in to change notification settings - Fork 0
/
Western Blot Total Protein FC Boxplot.R
28 lines (26 loc) · 1.33 KB
/
Western Blot Total Protein FC Boxplot.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(tidyverse)
library(ggpubr)
library(RColorBrewer)
# Load in csv containing densities of western blots
# Must contain three columns: 1) Source, 2) Sample, 3) Density
df <- read.csv('~/Densities.csv', header = TRUE)
df$Sample <- factor(df$Sample, levels=c('WT', 'E638A', 'P1', 'P2'))
# Plot the data in a boxplot
p <- ggplot(df, aes(x=Sample, y=Density, fill=Sample)) +
theme_minimal() +
theme(legend.position = 'none') +
theme(
axis.text = element_text(size=16),
axis.title.x = element_blank(),
axis.title.y = element_text(size=20)) +
geom_boxplot(position=position_dodge(width=0.8), width=0.7, outlier.shape = NA) + # Boxplot
geom_text(data=data.frame(Sample=unique(df$Sample), Density=max(df$Density)),
aes(label="n=6"), vjust=-2, position=position_dodge(width=0.8)) + # Add "n=6" above each boxplot
stat_summary(fun=mean, geom="point", shape=4, size=7, color="red", position=position_dodge(width=0.8)) + # Mean as red cross
stat_summary(fun=mean, geom="text",
vjust=3.5, # Adjust this value to position the text above the mean point
aes(label=sprintf("%.2f", ..y..)), # Format to 2 decimal places
position=position_dodge(width=0.8)) + # Display mean value
scale_fill_brewer(palette = 'Set3')
p
ggsave('~/Densities.png', p, height = 10, width = 10, dpi = 300)