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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| rm(list = ls())
library(tidyverse) library(reshape2) library(ggsci) library(extrafont) loadfonts()
df = read.csv('data_for_plot.csv', header = T, encoding = 'utf-8') %>% reshape2::melt(id.vars = c(1:3, 16:18)) colnames(df)[1] = 'receptor' df$receptor = as.character(df$receptor) df$Neighbored.by = as.character(df$Neighbored.by)
p = ggplot(df) + geom_bar(aes(gene, mean, fill = Neighbored.by), stat = 'identity',position = 'dodge',width = 1) + geom_point(aes(gene, value, group = Neighbored.by), position = position_dodge(width = 1)) + geom_hline(yintercept = 4.5, color = 'white') + geom_errorbar(aes(gene, ymin = mean - se, ymax = mean + se, group = Neighbored.by), position = position_dodge(width = 1), width = 0.5) + scale_y_continuous(expand = c(0,0)) + scale_fill_manual(values = c('#008000','#FFA74F', '#663300','#FF5900')) + facet_grid(~ receptor) + labs(x = '', y = 'Relatice expression') + theme_bw()+ theme(axis.ticks.x = element_blank(), legend.text = element_text(color = 'black',size = 12, family = 'Arial', face = 'plain'), panel.background = element_blank(), panel.grid = element_blank(), axis.text = element_text(color = 'black',size = 15, family = 'Arial', face = 'plain'), axis.title = element_text(color = 'black',size = 15, family = 'Arial', face = 'plain'), axis.ticks = element_line(color = 'black')) p ggsave(p, filename = 'res.pdf', width = 5, height = 4, device = cairo_pdf)
|