多样本物种组成

### 1 样本物种注释后会得到各个水平的相对丰度表

## 种水平的相对丰度 物种注释
Samples sp1 sp2 sp3
S__Abiotrophia_defectiva 0 2.16456839333914e-06 0
S__Acetanaerobacterium_elongatum 1.05806590497696e-06 0 0
S__Acetitomaculum_ruminis 0 0 0
S__Acetivibrio_cellulolyticus 0 9.89868878213682e-06 0
S__Acetivibrio_ethanolgignens 2.54762969610528e-05 4.89713417844563e-05 1.68196117368884e-05
S__Acetoanaerobium_noterae 0 0 0
S__Acetoanaerobium_sticklandii 0 0 0

### 2 对数据进行处理,取前N优势物种

思路: ①对每个样本取前N优势物种,去重复,得到矩阵,再进行R 绘制图;② 对每个物种的所有样本求和,排序,前N的优势物种。

### 思路②

topNData = taxonomy[order(apply(data, 1, sum),decreasing = 1)[1:topN],]

others=1- apply(topNData, 2, sum)
others=as.data.frame(others)

topNData=rbind(topNData,t(others))

### 3 R绘图

## ggplot 很青睐 长格式的数据(melt)

ggplot(dataTM,aes(sample,value,fill=variable))+
  guides(fill = guide_legend(keywidth = 0.8, keyheight = 0.8, title="type", size=5,ncol = 1 )) +
  theme_bw()+geom_bar(stat="identity",position="stack")+
  +theme_calc()+

  ylab("Relative abundance")+xlab("Samples")

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值