>fpkm <- read.csv(file = "clipboard", header = T, sep = "\t")? ?# 讀取分析好的差異表達數據
>head(fpkm)
>fpkm$type <- ifelse(fpkm$regulation == "up" & fpkm$significant == "yes","up",
? ? ? ? ? ? ? ? ? ? ? ? ifelse(fpkm$regulation == "down" & fpkm$significant == "yes","down","no"))
>data2 <- fpkm[ , c(1,2,4,6)]
>head(data2)
>data2$pval <- -log10(data2$pval)
>data2$type <- as.factor(data2$type)
>ggplot(data2)+
? geom_point(mapping = aes(x = log2FC, y = pval, color = type), size = 3, alpha = 0.8)+
? scale_color_manual(values = c("skyblue","grey","pink"))+? ? ? ? ? # 自定義設置顏色
? labs(title = "LPF vs LPE", x = "log2(fold change)", y = "log10(p-value)")+
? #geom_hline(yintercept = -log10(0.05), linetype = "dashed", size = 1, color = "grey")+? ? ? ? ? ?#在圖中畫橫線
? #geom_vline(xintercept = c(-1,1), linetype = "dashed", size = 1, color = "grey", intercept = 0)+? ? ? ?#在圖中畫垂線
? geom_segment(mapping = aes(x = -1, y = 0, xend = -1, yend = 22), linetype = "dashed", size = 1, color = "grey")+? ? ? #在圖中任意位置畫線
? geom_segment(mapping = aes(x = 1, y = 0, xend = 1, yend = 22), linetype = "dashed",size = 1, color = "grey")+
? geom_segment(mapping = aes(x = -12, y = -log10(0.05), xend = 16, yend = -log10(0.05)), linetype = "dashed", size = 1, color = "grey")+
? coord_cartesian(expand = T)+? ? ?#調整坐標軸,可以設置圖像是否挨著坐標軸
? theme(axis.text = element_text(size = rel(1.5)),??
? ? ? ? axis.line = element_line(size = rel(1.5)),
? ? ? ? axis.title = element_text(size = rel(1.5)),
? ? ? ? panel.background = element_blank())
繪制圖片結果: