宏基因组分箱CheckM评估结果的提取

CheckM

CheckM在前文已经提过了,是一款评估宏基因组分箱质量的软件。目前我使用MetaBAT2这款软件已经对我的数据进行了一次分箱,现在利用CheckM进行质量评估。目前阶段,我主要想看Completeness和Contamination两个指标。

CheckM结果存储

我找了一下CheckM的结果存储,发现了这个文件/PATH/TO/checkm_results/storage/bin_stats_ext.tsv,里面存储的信息还是我想要的用的
在这里插入图片描述
可以发现,每一行都是一个bin的信息,由bin的id和信息组成,bin的信息是由一个类似于python里字典的形式存储的。接下来就是要把这个信息提取出来,变成我们常用的txt表格的形式,方便后续的整理。

代码

#!/bin/python3

'''
This program is designed to process CheckM output file (e.g. bin_stats_ext.tsv) to easy-to-read text format (.txt)

Usage: python3 checkm_summary.py <inputfile> <outputfile>

Written by: Emmett Peng
'''
import json
import sys

with open(sys.argv[1] ,'r') as f:
	Load = {}
	for line in f:
		line = line.replace('\'','\"')
		line = line.split('\t')
		line[0] = 'bin_' + line[0].replace('.bin.', '_')
		#print(line[0])
		#line[0]:Bin Id; line[1]:Bin information
		#exec(f"line[0] = json.loads(line[1])")
		Load[line[0]] = json.loads(line[1])
		#print(Load)
		#print(text)

with open(sys.argv[2], 'w+') as output:
	output.write('Bin Id\tMarker Lineage\tGenomes\tMarkers\tMarker Sets\t0\t1\t2\t3\t4\t5+\tCompleteness\tContamination\tGC\tGC std\tGenome Size\tAmbiguous Bases\tScaffolds\tContigs\tTranslation Table\tPredicted Genes\n')
	for key in Load:
		output.write(key + '\t')
		output.write(Load[key]['marker lineage'] + '\t')
		output.write(str(Load[key]['# genomes']) + '\t')
		output.write(str(Load[key]['# markers']) + '\t')
		output.write(str(Load[key]['# marker sets']) + '\t')
		output.write(str(Load[key]['0']) + '\t')
		output.write(str(Load[key]['1']) + '\t')
		output.write(str(Load[key]['2']) + '\t')
		output.write(str(Load[key]['3']) + '\t')
		output.write(str(Load[key]['4']) + '\t')
		output.write(str(Load[key]['5+']) + '\t')
		output.write(str(Load[key]['Completeness']) + '\t')
		output.write(str(Load[key]['Contamination']) + '\t')
		output.write(str(Load[key]['GC']) + '\t')
		output.write(str(Load[key]['GC std']) + '\t')
		output.write(str(Load[key]['Genome size']) + '\t')
		output.write(str(Load[key]['# ambiguous bases']) + '\t')
		output.write(str(Load[key]['# scaffolds']) + '\t')
		output.write(str(Load[key]['# contigs']) + '\t')
		output.write(str(Load[key]['Translation table']) + '\t')
		output.write(str(Load[key]['# predicted genes']) + '\t')
		output.write('\n')

这里主要是利用的json.loads()函数读取后面这一片信息为python里的字典格式,必须注意要将所有单引号都换成双引号,因为json库函数在这里仅识别双引号为字符串信息。

代码存储在我的Github主页。

结果预览

运行结果可以放在Notepad++或Excel里打开查看,就是我们想到的比较易于检查和统计的形式了。
在这里插入图片描述

dRep checkm是dRep软件中的一个命令,用于检查基因组的完整性和质量。在运行dRep checkm命令时,会检查一些依赖软件的安装情况,如mash、nucmer、ANIcalculator、centrifuge、nsimscan和fastANI。如果这些软件没有正确安装或位置不正确,dRep checkm命令会显示错误信息。\[1\] 另外,在dRep中还有其他一些命令可以用于去除基因组目录中的冗余。例如,可以使用dRep dereplicate命令以一定的ANI阈值对基因组进行聚类,并将相似度较高的基因组放入物种级别的次要集群。要去冗余基因组,可以使用以下命令:dRep dereplicate -p {threads} {params.outdir} -g {params.indir}/*.fa -pa 0.90 -sa 0.95 -nc 0.30 -cm larger --genomeInfo {input.checkm} -comp 50 -con 5。其中,pa参数表示主要集群的ANI阈值,sa参数表示次要集群的ANI阈值。\[2\] 此外,还可以使用bwa和samtools等工具对基因组进行比对和排序。例如,可以使用bwa mem命令将基因组比对到参考序列上,并使用samtools进行排序和索引。具体命令如下:bwa index {input.catalog}、bwa mem -t {threads} {input.catalog} {input.fwd} {input.rev} | samtools view -bS - | samtools sort -@ {threads} -o {params.alignedsorted}、samtools index {params.alignedsorted}、samtools flagstat {params.alignedsorted} > {output.flagstat}。\[3\] #### 引用[.reference_title] - *1* [dRep学习笔记](https://blog.csdn.net/dunghill_cock/article/details/124682718)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Nature子刊:宏基因组中挖掘原核基因组的分析流程](https://blog.csdn.net/woodcorpse/article/details/118124686)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

EmmettPeng

你的鼓励将是我创作的最大动力

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

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

打赏作者

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

抵扣说明:

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

余额充值