CNVnator进阶工具CNVpytor的CNV检测最佳实践

AI摘要

CNVpytor是基于CNVnator的增强版,提供更强大的CNV检测、可视化和模块化功能。通过Read Depth分析Copy Number Variations(CNVs)和Copy Number Alterations(CNAs)。本文介绍了CNVpytor的conda安装、使用示例,包括shell程序代码、CNV质控、结果合并的Python代码,最终得到经过过滤和合并的CNV分析结果。

cnvpytor 简介

CNV分析里比较常用到的CNVnator,该工具的高精度和高感度受到广泛的欢迎和应用。CNVpytor就是基于该工具开发的,使用Python内核,强化了CNVnator的可视化,模块化,功能和计算能力。根据RD(Read Depth)来检测CNV(copy number variations)和CNA(copy number alterations),是CNVnator的进化版。

cnvpytor github

https://github.com/abyzovlab/CNVpytor

conda安装

conda install cnvpytor -y

使用示例

sh cnvpytor_calling.sh sample001 /public/analysis/result/

Calling CNV Shell程序代码

cnvpytor_calling.sh

#!/usr/bin/bash
# 样本名称
sample=$1
# 输出结果路径
output_dir=$2
# 去除PCR重复的bam文件位于输出结果目录的下方
# 去除PCR重复可使用Samtools工具
rmdup_bam_path=${output_dir}/${sample}.rmdup.bam
# hg19参考基因组路径
hg19_reference=/reference/hg19/hg19.fa
# cnvpytor路径
# which cnvpytor获取
cnvpytor=/public/software/anaconda3/envs/WGS/bin/cnvpytor
# 检测窗口大小1000Kb
detect_bin=1000000

# 检测是否存在bam文件的index
if [ ! -f "$rmdup_bam_path.idx" ];then
  samtools index $rmdup_bam_path
fi

# cnvpytor calling cnv 参考github
$cnvpytor -root ${output_dir}${sample}/${sample}.pytor -rd $rmdup_bam_path

$cnvpytor -root ${output_dir}${sample}/${sample}.pytor -his $detect_bin

$cnvpytor  -root ${output_dir}/${sample}/${sample}.pytor -stat $detect_bin

$cnvpytor -root ${output_dir}${sample}/${sample}.pytor -partition $detect_bin

$cnvpytor -root ${output_dir}${sample}/${sample}.pytor -call $detect_bin > ${output_dir}${sample}/${sample}.pytor.txt

sample.pytor.txt

sample.pytor.txt

对CNV进行质控

cd ${output_dir}$
$cnvpytor -root ${sample}.pytor -view $detect_bin << EOF
print calls
# 质量值过滤
set Q0_range 0 0.5
set size_range $detect_bin inf
print calls
# 显著性过滤
set p_range 0 0.01
# 输出为tsv和vcf文件
set print_filename ${sample}.pytor.filter.tsv
print calls
set print_filename ${sample}.pytor.filter.vcf
print calls
EOF

sample.pytor.filter.tsv

sample.pytor.filter.tsv

对CNV结果进行合并

python cnvpytor_merge.py --o ${output_dir}${sample}/${sample}

合并程序python代码

cnvpytor_merge.py

import pandas as pd
import optparse
import os

# 获取所在染色体带
def get_cytoband(pos_start, pos_end, chrom):
		# cytoBand.txt文件内容参考本人生信技能30
    cytoband_file = "./cytoBand.txt"
    try:
        df = pd.read_csv(cytoband_file, header=None, sep='\t')
        df.columns = ['chr', 'start', 'end', 'cyto', 'gene']
        df_chr = df[df['chr'] == chrom].reset_index()

        list_ctyo_start = []
        list_ctyo_end = []
        for idx, row in df_chr.iterrows():
            cyto_start = int(row['start'])
            cyto_end = int(row['end'])
            if int(pos_start) >= cyto_start:
                list_ctyo_start.append(row['cyto'])
            if int(pos_end) <= cyto_end:
                list_ctyo_end.append(row['cyto'])

            if idx == (len(df_chr) - 1 ):
                if len(list_ctyo_start) == 0:
                    list_ctyo_start.append(row['cyto'])
                if len(list_ctyo_end) == 0:
                    list_ctyo_end.append(row['cyto'])

        res_cyto_start = list_ctyo_start[len(list_ctyo_start) - 1]
        res_cyto_end = list_ctyo_end[0]
        if res_cyto_start == res_cyto_end:
            cyto = res_cyto_start
        else:
            if 'p' in res_cyto_start and 'p' in res_cyto_end:
                cyto = res_cyto_start + res_cyto_end
            elif 'q' in res_cyto_start and 'q' in res_cyto_end:
                cyto = res_cyto_start + res_cyto_end
            else:
                cyto = res_cyto_start + res_cyto_end
    except:
        cyto = ""

    return cyto

def merge_results(input_file, output_file):
    df = pd.read_csv(input_file, sep='\t', header=None, names=["sample", "type", "dup/del", "chrom", "start",
                                                               "end", "size", "p1", "p2", "p3", "p4", "p5", "p6", "p7", "value"])
    df_merge = pd.DataFrame()
    for idx, row in df.iterrows():
        df_merge.at[idx, 'sample'] = row['sample']
        type = "dup" if row['dup/del'] == "duplication" else "del"
        df_merge.at[idx, 'type'] = type
        df_merge.at[idx, 'chrom'] = row['chrom']
        pos_cyto = get_cytoband(pos_start=row['start'], pos_end=row['end'], chrom=row['chrom'])
        df_merge.at[idx, 'cyto'] = pos_cyto
        region = f"{int(row['start'])}-{int(row['end'])}"
        df_merge.at[idx, 'region'] = region
        size = f"{float(row['size'] / 1000000)}M"
        df_merge.at[idx, 'size'] = size
        copy_num = 1 if type == 'dup' else 2
        df_merge.at[idx, 'result'] = f"{type}({row['chrom']})({pos_cyto})({size}) {row['chrom']}:g.{region}{type}"

    df_merge.to_csv(output_file, sep='\t', index=False)

if __name__ == '__main__':
    parse = optparse.OptionParser(usage='"%prog"', version="%prog V1.0")
    parse.add_option("--o", "--output-path", dest="output_path", type=str, help="the output path of file.")
    options, args = parse.parse_args()

    result_merge_path = options.output_path + '.pytor.merge.tsv'
    if os.path.exists(result_path):
        merge_results(result_path, result_merge_path)

最终结果sample.pytor.merge.tsv

sample.pytor.merge.tsv

完整代码

CNVpytor CNV检测

利用singularity 已经发布的cnvnator容器,并调用运行cnvnator软件 为了搜索并调用 CNVnator 容器,我们需要先确定在哪里可以找到 CNVnator 的容器镜像。由于 Singularity Hub 已停止服务,我们可以尝试从其他地方搜索,比如 Docker Hub 或 Singularity Library。在本例中,我们将尝试从 Docker Hub 搜索 CNVnator 容器镜像,并使用 Singularity 拉取并运行它。首先,访问 Docker Hub 并使用搜索功能搜索 CNVnator。您可以在搜索框中输入 “CNVnator” 并查找相关的镜像。 阅读详情

相关推荐

singularity 利用 centos 构建sandbox, 并安装cnvnator(阿里云root)

在CentOS上安装Singularity的具体步骤可能会根据你的系统配置和Singularity版本有所不同,建议参考官方文档进行安装。这些步骤提供了一个大致的指导,具体细节(如依赖库的安装和ROOT的配置)可能需要根据你的具体环境和CNVnator的版本进行调整。完成以上步骤后,CNVnator应该已经在你的Singularity sandbox环境中安装完成。你可以通过执行CNVnator的命令来测试是否安装成功。进入Sandbox环境,安装CNVnator需要的依赖项,包括ROOT和其他工具。

qq_40256654的博客 547

CNVnator:用于通过映射读取从覆盖深度发现CNV和进行基因分型的工具

自述文件 快速入门指南 # Extract read mapping $ ./cnvnator -root file.root -tree file.bam -chrom 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16\ 17 18 19 20 21 22 X Y OR $ ./cnvnator -root file.root -tree file.bam -chrom $(seq 1 22) X Y OR $ ./cnvnator -root file.root -tree file.bam -chrom chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8\ chr9 chr10 chr11 chr12 chr13 chr14 chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22

cnvnator:

cnvnator :)

为什么大语言模型推理要分成 Prefill 和 Decode?深入理解这两个阶段的真正意义

Prefill 阶段是语言模型推理中的第一个步骤,它负责处理你输入的所有上下文内容(prompt),为后续生成打下基础。“请解释一下 Transformer 的原理。这句话会被 tokenizer 编码为一串 token,比如["请", "解释", "一下", "Trans", "##former", "的", "原理", "。"]。然后这些 token 会进入 Transformer 模型进行前向传播。重点来了 👇。

Harry的博客 1万+

深入解析DDR5 SDRAM中的CA训练模式(CATM):原理与实现

本文深入解析DDR5 SDRAM中的CA训练模式(CATM),详细探讨其工作原理与实现方法。通过分析JESD79-5标准,揭示CATM在时序校准、信号质量优化和系统稳定性方面的核心价值,并提供硬件设计考量和系统级调试技巧,帮助工程师解决高速内存系统中的信号完整性问题。

weixin_29235923的博客 391

模电专题-MOS管的放大电路分析

在实际应用中,我们经常会使用到功率MOS,这时通常不会将它当成一个开关使用,而是当成一个放大器来使用,那这就需要让其工作在放大状态。参考下图中的mos管的特性曲线,右图中的输出特性曲线中有一根红色的分界线,这个线就是区分mos管工作状态的分界线,在红线的左边,mos管工作在可变电阻区,也就是线性区;在红线的右边mos管工作在恒流区,也就是饱和区。当然,还有一个截止区。本文分析主要运用模电课本中的理论计算验证。

Anitawen的博客 2万+

告别死记硬背!用实际案例带你玩转UE5编辑器界面(附场景搭建练习)

本文通过实际案例教学,带你轻松掌握Unreal Engine5编辑器界面的核心功能。从创建基础场景到添加光源和可交互对象,逐步讲解内容浏览器、模式面板、世界大纲等模块的协同工作方式,告别死记硬背的学习模式。附场景搭建练习,助你快速上手UE5开发。

weixin_30566063的博客 736

Grafana 可视化配置

Grafana 可视化操作使用

原名又逢乱世。不要放下学习的脚步,毕竟比天天打牌、钓鱼、打游戏更能从内在充实自己。 1947

knowhere | 第一课:项目导论与环境搭建

摘要 本课程是Knowhere项目的第一课,重点介绍项目整体架构和开发环境搭建。Knowhere定位为AI Agent的文档记忆基础设施,通过解析多格式文档并保留结构化信息(如章节层级、表格语义等),为Agent提供可导航的文档知识。项目采用Python monorepo结构,核心包括: apps/api:FastAPI服务,处理HTTP请求和流程调用 apps/worker:Celery服务,执行文档解析等耗时任务 packages/shared-python:共享基础设施层 课程明确了各层职责边界,并推

weixin_43674738的博客 156

基于Simulink的转向控制系统仿真建模示例

本文完成了基于 Simulink 的 EPS 转向控制系统仿真,实现了:✅掌握 EPS 助力控制基本原理✅构建车速敏感的可变助力策略✅在 Simulink 中验证低速轻便、高速沉稳的手感✅达成“安全、舒适、高效”的现代转向系统。

xiaoheshang_123的博客 90

【制作100个Unity游戏之36】用unity从零开始实现类《开心消消乐》的三消类消除解压小游戏

Unity甜品消除游戏开发摘要 本文介绍了使用Unity开发甜品消除游戏的核心实现步骤: 冰块阵列生成 通过GlobalDef定义全局参数(9行7列网格) IceSpawner脚本动态生成网格化冰块阵列 添加Resolution脚本实现多分辨率适配 随机水果生成 创建FruitSpawner作为水果容器 FruitItem脚本管理水果属性(行列索引、类型) 支持动态创建水果精灵并设置位置 关键技术点 使用Instantiate动态生成预制体 通过localPosition精确控制网格布局 分辨率适配算法保持

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1304

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

上一篇: Barcode拆分获取样本Fastq数据最佳实践
下一篇: 生信算法1 - DNA测序算法实践之序列操作
生信与基因组学
博客等级 码龄9年 7214粉丝 257原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

生信与基因组学

每一份鼓励是我坚持下去动力

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

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

打赏作者

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

抵扣说明:

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

余额充值
⌂ 换网址