微生物群落关键种识别:一种不依赖于网络的自上而下的方法

  微生物群落在促进养分循环、协助植物生长、维持人体健康等方面发挥着重要的作用。群落关键种对维持微生物群落稳定性具有重要影响,识别关键种一直是微生物生态学中的热点话题。识别关键种主要有两种框架:数据驱动的方法(data driven method)去除实验(perturbation experiment)。其中数据驱动的方法主要有三种:

  • 基于共现网络的方法
  • top-down方法
  • 基于深度学习的方法

注意:数据驱动的方法确定的关键种只是可能的关键种,还需要通过去除实验进一步地验证。

  • 基于共现网络的方法主要包括:构建共现网络→划分模块→计算模块间连通度和模块内连通度→确定关键种,该方法已在之前的博客中有所介绍:计算网络节点模块内连通度(within modular degree)和模块间连通度(between modular degree)
  • 基于深度学习的方法:这里先做个预告,代码和数据都整理好了,预计下周上线,具体可参考论文Identifying keystone species in microbial communities using deep learning
  • 本文主要介绍top-down方法,该方法源于论文:Top-down identification of keystone taxa in the microbiome。该方法通过计算Empirical Presence-abundance Interrelation (EPI)来衡量物种的重要性。

EPI指标计算的流程是:

  1. 根据物种i的有-无划分为两组:
  2. 将该物种去除,并将剩余物种的相对丰度标准化,使其和为1;
  3. 然后计算组和组的距离,即该物种的重要性,EPI;
  4. 物种EPI高于平均值+两个标准差的物种可以确定为关键种。

这里的某物种 i i i 的EPI有三种衡量方法:
在这里插入图片描述
D 1 i {D}_{1}^{i} D1i 的计算:

  1. 根据物种 i i i 的有-无划分为两组:
  2. 将该物种去除,并将剩余物种的相对丰度标准化,使其和为1;
  3. 计算组和组样品的两两间的Bray-Crutis距离。假设有5个样品A、B、C、D、E,其中组:A、B、C, 组: D、E。组和组样品的两两间的距离矩阵为:
IDABC
Dxxxxxxxxx
Exxxxxxxxx
  1. 然后取该矩阵的平均值,即为 D 1 i {D}_{1}^{i} D1i

计算 D 1 i {D}_{1}^{i} D1i R代码如下:

EPI_D1 <- function(S) {
  library(vegan)
  # Initialization
  N <- nrow(S)
  M <- ncol(S)
  S_01 <- ifelse(S>0,1,0)
  D1 <- rep(NA, N)
  
  for (i in 1:N) {
    # If the species is always present/absent, D1 is undefined
    if (sum(S_01[i, ], na.rm = TRUE) != 0 & sum(S_01[i, ], na.rm = TRUE) != M) {
      print(i)
      ind_pres <- S_01[i, ] != 0
      S2 <- S[-i, , drop = FALSE]
      S2 <- S2 / colSums(S2)
      bc <- as.matrix(vegdist(t(S2)))
      bc2 <- bc[ind_pres,!ind_pres]
      D1[i] <- sum(bc2) / (sum(ind_pres) * sum(!ind_pres))
    }
  }
  return(D1)
}

D 2 i {D}_{2}^{i} D2i 的计算:

  1. 根据物种 i i i 的有-无划分为两组:
  2. 将该物种去除,并将剩余物种的相对丰度标准化,使其和为1;
  3. 分别计算组和组样品的平均物种组成,获得 P ‾ \overline P P (P: Presence)和 A ‾ \overline A A (A: Absence),然后计算两者的平均值。假设有5个样品A、B、C、D、E,其中组:A、B、C, 组: D、E。组和组样品平均值如下:
IDABC P ‾ \overline P P
taxa1x1x2x3average(x1,x2,x3)
taxa2y1y2y3average(y1,y2,y3)
taxa3z1z2z3average(z1,z2,z3)
IDCD A ‾ \overline A A
taxa1x1x2average(x1,x2)
taxa2y1y2average(y1,y2)
taxa3z1z2average(z1,z2)
  1. 然后计算 P ‾ \overline P P A ‾ \overline A A的Bray-Crutis距离,即为 D 2 i {D}_{2}^{i} D2i

计算 D 2 i {D}_{2}^{i} D2i R代码如下:

EPI_D2 <- function(S) {
  N <- nrow(S)
  M <- ncol(S)
  S_01 <- ifelse(S>0,1,0)
  D2 <- rep(NA, N)
  
  for (i in 1:N) {
    # If the species is always present/absent, D2 is undefined
    if (sum(S_01[i, ], na.rm = TRUE) != 0 & sum(S_01[i, ], na.rm = TRUE) != M) {
      print(i)
      # Dividing into the two groups
      ind_pres <- S_01[i, ] != 0
      S_pres <- as.matrix(S[, ind_pres])
      S_abs <- as.matrix(S[, !ind_pres])
      
      # Removing the i species
      S_pres <- S_pres[-i, , drop = FALSE]
      S_abs <- S_abs[-i, , drop = FALSE]
      
      # Normalizing
      S_pres <- S_pres / colSums(S_pres)
      S_abs <- S_abs / colSums(S_abs)
      
      # Calculating D2
      D2[i] <- vegdist(rbind(rowMeans(S_pres), rowMeans(S_abs)))[1]
    }
  }
  return(D2)
}

Q i {Q}^{i} Qi 的计算:

  1. 根据物种 i i i 的有-无划分为两组:
  2. 将该物种去除,并将剩余物种的相对丰度标准化,使其和为1;
  3. 计算样品间的Bray-Crutis距离;
  4. 设定一定的阈值,构建样品-样品的网络,这里网络中的节点代表样品;
  5. 对网络中的节点(代表样品)赋予模块,例如:模块1代表模块2代表
  6. 计算该网络的模块度(modularity),即为 Q i {Q}^{i} Qi

计算 Q i {Q}^{i} Qi 的R代码如下:

EPI_Q <- function(S, threshold_net) {
  N <- nrow(S)
  M <- ncol(S)
  S_01 <- ifelse(S > 0,1,0)
  Q <- rep(NA, N)
 
  modularity <- function(B, s) {
    library(igraph)
    B_graph <- graph.adjacency(B, mode = "undirected")
    d <- degree(B_graph) # Degree of each sample
    q <- sum(B) / 2
    Qmod <- (t(s) %*% (B - (d %*% t(d)) / (2 * q)) %*% s) / (4 * q)
    return(Qmod)
  }
  
  for (i in 1:N) {
    # If the species is always present/absent, Q is undefined
    if (sum(S_01[i, ], na.rm = TRUE) != 0 & sum(S_01[i, ], na.rm = TRUE) != M) {
      print(i)
      # Removing the i species
      S_i <- S[-i,]
      
      # Normalizing
      S_i <- S_i / colSums(S_i)
      
      # Building the network
      distances_i <- as.matrix(vegdist(t(S_i)))
      dist_threshold <- quantile(distances_i, threshold_net)
      B_i <- as.matrix(distances_i <= dist_threshold)
      diag(B_i) <- 0
      s_i <- as.numeric(S_01[i, ])
      s_i[s_i == 0] <- -1
      
      # Calculating
      Q[i] <- modularity(B_i, s_i)
    }
  }
  
  return(Q)
}

觉得博主写地不错的话,可以买箱苹果,支持博主
更多测试数据及R代码可参考如下连接:https://mbd.pub/o/bread/ZZ2bm5hx

  • 23
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

道阻且长1994

您的鼓励有助于我创作更多高质量

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值