GPU加速生信分析-宏基因组MAG去污染

Deepurify利用多模态深度语言模型来过滤污染的基因组,从而提高了宏基因组组装基因组(MAGs)的质量,并且可以利用GPU加速。

宏基因组组装的基因组 (MAG) 为使用宏基因组测序数据探索微生物暗物质提供了有价值的见解。然而,人们越来越担心 MAG 中的污染可能会严重影响下游分析的结果。目前的 MAG 纯化工具主要依赖于标记基因,并没有充分利用基因组序列的上下文信息。为了克服这一限制,作者引入了用于 MAG 净化的 Deepurify。Deepurify 使用多模态深度语言模型和对比学习来匹配微生物基因组序列与其分类谱系。它将 MAG 中的重叠群分配给 MAG 分隔的树,并应用树遍历算法将 MAG 划分为子 MAG,目的是最大限度地提高高质量和中等质量子 MAG 的数量。在这里,我们表明 Deepurify 在模拟数据、CAMI 数据集和具有不同复杂性的真实数据集上优于 MDMclearer 和 MAGpurify。Deepurify 在土壤中增加了 20.0%的高质量 MAG,在海洋中增加了 45.1%,在植物中增加了 45.5%,在淡水中增加了 33.8%,在人类粪便宏基因组测序数据集中增加了 28.5%。

安装:

1. 第一步(为 Deepurify 创建 Conda 环境)

使用以下命令创建 deepurify 的 conda 环境:

conda env create -n deepurify -f deepurify-conda-env.yml

所有的依赖都可以通过conda使用安装部分中的命令安装

如果您想使用 GPU,请从 http://pytorch.org/ 下载 PyTorch v2.1.0 -cu121(或更高版本)(强烈建议使用 GPU)。

conda activate deepurify
conda install pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia
2. 第二步(安装 Deepurify 代码)

准备好环境后,Deepurify 的代码就可以简单地通过 pip 安装了。

conda activate deepurify
pip install Deepurify==2.3.10

此安装将运行大约 10 分钟。

下载模型权重等文件进行运行

从此**链接下载用于运行 Deepurify 的模型权重和其他文件 (Deepurify-DB.zip**)。

1. 设置环境变量
  • 解压缩下载的文件 (Deepurify-DB.zip) 并设置一个名为 “DeepurifyInfoFiles” 的环境变量,方法是将以下行添加到 .bashrc 文件的最后一行(文件路径:~/.bashrc):

export DeepurifyInfoFiles=/path/of/this/Deepurify-DB/

例如:'export DeepurifyInfoFiles=/home/csbhzou/software/Deepurify-DB/'。

  • 保存 .bashrc 文件,然后执行:

source .bashrc
2. 在 CLI 中使用 '--db_folder_path' 标志
  • 如果您不想设置环境变量,您可以在 CLI 中将 '--db_folder_path' 标志设置为'Deepurify-DB' 文件夹的路径。

使用“清理”模式运行 Deepurify

1. 您可以通过以下命令以 'clean' 模式运行 Deepurify:

清洁模式

清洁模式

deepurify clean  -i ./input_folder/ -o ./output_folder/ --bin_suffix fasta --gpu_num 1 --each_gpu_threads 1 --db_folder_path /path/of/this/Deepurify-DB/

usage: deepurify clean [-h] -i INPUT_PATH -o OUTPUT_PATH --bin_suffix BIN_SUFFIX [--gpu_num GPU_NUM] [--batch_size_per_gpu BATCH_SIZE_PER_GPU] [--each_gpu_threads EACH_GPU_THREADS]
                       [--overlapping_ratio OVERLAPPING_RATIO] [--cut_seq_length CUT_SEQ_LENGTH] [--mag_length_threshold MAG_LENGTH_THRESHOLD] [--num_process NUM_PROCESS]
                       [--topk_or_greedy_search {topk,greedy}] [--topK_num TOPK_NUM] [--temp_output_folder TEMP_OUTPUT_FOLDER] [--db_folder_path DB_FOLDER_PATH]
                       [--model_weight_path MODEL_WEIGHT_PATH] [--taxo_vocab_path TAXO_VOCAB_PATH] [--taxo_tree_path TAXO_TREE_PATH]

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT_PATH, --input_path INPUT_PATH
                        The folder of input MAGs.
  -o OUTPUT_PATH, --output_path OUTPUT_PATH
                        The folder used to output cleaned MAGs.
  --bin_suffix BIN_SUFFIX
                        The bin suffix of MAG files.
  --gpu_num GPU_NUM     The number of GPUs to be used can be specified. Defaults to 1. If you set it to 0, the code will utilize the CPU. However, please note that using the CPU can
                        result in significantly slower processing speed. It is recommended to provide at least one GPU (>= GTX-1060-6GB) for accelerating the speed.
  --batch_size_per_gpu BATCH_SIZE_PER_GPU
                        The batch size per GPU determines the number of sequences that will be loaded onto each GPU. This parameter is only applicable if the --gpu_num option is set to a
                        value greater than 0. The default value is 4, meaning that one sequence will be loaded per GPU batch. The batch size for the CPU is 4.
  --each_gpu_threads EACH_GPU_THREADS
                        The number of threads per GPU (or CPU) determines the parallelism level during the contigs' inference stage. If the value of --gpu_num is greater than 0, each GPU will
                        have a set number of threads to do inference. Similarly, if --gpu_num is set to 0 and the code will run on the CPU, the specified number of threads will be used. By
                        default, the number of threads per GPU or CPU is set to 1. The --batch_size_per_gpu value will be divided by the number of threads to determine the batch size per
                        thread.
  --overlapping_ratio OVERLAPPING_RATIO
                        The --overlapping_ratio is a parameter used when the length of a contig exceeds the specified --cut_seq_length. By default, the overlapping ratio is set to 0.5.
                        This means that when a contig is longer than the --cut_seq_length, it will be split into overlapping subsequences with 0.5 overlaps between consecutive
                        subsequences.
  --cut_seq_length CUT_SEQ_LENGTH
                        The --cut_seq_length parameter determines the length at which a contig will be cut if its length exceeds this value. The default setting is 8192, which is also the
                        maximum length allowed during training. If a contig's length surpasses this threshold, it will be divided into smaller subsequences with lengths equal to or less
                        than the cut_seq_length.
  --mag_length_threshold MAG_LENGTH_THRESHOLD
                        The threshold for the total length of a MAG's contigs is used to filter generated MAGs after applying single-copy genes (SCGs). The default threshold is set to
                        200,000, which represents the total length of the contigs in base pairs (bp). MAGs with a total contig length equal to or greater than this threshold will be
                        considered for further analysis or inclusion, while MAGs with a total contig length below the threshold may be filtered out.
  --num_process NUM_PROCESS
                        The maximum number of threads will be used. All CPUs will be used if it is None. Defaults to None
  --topk_or_greedy_search {topk,greedy}
                        Topk searching or greedy searching to label a contig. Defaults to "topk".
  --topK_num TOPK_NUM   During the top-k searching approach, the default behavior is to search for the top-k nodes that exhibit the highest cosine similarity with the contig's encoded
                        vector. By default, the value of k is set to 3, meaning that the three most similar nodes in terms of cosine similarity will be considered for labeling the contig.
                        Please note that this parameter does not have any effect when using the greedy search approach (topK_num=1). Defaults to 3.
  --temp_output_folder TEMP_OUTPUT_FOLDER
                        The temporary files generated during the process can be stored in a specified folder path. By default, if no path is provided (i.e., set to None), the temporary
                        files will be stored in the parent folder of the '--input_path' location. However, you have the option to specify a different folder path to store these temporary
                        files if needed.
  --db_folder_path DB_FOLDER_PATH
                        The path of the database folder. Defaults to None. It is expected that the environmental variable 'DeepurifyInfoFiles' has been set
                        to point to the appropriate folder if no path is provided (i.e., set to None). Please ensure the 'DeepurifyInfoFiles' environmental variable is correctly configured if the path is not explicitly
                        provided.
  --model_weight_path MODEL_WEIGHT_PATH
                        The path of model weight. (In database folder) Defaults to None.
  --taxo_vocab_path TAXO_VOCAB_PATH
                        The path of taxon vocabulary. (In database folder) Defaults to None.
  --taxo_tree_path TAXO_TREE_PATH
                        The path of taxonomic tree. (In database folder) Defaults to None.

2. You can run Deepurify with 'clean' mode through the cleanMAGs function in Python.

from Deepurify.clean_func import cleanMAGs

if __name__ == "__main__":
    input_folder = "./input_folder/"
    bin_suffix = "fasta"
    output_folder = "./output_folder/"
    cleanMAGs(
        output_bin_folder_path=output_folder,
        batch_size_per_gpu=4,
        each_gpu_threads=1,
        input_bins_folder=input_folder,
        bin_suffix=bin_suffix,
        gpu_work_ratio=[0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125], # enable 8 GPUs with equal work ratios.
        db_files_path="./Deepurify-DB/"
    )

用 'iter-clean' 模式运行 Deepurify

1. 可以通过以下命令以 'iter-clean' 模式运行 Deepurify:

re-bin mode

re-bin mode

deepurify iter-clean  -c ./contigs.fasta -o ./output_folder/ -s ./sorted.bam --gpu_num 1 --each_gpu_threads 1 --db_folder_path /path/of/this/Deepurify-DB/

usage: deepurify iter-clean [-h] -c CONTIGS PATH -s SORTED_BAM_PATH -o OUTPUT_PATH [--binning_mode BINNING_MODE] [--gpu_num GPU_NUM] [--batch_size_per_gpu BATCH_SIZE_PER_GPU]
                        [--each_gpu_threads EACH_GPU_THREADS] [--overlapping_ratio OVERLAPPING_RATIO] [--cut_seq_length CUT_SEQ_LENGTH] [--mag_length_threshold MAG_LENGTH_THRESHOLD]
                        [--num_process NUM_PROCESS] [--topk_or_greedy_search {topk,greedy}] [--topK_num TOPK_NUM] [--temp_output_folder TEMP_OUTPUT_FOLDER]
                        [--db_folder_path DB_FOLDER_PATH] [--model_weight_path MODEL_WEIGHT_PATH] [--taxo_vocab_path TAXO_VOCAB_PATH] [--taxo_tree_path TAXO_TREE_PATH]

optional arguments:
  -h, --help            show this help message and exit
  -c CONTIGS PATH, --contigs_path CONTIGS PATH
                        The contigs fasta path.
  -s SORTED_BAM_PATH, --sorted_bam_path SORTED_BAM_PATH
                        The sorted bam path.
  -o OUTPUT_PATH, --output_path OUTPUT_PATH
                        The folder used to output cleaned MAGs.
  --binning_mode BINNING_MODE
                        If this parameter is None, then the semibin2, concoct, and metabat2 will all run. Defaults to None. The other modes are: 'semibin2', 'concoct', and 'metabat2'.
  --gpu_num GPU_NUM     The number of GPUs to be used can be specified. Defaults to 1. If you set it to 0, the code will utilize the CPU. However, please note that using the CPU can
                        result in significantly slower processing speed. It is recommended to provide at least one GPU (>= GTX-1060-6GB) for accelerating the speed.
  --batch_size_per_gpu BATCH_SIZE_PER_GPU
                        The batch size per GPU determines the number of sequences that will be loaded onto each GPU. This parameter is only applicable if the --gpu_num option is set to a
                        value greater than 0. The default value is 4, meaning that one sequence will be loaded per GPU batch. The batch size for the CPU is 4.
  --each_gpu_threads EACH_GPU_THREADS
                        The number of threads per GPU (or CPU) determines the parallelism level during the contigs' inference stage. If the value of --gpu_num is greater than 0, each GPU will
                        have a set number of threads to do inference. Similarly, if --gpu_num is set to 0 and the code will run on the CPU, the specified number of threads will be used. By
                        default, the number of threads per GPU or CPU is set to 1. The --batch_size_per_gpu value will be divided by the number of threads to determine the batch size per
                        thread.
  --overlapping_ratio OVERLAPPING_RATIO
                        The --overlapping_ratio is a parameter used when the length of a contig exceeds the specified --cut_seq_length. By default, the overlapping ratio is set to 0.5.
                        This means that when a contig is longer than the --cut_seq_length, it will be split into overlapping subsequences with 0.5 overlaps between consecutive
                        subsequences.
  --cut_seq_length CUT_SEQ_LENGTH
                        The --cut_seq_length parameter determines the length at which a contig will be cut if its length exceeds this value. The default setting is 8192, which is also the
                        maximum length allowed during training. If a contig's length surpasses this threshold, it will be divided into smaller subsequences with lengths equal to or less
                        than the cut_seq_length.
  --mag_length_threshold MAG_LENGTH_THRESHOLD
                        The threshold for the total length of a MAG's contigs is used to filter generated MAGs after applying single-copy genes (SCGs). The default threshold is set to
                        200,000, which represents the total length of the contigs in base pairs (bp). MAGs with a total contig length equal to or greater than this threshold will be
                        considered for further analysis or inclusion, while MAGs with a total contig length below the threshold may be filtered out.
  --num_process NUM_PROCESS
                        The maximum number of threads will be used. All CPUs will be used if it is None. Defaults to None
  --topk_or_greedy_search {topk,greedy}
                        Topk searching or greedy searching to label a contig. Defaults to "topk".
  --topK_num TOPK_NUM   During the top-k searching approach, the default behavior is to search for the top-k nodes that exhibit the highest cosine similarity with the contig's encoded
                        vector. By default, the value of k is set to 3, meaning that the three most similar nodes in terms of cosine similarity will be considered for labeling the contig.
                        Please note that this parameter does not have any effect when using the greedy search approach (topK_num=1). Defaults to 3.
  --temp_output_folder TEMP_OUTPUT_FOLDER
                        The temporary files generated during the process can be stored in a specified folder path. By default, if no path is provided (i.e., set to None), the temporary
                        files will be stored in the parent folder of the '--input_path' location. However, you have the option to specify a different folder path to store these temporary
                        files if needed.
  --db_folder_path DB_FOLDER_PATH
                        The path of the database folder. Defaults to None. It is expected that the environmental variable 'DeepurifyInfoFiles' has been set
                        to point to the appropriate folder if no path is provided (i.e., set to None). Please ensure the 'DeepurifyInfoFiles' environmental variable is correctly configured if the path is not explicitly
                        provided.
  --model_weight_path MODEL_WEIGHT_PATH
                        The path of model weight. (In database folder) Defaults to None.
  --taxo_vocab_path TAXO_VOCAB_PATH
                        The path of taxon vocabulary. (In database folder) Defaults to None.
  --taxo_tree_path TAXO_TREE_PATH
                        The path of taxonomic tree. (In database folder) Defaults to None.

2. 可以通过 Python 中的 cleanMAGs 函数以 'iter-clean' 模式运行 Deepurify

from Deepurify.clean_func import cleanMAGs

if __name__ == "__main__":
    contig_fasta_path = "./contigs.fasta"
    bam_file_path = "./sorted.bam"
    output_folder = "./output_folder/"
    cleanMAGs(
        output_bin_folder_path=output_folder,
        batch_size_per_gpu=4,
        each_gpu_threads=1,
        contig_fasta_path=contig_fasta_path,
        sorted_bam_file=bam_file_path,
        gpu_work_ratio=[0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.25], # enable 7 GPUs with different work ratios.
        db_files_path="./Deepurify-DB/"
    )

有关更多详细信息,请参阅此函数的文档。

输出目录中的文件

  • 纯化的 MAG。
  • MetaInfo.tsv 文件包含以下列:
  1. MAG 名称(第一列)

  2. MAG 的完整性(第二列)

  3. MAG 污染(第三柱)

  4. MAG 质量(第四列)

运行 Deepurify 的最低系统要求

  • 系统: Linux

  • CPU:无限制。

  • 内存:>= 32 GB

  • GPU:GPU 内存必须等于或大于 6GB。(5273MB)

该系统可以运行 “Running Deepurify” 部分中的 deepurify 命令。

参考文献

  1. DOI:10.1038/s42256-024-00908-5

  2. https://github.com/ericcombiolab/Deepurify

  3. https://www.comp.hkbu.edu.hk/~ericluzhang/recipes/southern-cornbread/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/984656.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

AI与SEO关键词智能解析

内容概要 人工智能技术正重塑搜索引擎优化的底层逻辑,其核心突破体现在关键词解析维度的结构性升级。通过机器学习算法对海量搜索数据的动态学习,AI不仅能够识别传统TF-IDF模型中的高频词汇,更能捕捉语义网络中隐含的关联特征。下表展示了传…

【已解决】最新 Android Studio(2024.3.1版本)下载安装配置 图文超详细教程 手把手教你 小白

前言 设置 Android 开发环境,主要包括: 下载Java Development Kit(JDK)安装 Android Studio(集成开发环境) 下载Android SDK 一、JDK Android Studio 自带了 OpenJDK,通常无需额外安装。 如…

LLM中的transformer结构学习(二 完结 Multi-Head Attention、Encoder、Decoder)

文章目录 LLM中的transformer结构学习(二 完结 Multi-Head Attention、Encoder、Decoder)Self-Attention (自注意力机制)结构多头注意力 EncoderAdd & Norm 层Feed Forward 层 EncoderDecoder的第一个Multi-Head AttentionMas…

TDengine 接入帆软 BI 工具

1. 简介 帆软 BI 和 TDengine 在数据分析和可视化领域有紧密的合作关系,帆软是中国专业的大数据 BI 和分析平台提供商,其核心产品包括 FineReport 和 FineBI 等。帆软的 BI 工具广泛应用于各类企业,帮助用户实现数据的可视化分析、报表生成和…

【Java开发指南 | 第三十四篇】IDEA没有Java Enterprise——解决方法

读者可订阅专栏:Java开发指南 |【CSDN秋说】 文章目录 1、新建Java项目2、单击项目名,并连续按两次shift键3、在搜索栏搜索"添加框架支持"4、勾选Web应用程序5、最终界面6、添加Tomcat 1、新建Java项目 2、单击项目名,并连续按两次…

NET400系列协议网关技术方案

NET400系列协议网关技术方案 1. 问题背景 工业现场普遍存在多品牌设备异构通信难题: 协议碎片化:西门子(Profinet/S7-TCP)、罗克韦尔(EtherNet/IP)、三菱(MC Protocol)等设备协议…

如何用Kimi生成PPT?秒出PPT更高效!

做PPT是不是总是让你头疼?😩 快速制作出专业的PPT,今天我们要推荐两款超级好用的AI工具——Kimi 和 秒出PPT!我们来看看哪一款更适合你吧!🚀 🥇 Kimi:让PPT制作更轻松 Kimi的生成效…

深入理解Java中的static关键字及其内存原理

static是Java中实现类级共享资源的核心修饰符,它突破了对象实例化的限制,使得变量和方法能够直接与类本身绑定。这种特性让static成为构建工具类、全局配置等场景的利器,但同时也带来独特的内存管理机制需要开发者关注。 static修饰成员变量…

Zemax 中的 CAD 文件性能比较

这些文件格式 STEP、IGS、SAT 和 STL 通常用于 3D 建模、CAD 和工程应用程序。STEP、IGS、SAT 和 STL 之间的主要区别在于它们如何在 CAD、工程和 3D 打印应用程序中存储和表示 3D 几何图形。 Zemax OpticStudio、STEP、IGES、SAT 和 STL 文件的性能可能会因文件类型和用例&am…

springboot 修复 Spring Framework 特定条件下目录遍历漏洞(CVE-2024-38816)

一定要看到最后! 一定要看到最后! 一定要看到最后! 一、漏洞描述 Spring框架是 Java 平台的一个开源的全栈应用程序框架和控制反转容器实现。2024年9月,Spring官方发布公告披露 CVE-2024-38816 Spring Framework 特定条件下目…

electron builder打包时,出现errorOut=ERROR: Cannot create symbolic link

解决办法: 以管理员身份运行PowerShell,然后进入到该目录下重新执行该指令。然后就会看到打包成功。 只要首次在PowerShell中链接创建完成,后续在VSCode或者CMD这些运行指令,都不会报错了

Tomcat下载安装及日志乱码问题解决

目录 tomcat下载安装 打开官网,选择想安装的版本 根据自己的电脑配置进行选择 tomcat安装 tomcat启动 启动窗口中文乱码问题 将tomcat日志配置改为GBK编码 修改系统区域设置 tomcat下载安装 访问tomcat官网:Apache Tomcat - Welcome! 打开官网&…

【贪心算法】简介

1.贪心算法 贪心策略:解决问题的策略,局部最优----》全局最优 (1)把解决问题的过程分成若干步 (2)解决每一步的时候,都选择当前看起来的“最优”的算法 (3)“希望”得…

J6打卡——pytorch实现ResNeXt-50实现猴痘检测

🍨 本文为🔗365天深度学习训练营中的学习记录博客 🍖 原作者:K同学啊 1.检查GPU import torch import torch.nn as nn import torchvision.transforms as transforms import torchvision from torchvision import transforms, d…

javaEE初阶————多线程进阶(2)

今天来继续带大家学习多线程进阶部分啦,今天是最后一期啦,下期带大家做一些多线程的题,我们就可以开始下一个环节啦; 1,JUC(java.util.concurrent)的常见类 1)Callable 接口 我们之…

初次体验Tauri和Sycamore(3)通道实现

​ 原创作者:庄晓立(LIIGO) 原创时间:2025年03月10日(发布时间) 原创链接:https://blog.csdn.net/liigo/article/details/146159327 版权所有,转载请注明出处。 20250310 LIIGO备注&…

【2025力扣打卡系列】0-1背包 完全背包

坚持按题型打卡&刷&梳理力扣算法题系列,语言为python3,Day5 0-1背包【目标和】 有n个物品,第i个物品的体积为w[i], 价值为v[i]。每个物品至多选一个,求体积和不超过capacity时的最大价值和常见变形 至多装capacity&#x…

windows下使用msys2编译ffmpeg

三种方法: 1、在msys2中使用gcc编译 2、在msys2中使用visual studio编译(有环境变量) 3、在msys2中使用visual studio编译(无环境变量) 我的环境: 1、msys2-x86_64-20250221 2、vs2015 3、ffmpeg-7.1…

引领变革!北京爱悦诗科技有限公司荣获“GAS消费电子科创奖-产品创新奖”!

在2025年“GAS消费电子科创奖”评选中,北京爱悦诗科技有限公司提交的“aigo爱国者GS06”,在技术创新性、设计创新性、工艺创新性、智能化创新性及原创性五大维度均获得评委的高度认可,荣获“产品创新奖”。 这一奖项不仅是对爱悦诗在消费电子…

cesium地图设置3d,2d,2.5d动态切换

通过修改cesium实例vw的scene的显示模式,来切换最终的显示模式。 Cesium.SceneMode总共有四个变量值,分别如下:NameTypeDescriptionMORPHINGnumber在3d与2d之间切换变体 between mode, e.g., 3D to 2D.COLUMBUS_VIEWnumber2.5d模式&#xff0…