美文网首页
[R语言] GO富集分析可视化 GOplot::GOCircle

[R语言] GO富集分析可视化 GOplot::GOCircle

作者: 半为花间酒 | 来源:发表于2020-04-11 22:03 被阅读0次

转载请注明:陈熹 chenx6542@foxmail.com (简书号:半为花间酒)

分析和预处理

查看GOplot内示例数据的格式,对自己的数据做处理

library(GOplot)
library(dplyr)

data(EC)
class(EC)
# [1] "list"

David <- EC$david
View(David )
Genelist <- EC$genelist
View(Genelist)

观察结论:

  1. David富集分析表和gene差异分析表注意所含列以及表头
  2. David表gene之间用', '分隔开
  3. David表除各别注释外,adj.pval一般小于0.05

- 数据预处理

观察自己的两个数据表:

# 处理genelist
genelist <- nrDEG %>% 
  tibble::rownames_to_column(var="ID") 

df <- as.data.frame(nrDEG)
df$Regulate =ifelse(df$logFC <=-1& df$P.Value<=0.05,'Down',
                    ifelse(df$logFC >=1 & df$P.Value<=0.05,'Up','Stream'))
new_df <- df[which(df$Regulate=='Up'|df$Regulate=='Down'),]

Genelist <- genelist[genelist$ID %in% new_df$name,]
# 处理david
library(stringr)
GO_all <- ALL_ego@result
GO_all$geneID <- gsub(pattern = '/',replacement = ', ',GO_all$geneID)

david <- GO_all %>% 
  tibble::rownames_to_column(var="wait") 

David <- david %>% 
  dplyr::select(c(2:4,10,8)) %>% 
  dplyr::rename(Category = ONTOLOGY,
                Term = Description,
                Genes = geneID,
                adj_pval = p.adjust) %>% 
  filter(adj_pval < 0.05)

# 交互
circ <- circle_dat(David,Genelist)

GOCircle

windowsFonts(HEL=windowsFont("Helvetica CE 55 Roman"),
             RMN=windowsFont("Times New Roman"),
             ARL=windowsFont("Arial"),
             JBM=windowsFont("JetBrains Mono"))

IDs <- c('GO:0035456', 'GO:0035458', 'GO:0034341', 'GO:0060700', 
         'GO:0045088', 'GO:0043901', 'GO:0045071', 'GO:0032069', 'GO:0019221')

GOCircle(circ,
         nsub = IDs,
         # nsub = 9, # 也可以指定数字
         rad1 = 2, rad2 = 3, # 内径、外径设置
         zsc.col = c('firebrick3', 'white', 'royalblue3'),# z-score颜色设置
         lfc.col = c('firebrick3', 'royalblue3'),# 上调下调颜色设置
         label.size = 9.5,
         label.fontface='bold',# 字体大小格式设置
         table.legend = F 
         # 右侧表格设置,为TRUE则无法设置theme
         # 如果解除表格加theme会释放出网格线和坐标轴
         ) +
  # 去除大背景颜色
  theme_bw() +
  theme(
    # 去除坐标轴文本、刻度线、标题
    axis.text = element_blank(),
    axis.ticks = element_blank(),
    axis.title = element_blank(),
    # 去除坐标轴边框、图内网格线
    panel.border = element_blank(),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank()
    ) +
  # 字体相关设置
  theme(legend.text = element_text(size = 16),
        legend.title = element_text(size = 20),
        text = element_text(family="ARL"))

# 结果可用ggsave保存
ggsave(here::here('.',paste0("GOCircle ", format(Sys.time(), "%Y%m%d"), ".png")), 
       dpi = 320, width = 14, height = 10)

table.legend设置为T时会显示表格

本图中表格和图例是出图后剪切拼合而成,没有用R中的拼图包

相关文章

网友评论

      本文标题:[R语言] GO富集分析可视化 GOplot::GOCircle

      本文链接:https://www.haomeiwen.com/subject/lzepmhtx.html