将gtf格式转换为bed格式

使用BEDOPS将gtf格式转换为bed格式。

安装

安装BEDOPS可以使用bioconda做的docker镜像:https://quay.io/repository/biocontainers/bedops

1
docker pull quay.io/biocontainers/bedops:2.4.35--h2d50403_1

注意把上面命令中的tag2.4.35--h2d50403_1)替换成最新的版本。

使用

启动docker容器后,使用gtf2bed命令:

1
gtf2bed < foo.gtf

转换后的bed文件将被直接输出在标准输出上。

如果需要将bed转换回gtf,可以使用awk

1
awk '{print $1"\t"$7"\t"$8"\t"($2+1)"\t"$3"\t"$5"\t"$6"\t"$9"\t"(substr($0, index($0,$10)))}' foo_subset.bed > foo_subset.gtf

参考

1. https://github.com/bedops/bedops
2. https://bioconda.github.io/recipes/bedops/README.html
3. https://bedops.readthedocs.io/en/latest/content/reference/file-management/conversion/gtf2bed.html