R语言做图收藏跟着SCI学作图

跟着Nature Communications学作图:R语言Up

2022-06-19  本文已影响0人  小明的数据分析笔记本

论文

A highly conserved core bacterial microbiota with nitrogen-fixation capacity inhabits the xylem sap in maize plants

https://www.nature.com/articles/s41467-022-31113-w

本地pdf s41467-022-31113-w.pdf

数据代码链接

https://github.com/PlantNutrition/Liyu

今天的推文我们重复一下论文中的Figure2c

image.png

首先是输入数据的格式

image.png

第一列是所有的基因名,读取数据后要将其转换成行名

后面每一列是数据分组,如果这个基因存在于这一组,就标识为1,如果不存在就标识为0

读取示例数据

library(tidyverse)
library(readxl)
dat01<-read_excel("data/20220618/example_upsetR.xlsx") %>% 
  column_to_rownames("gene_name")
dat01

作图代码

library(UpSetR)

upset(dat01)
image.png

如果要突出强调某一组

queries = list(list(query = intersects, 
                    params = list("group01","group03"), 
                    active = T,
                    color="#d66a35", 
                    query.name = "ABC"))
upset(dat01,
      queries = queries)
image.png

接下来是论文中提供的数据和代码

otu_RA <- read.delim('example_data/09-venndiagram/otu_RA.txt', header = TRUE, row.names = 1, sep = '\t')
head(otu_RA)
otu_RA[otu_RA > 0] <- 1

head(otu_RA)

他这里把otu表格里有数值的就变成1,只要有数值就说明这个样本中有这个otu

list(list(query=intersects,
          params=list("RS","BS"),
          active=T,
          color="red"),
     list(query=intersects,
          params=list("RS","BS","RE"),
          active=T,
          color="blue")) -> queries
upset(otu_RA, 
      nset = 7, 
      nintersects = 10, 
      order.by = c('degree','freq'),
      decreasing = c(FALSE, TRUE),
      mb.ratio = c(0.5, 0.5),
      point.size = 1.8,
      line.size = 1, 
      mainbar.y.label = "Intersection size", 
      sets.x.label = "Set Size", 
      main.bar.color = "#2a83a2", 
      sets.bar.color = "#3b7960",
      queries = queries)
image.png

示例数据和代码可以到论文中去下载,或者直接在公众号后台留言20220618获取

明天下午两点半到3点半直播分享R语言ggplot2科研数据可视化入门的一些基础内容,感兴趣的可以参加 腾讯会议号984290307,密码220222。感兴趣的参加。参考文档链接https://rpubs.com/xiaoming24/916001

欢迎大家关注我的公众号

小明的数据分析笔记本

小明的数据分析笔记本 公众号 主要分享:1、R语言和python做数据分析和数据可视化的简单小例子;2、园艺植物相关转录组学、基因组学、群体遗传学文献阅读笔记;3、生物信息学入门学习资料及自己的学习笔记!

上一篇下一篇

猜你喜欢

热点阅读