单细胞scMetabolism代谢相关通路分析学习和整理

scMetabolism一个单细胞水平的代谢相关通路分析工具。

内置了KEGG_metabolism_nc和REACTOME_metabolism两个库的代谢通路信息。

分析方法可选择VISION、AUCell、ssgsea和gsva这四种,默认是VISION。

其他没有什么需要特殊介绍的。

分析流程
1.导入
rm(list = ls())
# V5_path = "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/seurat5/"
# .libPaths(V5_path)
# .libPaths()
library(stringr)
library(Seurat)
library(rsvd)
library(qs)
library(scMetabolism)
library(BiocParallel)
register(MulticoreParam(workers = 4, progressbar = TRUE))

scRNA <- qread("sc_dataset.qs") # V4 data
sub_scRNA <- subset(scRNA,
                    subset = celltype %in% c("epithelial/cancer cells",
                                              "myeloid cells"))
load("scRNA.Rdata") # V5 data
2.V5版本(需修改代码)
sc.metabolism.SeuratV5 <- function (obj, method = "VISION", imputation = F, ncores = 2, 
  metabolism.type = "KEGG") 
{
  countexp <- GetAssayData(obj, layer='counts')
  countexp <- data.frame(as.matrix(countexp))
  signatures_KEGG_metab <- system.file("data", "KEGG_metabolism_nc.gmt", 
    package = "scMetabolism")
  signatures_REACTOME_metab <- system.file("data", "REACTOME_metabolism.gmt", 
    package = "scMetabolism")
  if (metabolism.type == "KEGG") {
    gmtFile <- signatures_KEGG_metab
    cat("Your choice is: KEGG\n")
  }
  if (metabolism.type == "REACTOME") {
    gmtFile <- signatures_REACTOME_metab
    cat("Your choice is: REACTOME\n")
  }
  if (imputation == F) {
    countexp2 <- countexp
  }
  if (imputation == T) {
    cat("Start imputation...\n")
    cat("Citation: George C. Linderman, Jun Zhao, Yuval Kluger. Zero-preserving imputation of scRNA-seq data using low-rank approximation. bioRxiv. doi: https://doi.org/10.1101/397588 \n")
    result.completed <- alra(as.matrix(countexp))
    countexp2 <- result.completed[[3]]
    row.names(countexp2) <- row.names(countexp)
  }
  cat("Start quantify the metabolism activity...\n")
  if (method == "VISION") {
    library(VISION)
    n.umi <- colSums(countexp2)
    scaled_counts <- t(t(countexp2)/n.umi) * median(n.umi)
    vis <- Vision(scaled_counts, signatures = gmtFile)
    options(mc.cores = ncores)
    vis <- analyze(vis)
    signature_exp <- data.frame(t(vis@SigScores))
  }
  if (method == "AUCell") {
    library(AUCell)
    library(GSEABase)
    cells_rankings <- AUCell_buildRankings(as.matrix(countexp2), 
      nCores = ncores, plotStats = F)
    geneSets <- getGmt(gmtFile)
    cells_AUC <- AUCell_calcAUC(geneSets, cells_rankings)
    signature_exp <- data.frame(getAUC(cells_AUC))
  }
  if (method == "ssGSEA") {
    library(GSVA)
    library(GSEABase)
    geneSets <- getGmt(gmtFile)
    gsva_es <- gsva(as.matrix(countexp2), geneSets, method = c("ssgsea"), 
      kcdf = c("Poisson"), parallel.sz = ncores)
    signature_exp <- data.frame(gsva_es)
  }
  if (method == "ssGSEA") {
    library(GSVA)
    library(GSEABase)
    geneSets <- getGmt(gmtFile)
    gsva_es <- gsva(as.matrix(countexp2), geneSets, method = c("gsva"), 
      kcdf = c("Poisson"), parallel.sz = ncores)
    signature_exp <- data.frame(gsva_es)
  }
  cat("\nPlease Cite: \nYingcheng Wu, Qiang Gao, et al. Cancer Discovery. 2021. \nhttps://pubmed.ncbi.nlm.nih.gov/34417225/   \n\n")
  obj@assays$METABOLISM$score <- signature_exp
  obj
}

Idents(scRNA) <- "celltype"
res <-sc.metabolism.SeuratV5(obj = scRNA,
                             method = "VISION", # VISION、AUCell、ssgsea和gsva
                             imputation =F, ncores = 2, 
                             metabolism.type = "KEGG") # KEGG和REACTOME
3.V5可视化(需修改代码)
# 需要修改DimPlot.metabolism中的UMAP大小写
DimPlot.metabolismV5 <- function (obj, pathway, dimention.reduction.type = "umap", dimention.reduction.run = T, 
  size = 1) 
{
  cat("\nPlease Cite: \nYingcheng Wu, Qiang Gao, et al. Cancer Discovery. 2021. \nhttps://pubmed.ncbi.nlm.nih.gov/34417225/   \n\n")
  if (dimention.reduction.type == "umap") {
    if (dimention.reduction.run == T) 
      obj <- Seurat::RunUMAP(obj, reduction = "pca", dims = 1:40)
    umap.loc <- obj@reductions$umap@cell.embeddings
    row.names(umap.loc) <- colnames(obj)
    signature_exp <- obj@assays$METABOLISM$score
    input.pathway <- pathway
    signature_ggplot <- data.frame(umap.loc, t(signature_exp[input.pathway, 
      ]))
    library(wesanderson)
    pal <- wes_palette("Zissou1", 100, type = "continuous")
    library(ggplot2)
    plot <- ggplot(data = signature_ggplot, aes(x = umap_1, 
      y = umap_2, color = signature_ggplot[, 3])) + geom_point(size = size) + 
      scale_fill_gradientn(colours = pal) + scale_color_gradientn(colours = pal) + 
      labs(color = input.pathway) + xlab("UMAP 1") + ylab("UMAP 2") + 
      theme(aspect.ratio = 1) + theme(panel.grid.major = element_blank(), 
      panel.grid.minor = element_blank(), panel.background = element_blank(), 
      axis.line = element_line(colour = "black"))
  }
  if (dimention.reduction.type == "tsne") {
    if (dimention.reduction.run == T) 
      obj <- Seurat::RunTSNE(obj, reduction = "pca", dims = 1:40)
    tsne.loc <- obj@reductions$tsne@cell.embeddings
    row.names(tsne.loc) <- colnames(obj)
    signature_exp <- obj@assays$METABOLISM$score
    input.pathway <- pathway
    signature_ggplot <- data.frame(tsne.loc, t(signature_exp[input.pathway, 
      ]))
    pal <- wes_palette("Zissou1", 100, type = "continuous")
    library(ggplot2)
    plot <- ggplot(data = signature_ggplot, aes(x = tSNE_1, 
      y = tSNE_2, color = signature_ggplot[, 3])) + geom_point(size = size) + 
      scale_fill_gradientn(colours = pal) + scale_color_gradientn(colours = pal) + 
      labs(color = input.pathway) + xlab("tSNE 1") + ylab("tSNE 2") + 
      theme(aspect.ratio = 1) + theme(panel.grid.major = element_blank(), 
      panel.grid.minor = element_blank(), panel.background = element_blank(), 
      axis.line = element_line(colour = "black"))
  }
  plot
}

# check一下有哪些pathway
pathways <- res@assays$METABOLISM$score
head(rownames(pathways))
# [1] "Glycolysis / Gluconeogenesis"            
# [2] "Citrate cycle (TCA cycle)"               
# [3] "Pentose phosphate pathway"               
# [4] "Pentose and glucuronate interconversions"
# [5] "Fructose and mannose metabolism"         
# [6] "Galactose metabolism"

# Dimplot
DimPlot.metabolismV5(obj = res, 
                   pathway = "Glycolysis / Gluconeogenesis", 
                   dimention.reduction.type = "umap",  
                   dimention.reduction.run = F, size = 1)

# DotPlot
input.pathway<-c("Glycolysis / Gluconeogenesis",
                 "Oxidative phosphorylation",
                 "Citrate cycle (TCA cycle)")
DotPlot.metabolism(obj = res,
                  pathway = input.pathway,
                  phenotype = "celltype", #这个参数需按需修改
                  norm = "y")

# BoxPlot
# 由于开发者默认吧obj定义为countexp.Seurat,所以还需要重新命名一下
countexp.Seurat <- res
BoxPlot.metabolism(obj = countexp.Seurat,
                  pathway = input.pathway, 
                  phenotype = "celltype", #这个参数需按需修改
                  ncol = 1)

4.V4可直接用
res <-sc.metabolism.Seurat(obj = sub_scRNA,
                           method = "AUCell", # VISION、AUCell、ssgsea和gsva
                           imputation =F, ncores = 2, 
                           metabolism.type = "KEGG") # KEGG和REACTOME
5.V4可视化
# check一下有哪些pathway
pathways <- res@assays$METABOLISM$score
head(rownames(pathways))
# [1] "Terpenoid backbone biosynthesis"                
# [2] "Caffeine metabolism"                            
# [3] "Neomycin, kanamycin and gentamicin biosynthesis"
# [4] "Metabolism of xenobiotics by cytochrome P450"   
# [5] "Drug metabolism - cytochrome P450"              
# [6] "Drug metabolism - other enzymes" 

# Dimplot绘图
DimPlot.metabolism(obj = res, 
                   pathway = "Glycolysis / Gluconeogenesis", 
                   dimention.reduction.type = "umap",  
                   dimention.reduction.run = F, size = 1)

# DotPlot
input.pathway<-c("Folate biosynthesis",
                 "Nicotinate and nicotinamide metabolism",
                 "Pyrimidine metabolism")
DotPlot.metabolism(obj = res,
                  pathway = input.pathway,
                  phenotype = "celltype", #这个参数需按需修改
                  norm = "y")

#BoxPlot
# 由于开发者默认吧obj定义为countexp.Seurat,所以还需要重新命名一下
countexp.Seurat <- res
BoxPlot.metabolism(obj = countexp.Seurat,
                  pathway = input.pathway, 
                  phenotype = "celltype", #这个参数需按需修改
                  ncol = 1)

参考资料:

1、Spatiotemporal Immune Landscape of Colorectal Cancer Liver Metastasis at Single-Cell Level. Cancer Discov. 2022 Jan;12(1):134-153.

2、scMetabolism: https://github.com/wu-yc/scMetabolism

3、生信菜鸟团:

https://mp.weixin.qq.com/s/nSXm3gDBu9be2vogFnYxbQ;
https://mp.weixin.qq.com/s/CG4cWARe9KegD-gqz0rDzw

:若对内容有疑惑或者有发现明确错误的朋友,请联系后台(欢迎交流)。更多内容可关注公众号:生信方舟

- END -

### 生物信息学单细胞测序数据分析工具及相关方法 #### 单细胞测序数据分析工具 单细胞测序技术的进步使得科学家能够以前所未有的分辨率解析复杂组织中的细胞异质性。对于单细胞转录组数据的分析,常用的工具有 Seurat Scanpy。Seurat 是一种 R 包,提供了强大的功能来处理可视化单细胞 RNA 测序数据[^4]。它支持降维、聚类以及差异表达分析等功能。Scanpy 则是一个基于 Python 的库,同样适用于大规模单细胞数据集的分析,并且可以轻松与其他科学计算生态系统集成。 #### 代谢通路分析工具 针对代谢通路的研究,有多种生物信息学工具可供选择。例如 iMeta 提供了一个综合平台用于微生物群落及其代谢活动的研究,其中包含了 MetOrigin 这样的专门工具用来探索代谢组学数据背后的潜在机制[^1]。此外,KEGG (Kyoto Encyclopedia of Genes and Genomes) 数据库也是广泛使用的资源之一,在这里可以通过查询已知路径来理解新的实验发现如何映射到现有的生化反应网络上。 #### 基因表达与模块识别 WGCNA(Weighted Gene Co-expression Network Analysis)是一种常被应用于基因共表达网络构建的方法,其核心在于识别那些在不同条件下共同变化的一组基因——即所谓的“基因模块”。这种方法不仅有助于揭示基因之间的相互作用关系,还可以进一步挖掘这些模块与特定表型之间可能存在的联系[^2]。 #### 质谱为基础的单细胞蛋白组学 随着技术进步,现在也出现了像 SCoPE2 或 Mad-CASP 等新型 MS-SCP (Mass Spectrometry-based Single Cell Proteomics)工具,它们极大地提升了我们对单个细胞内部蛋白质组成情况的认识水平。这类技术特别适合于深入探究诸如肿瘤异质性干细胞分化过程中涉及的关键调控因子等方面的问题[^3]。 ```python import scanpy as sc adata = sc.read_10x_mtx('./data/') # 加载数据 sc.pp.filter_cells(adata, min_genes=200) sc.pp.normalize_total(adata, target_sum=1e4) sc.pp.log1p(adata) sc.tl.pca(adata, svd_solver='arpack') sc.pl.pca_variance_ratio(adata, log=True) ``` 上述代码片段展示了利用 Scanpy 对单细胞 RNA 序列数据执行预处理操作的一个简单例子,包括过滤低质量单元格、标准化计数矩阵并转换为自然对数值形式等步骤之后再进行主成分分析以减少维度便于后续聚类等工作流程的一部分实现方式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值