不積跬步有送,無以至千里
本期我們嘗試“部分”復(fù)現(xiàn)2023年2月27日發(fā)表在Nature Communications上的Itaconate ameliorates autoimmunity by modulating T cell imbalance via metabolic and epigenetic reprogramming文章中的Fig2A
。
以下是原圖:
數(shù)據(jù)可以自行下載岩灭,也可評論區(qū)留言我私發(fā)給你。
代碼
library(ggplot2)
library(tidyverse)
library(tidyr)
library(readr)
data <- read_csv(file = 'data.csv',
skip = 1,
col_names = c('Day', paste('Ctrl', 1:11, sep = "_"), paste('ITA', 1:11, sep = "_")))
SEM <- function(vec) sd(vec)/sqrt(length(vec))
#control
data %>%
select(starts_with('Ctrl')) %>%
{
mean = apply(., MARGIN = 1, FUN = mean)
sem = apply(., MARGIN = 1, FUN = SEM)
data.frame(class = rep('Ctrl', nrow(data)),
days = factor(1:nrow(data), levels = 1:nrow(data)),
mean = mean,
sem = sem)
} -> ctrl
#ita
data %>%
select(starts_with('ITA')) %>%
{
mean = apply(., MARGIN = 1, FUN = mean)
sem = apply(., MARGIN = 1, FUN = SEM)
data.frame(class = rep('ITA', nrow(data)),
days = factor(1:nrow(data), levels = 1:nrow(data)),
mean = mean,
sem = sem)
} -> ita
rbind(ctrl, ita) %>%
ggplot(aes(x = days, y = mean)) +
geom_line(aes(group = class, color = class), size = 1) +
geom_point(aes(color = class), shape = 1, size = 2, stroke = 1.5) +
geom_errorbar(aes(ymin = mean - sem, ymax = mean + sem, color = class), size = 1, width = 0.6) +
scale_color_manual(values = c('#8B8D23', '#028C8F')) +
scale_y_continuous(limits = c(0, 4)) +
scale_x_discrete(breaks = c(0, 5, 10, 15)) +
theme_classic() +
labs(x = 'Day', y = 'Clinical score') +
theme(legend.position = c(0.15, 0.9),
legend.background = element_blank(),
legend.title = element_blank(),
axis.title = element_text(family = 'sans', color = 'black'),
axis.text = element_text(family = 'sans', color = 'black'),
axis.line = element_line(color = 'black', size = 1),
axis.ticks = element_line(color = 'black', size = 1)) +
annotate(geom = 'segment', x = 16, xend = 16, y = 1.4, yend = 2.7, size = 1) +
annotate(geom = 'segment', x = 15.5, xend = 16, y = 1.4, yend = 1.4, size = 1) +
annotate(geom = 'segment', x = 15.5, xend = 16, y = 2.7, yend = 2.7, size = 1) +
annotate(geom = 'text', label = 'P = 0.0001', angle = 90, x = 17, y = 2.15, vjust = "left", hjust = "center")
最終效果
寫在最后
原始圖中
errorbar
只顯示了一半赂鲤,這可以通過geom_segment()
來實現(xiàn)噪径,但在這里我沒有做。關(guān)于原圖中的
P
如何顯示成為P
数初,目前我還沒有找到一個好辦法找爱。