jlchen的个人博客分享 http://blog.sciencenet.cn/u/jlchen

博文

单细胞Hi-C分析工具Higashi——数据的降维与插补

已有 244 次阅读 2024-4-22 18:37 |系统分类:科研笔记

引言

近年来单细胞Hi-C数据成为了三维基因组学的研究热点,单细胞Hi-C数据可以用于研究单个细胞中的染色质结构,从而可以针对特定类型的细胞分别测量其转录调控元件间的空间相互作用。相较于传统Hi-C,scHi-C可以避免组织内细胞异质性影响,获得单个细胞内的空间互作信息,从而减少噪声,提高分辨率与信噪比。同时scHi-C可以在小样本与罕见细胞中应用,拓宽了Hi-C的研究范围,单细胞水平的高通量染色质构象捕获可以从复杂组织中识别细胞类型特异性的染色质环,将有助于全基因组关联研究 (GWAS)在疾病相关的细胞类型中发现变异。虽然可以提供大量细胞特异性的空间结构见解,但由于其实验的复杂性,目前的scHi-C数据有较高的稀疏性及较低的信噪比,给scHi-C数据的后续分析带来了较大挑战。

单细胞中低DNA含量及单细胞数据易丢失的特点使其更难进行稳定的染色质交联与分子连接。因此利用计算手段对scHi-C数据的增强处理有重要研究意义,一方面可以节省湿实验的损耗,另一方面也可以为研究人员提供更多的数据资源。本文希望以一组实验中的数据插补为例,介绍目前单细胞Hi-C数据分析领域常用的插补方法Higashi,这个工具是2021年发表在Nature Biotechnology上的一篇文章:Multiscale and integrative single-cell Hi-C analysis with Higashi(Zhang, R., Zhou, T. & Ma, J. Multiscale and integrative single-cell Hi-C analysis with Higashi.Nat Biotechnol40, 254–261 (2022). doi.org/10.1038/s41587-)。

https://www.nature.com/articles/s41587-021-01034-ywww.nature.com/articles/s41587-021-01034-y

连接到higashi-hic-impute镜像中的higashi内核来完成此notebook,目前提供的GPU机型均可支持测试数据上的模型训练,如果需要用自己的数据进行尝试请根据数据大小适当调节选择的GPU型号

由于Hi-C实验数据较大,镜像中包含了最小的一个测试数据(Ramani et al. 2017),此处给出链接使用者也可自行下载其余数据进行分析: drive.google.com/drive/

以下是数据介绍及示例:

  • cell_id: (int), id for each cell, start from 0. Must be continuous (0, 1, 2, ..., #cell - 1). The order of its appearance does not need to be sorted in the file.

  • chrom1: (str), chromosome name for fragment 1

  • pos1: (int), location for fragment 1

  • chrom2: (str), chromosome name for fragment 2

  • pos2: (int), location for fragment 2. Note that only intra-chromosomal reads are used in Higashi. No need to guarantee that fragment 2 has larger coordinate value than fragment 1.

  • count: (int or float), count number or normalized weight for the interaction.

Higashi是一种基于超图的表示学习算法,可以结合单个细胞间的潜在相关性来增强接触图的整体插补方法。这一方法将Hi-C接触矩阵转换为超图,并将contact信息和bin信息分别作为图的边与节点进行保存,并利用Hyper-SAGNN架构进行预测,被证明可以有效的对稀疏scHi-C矩阵进行插补。Hyper-SAGNN是一种基于self-attention机制的图神经网络,可以有效完成节点分类和超边预测等任务,对大小可变的异质性超边有很好的预测性能,因此较为适合scHi-C数据,可以更好的揭示数据中存在的高阶交互。

数据分析流程依赖安装

镜像中已包含所有依赖,当需要在自己的机器上处理数据时需先进行依赖安装。

  • 最简单的方法是通过conda安装:

install pytorch>=1.8.0 with cuda support when available. conda install -c ruochiz higashi
  • 也可以通过github进行安装:

git clone https://github.com/ma-compbio/Higashicd Higashipython setup.py install模型准备
  • 将google drive中的数据及配置文件存到同一目录下,并修改对应的路径依赖

  • 可以参考Higashi帮助文档给出的信息来了解各个参数的作用。

from higashi.Higashi_wrapper import *config = "/data/nb_data/test_case/config.json"# 根据配置文件构建模型higashi_model = Higashi(config)

数据插补与模型训练
  • 原始数据较大,此处缩减了训练轮数,三个步骤在V100下测试每个epoch训练时长均约1min,使用者可以根据自身需求进行修改训练轮数

  • 此处的neighbor information指的是利用Higashi降维后细胞特征相近的细胞信息来对当前细胞进行数据增强,一组实验中包含了多个细胞的数据

higashi_model.process_data() higashi_model.prep_model()
  • 训练第一步:得到细胞embedding对细胞类型的准确聚类可以为后续分析提供帮助,邻近细胞可以为单细胞Hi-C数据插补提供有效信息

# Step 1 Training for embeddings higashi_model.embedding_epoch = 10 higashi_model.train_for_embeddings()
  • 训练第二步:传统插补方法不借助邻近细胞信息进行插补,有较好的插补效果但通常会保留一些实验中的噪声

# Step 2 Training without neighbor information higashi_model.no_nbr_epoch = 10 higashi_model.train_for_imputation_nbr_0() higashi_model.impute_no_nbr()
  • 训练第三步:借助邻近细胞信息进行插补将相邻细胞的接触矩阵作为额外信息进行插补,可以较好的减小噪声,获得更高质量的数据

# Step 3 Training with neighbor information higashi_model.with_nbr_epoch=10 higashi_model.train_for_imputation_with_nbr() higashi_model.impute_with_nbr()细胞聚类结果可视化
  • Higashi提取所得embedding的一个重要作用是进行细胞聚类,良好的细胞聚类可以助力细胞特异性功能的发现测试数据中共包含了四种类型的细胞,使用UMAP对Higashi得到的细胞embedding进行聚类,有较好的分离效果

# Visualize embedding results cell_embeddings = higashi_model.fetch_cell_embeddings() print (cell_embeddings.shape) from umap import UMAP from sklearn.decomposition import PCA import seaborn as sns import matplotlib.pyplot as plt cell_type = higashi_model.label_info['cell type'] fig = plt.figure(figsize=(14, 5)) ax = plt.subplot(1, 2, 1) vec = PCA(n_components=2).fit_transform(cell_embeddings) sns.scatterplot(x=vec[:, 0], y=vec[:, 1], hue=cell_type, ax=ax, s=6, linewidth=0) handles, labels = ax.get_legend_handles_labels() labels, handles = zip(*sorted(zip(labels, handles), key=lambda t: t[0])) ax.legend(handles=handles, labels=labels, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0., ncol=1) ax = plt.subplot(1, 2, 2) vec = UMAP(n_components=2).fit_transform(cell_embeddings) sns.scatterplot(x=vec[:, 0], y=vec[:, 1], hue=cell_type, ax=ax, s=6, linewidth=0) handles, labels = ax.get_legend_handles_labels() labels, handles = zip(*sorted(zip(labels, handles), key=lambda t: t[0])) ax.legend(handles=handles, labels=labels, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0., ncol=1) plt.tight_layout() plt.show()

结果展示scHi-C数据增强结果可视化
  • Higashi可以利用随机游走方法结合邻近细胞信息对原始的稀疏矩阵进行插补,提高单细胞Hi-C数据质量,但训练轮数过少时,数据增强效果并不明显,一般的当epoch>30时可以看出明显差别

count = 0 fig = plt.figure(figsize=(6, 2*5)) for id_ in np.random.randint(0, 620, 5):  ori, nbr0, nbr5 = higashi_model.fetch_map("chr3", id_)  count += 1  ax = plt.subplot(5, 3, count * 3 - 2)  ax.imshow(ori.toarray(), cmap='Reds', vmin=0.0, vmax=np.quantile(ori.data, 0.6))  ax.set_xticks([], [])  ax.set_yticks([], [])  if count == 1:  ax.set_title("raw")    ax = plt.subplot(5, 3, count * 3 - 1)  ax.imshow(nbr0.toarray(), cmap='Reds', vmin=0.0, vmax=np.quantile(nbr0.data, 0.95))  ax.set_xticks([], [])  ax.set_yticks([], [])  if count == 1:  ax.set_title("higashi, k=0")    ax = plt.subplot(5, 3, count * 3)  ax.imshow(nbr5.toarray(), cmap='Reds', vmin=0.0, vmax=np.quantile(nbr5.data, 0.95))  ax.set_xticks([], [])  ax.set_yticks([], [])  if count == 1:  ax.set_title("higashi, k=5")   plt.tight_layout()

参考文献

Zhang R, Zhou T, Ma J. Multiscale and integrative single-cell Hi-C analysis with Higashi[J]. Nature biotechnology, 2022, 40(2): 254-261.Ramani V, Deng X, Qiu R, et al. Massively multiplex single-cell Hi-C[J]. Nature methods, 2017, 14(3): 263-266.



https://blog.sciencenet.cn/blog-3600244-1430838.html


下一篇:Nature|颠覆认知!无基因突变也能导致癌症发生
收藏 IP: 145.118.249.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-16 15:56

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部