METAflux | 实操教程1-简介和快速上手

文化   2024-10-18 11:02   黑龙江  

Introduction

METAFlux 是一个用于从Bulk RNA-seq 或single cell RNA-seq数据评估代谢通量的软件。一般来说,代谢通量通常以 mmol/gDW/hr 为单位测量,是反应代谢速率的指标。然而,在 METAFlux 中,预测的通量是根据基因表达数据计算和归一化的,这意味着其输出的结果是相对通量分数。今天小编就来通过代码实操的方式,带着大家快速上手METAFlux。

a METAFlux 在Bulk RNA-seq 中的工作流程。

在步骤 A 中,根据 RNA-seq 数据估计代谢反应活性评分 (MRAS)。在步骤 B 中,定义了代谢物成分,因此只能吸收某些代谢物。在步骤 C 中,执行基于二次规划的 FBA(通量平衡分析)以估计每个样品的代谢通量。

b METAFlux 在Single cell RNA-seq 中的工作流程。

在步骤 A 中,为每个分层的 bootstrap 采样单细胞数据集估计代谢反应活性评分 (MRAS)。在步骤 B 中,不同簇的代谢网络合并形成一个群落,并且在此步骤中应定义簇的比例。在步骤 C 中,定义了代谢物,因此只有特定的代谢物才能被 TME 吸收。在步骤 D 中,构建基于社区的二次编程 FBA 以估计每个簇的每个细胞的平均代谢通量和整个 TME 的总平均代谢通量。

Bulk RNA_seq data analysis

首先,我们先来介绍使用METAFlux分析Bulk RNA_seq数据。Bulk RNA_seq数据的分析流程比起scRNA_seq的分析流程要简单一些,这很大程度上是由于数据本身的复杂程度决定的。

处理细胞系数据

需要注意的是转录组数据这里只提供了人源样本和细胞系的代谢反应及代谢物数据,老鼠的暂时没有提供。

library(METAFlux)
#load the toy example
data("bulk_test_example")
#medium file for cell line model
data("cell_medium")
#Calculate mras for cell line data
scores<-calculate_reaction_score(bulk_test_example)
#Calculate flux for cell line data
flux<-compute_flux(mras=scores,medium = cell_medium) 

#optional: flux scores cubic root normalization
# cbrt <- function(x) {
#     sign(x) * abs(x)^(1/3)
# }

# flux=cbrt(flux)

注释掉的这一部分是对于数据的归一化处理,细胞系默认没有归一化,计算表达谱数据绝对值abs(x)的立方根(1/3)次幂,可以帮助减少极端值的影响,使数据分布更加均匀。为啥标识optional呢,我们后面再讨论

如图是葡萄糖摄取水平,这里看一下如果归一后是否有变化

可以看到,热图中V4,V5列产生了变化。一些不那么明显的通路展示出来了,但也有一些之前明显的通路的的显著性减弱。不过具体是否需要进行归一化要看分析项目目的确定

处理人源数据

library(METAFlux)
#load the toy example
data("bulk_test_example")
# medium file for human derived samples
data("human_blood")
#Calculate mras for human sample data
scores<-calculate_reaction_score(bulk_test_example)
#Calculate flux for human sample data
flux<-compute_flux(mras=scores,medium=human_blood) 

#optional: flux scores cubic root normalization
cbrt <- function(x) {
    sign(x) * abs(x)^(1/3)
}

flux=cbrt(flux)

人源数据软件默认做归一化处理。

图片解读可以参考上述细胞系的

scRNA-seq data analysis

同单细胞转录组数据分析流程一样,METAflux对scRNA-seq数据的代谢分析流程也有分单样本数据和多样本数据的处理。

处理单样本单细胞测序数据

library(METAFlux)
#load the toy seurat example, this data only has one patient. For mutiple samples,see example code at the end of this section.
data("sc_test_example")
# medium file for human derived samples
data("human_blood")

#check cell types
table(sc_test_example$Cell_type)

#Calculate the mean expression for bootstrap samples from seurat object
#Using "Cell_type" in seurat as my grouping variable
#For the sake of demonstration, we only set the number of bootstraps to 3. 
#In real analysis, the number of bootstraps should be much higher(e.g. 100, 200....)
mean_exp=calculate_avg_exp(myseurat = sc_test_example,myident = 'Cell_type',n_bootstrap=3,seed=1)

#calculate metabolic reaction scores
scores<-calculate_reaction_score(data=mean_exp)

#calculate the fractions of celltype/clusters
round(table(sc_test_example$Cell_type)/nrow(sc_test_example@meta.data),1)

在统计分析中,bootstrap是一种重采样方法,用于估计一个统计量的分布(例如均值、中位数、方差等)。通过从原始数据集中多次有放回地随机抽取样本,可以创建多个“bootstrap样本”,然后对每个样本计算感兴趣的统计量。这个过程可以帮助评估统计量的不确定性和置信区间。这里是示例练习,所以bootstrap设置为3;真实分析过程时bootstrap应该设置为几百,这里在后面也会详细介绍

这里使用的是人类血液样本作为操作对象,但当对象是细胞系时需要使用细胞系,即需要和对象保持一致

#num_cell=number of cell types/clusters, here we have 4 cell types, thus input is 4. Make sure the sum of cell percentage is 1.The order of fraction should be the same as that of "Mean_exp" data
flux=compute_sc_flux(num_cell = 4,fraction =c(0.1,0.3,0.3,0.3),fluxscore=scores,medium = human_blood)

#optional: flux scores normalization
cbrt <- function(x) {
    sign(x) * abs(x)^(1/3)
}

flux=cbrt(flux)

处理多样本单细胞测序数据

仔细看代码其实不难发现,官网提供的多样本处理流程是在分割对象后写了一个循环,其实和单样本处理流程的区别不大。

#load your seurat object
#sample code for 4 clusters in multiple patients
obj.list <- SplitObject(seurat, split.by = "patient_id")

for (i in c(1:length(obj.list))){
sc<-obj.list[[i]]
mean_exp=calculate_avg_exp(myseurat = sc_test_example,myident = 'Cell_type',n_bootstrap=50,seed=1)
scores<-calculate_reaction_score(data=mean_exp)
#g=round(table(sc$Cell_type)/nrow(sc@meta.data),3)
g=table(sc$Cell_type)/nrow(sc@meta.data)
print(g)
flux=compute_sc_flux(num_cell = 4,fraction =c(g[1],g[2],g[3],g[4]),fluxscore=scores,medium = human_blood)
saveRDS(flux,paste0("object",i,".rds"))
}


好啦,我们关于METAflux软件的第一次代码实操就分享到这里了。后续还会持续推出代码教程,敬请关注!


关注公众号,下回更新不迷路


生信宝库
本公众号只用于生信知识的收集与传播,以及生信人之间互相交流和学习,不会涉及任何商业利益。本公众号各小编平时忙于科研,更新文章较其它同类型公众号较慢,但保持宁缺毋滥的本心,只更新对大家有用的推文。
 最新文章