數(shù)據(jù)是我轉(zhuǎn)錄分析的到的基因表達(dá)量
導(dǎo)入數(shù)據(jù)如圖所式:

此表格為某個(gè)基因在兩個(gè)樣本即CM和HP三個(gè)生物重復(fù)的表達(dá)Mean和SE(SE為標(biāo)準(zhǔn)誤差,可用來(lái)評(píng)估準(zhǔn)確性或精確性,用來(lái)估計(jì)抽樣誤差),此表格在excel中保存為csv格式
將數(shù)據(jù)導(dǎo)入R,用ggplot進(jìn)行繪圖
代碼如下:
##導(dǎo)入數(shù)據(jù)
data<-read.csv("D:/桌面/bidui/geneex.csv",stringsAsFactors=FALSE)?
##代碼畫圖
ggplot(data,aes(x=sample,y=mean,fill=group))+
? geom_bar(stat='identity',position=position_dodge(0.3),width=0.3)+
? geom_errorbar(aes(ymin = mean - se, ymax = mean + se),width = 0.1, size = 0.8, position = position_dodge(0.3),color='black',linetype=1) +
? scale_fill_manual(name='',values = c('#eb4d4b', '#16a085')) +
? theme(panel.grid = element_blank(), panel.background = element_blank(), axis.line = element_line(colour = 'black'), legend.position = c(0.9, 0.85)) +
? scale_y_continuous(expand = c(0, 0), limit = c(0, 25))+
? xlab('')+
? ylab('Relative expression level')+
? labs(title="LOC107420087")+
? theme(plot.title = element_text(hjust = 0.5,size=16,face="bold"))+
? theme(legend.text=element_text(size=14,color = "black"))+
? theme(axis.line=element_line(colour = "black",size=0.8),axis.text = element_text(size=14,colour="black"))+
? theme(axis.title.y = element_text(size=14,color = "black"))+
? theme(axis.ticks = element_line(color = "black",size=0.8))

寫在最后,此代碼還不夠精簡(jiǎn),打算畫這種基因表達(dá)圖的小伙伴們可以試著去完善代碼畫出自己滿意的圖,有些代碼單獨(dú)看不知道是設(shè)置什么的,可以自己嘗試運(yùn)行改一下就了解了。