根据barcode过滤bam文件

10x 单细胞产生的BAM文件可以根据所需的barcode进行过滤。首先,将所需的cell barcode条形码放入 filter.txt中。并在barcode前面加上CB:Z:,以确保专门过滤BAM文件中的该标记,格式如下所示:

其次,将$ BAM_FILE设置为要过滤的BAM文件的位置及名称。例如,如果BAM文件被命名为“ possorted_genome_bam.bam ” ,则使用以下命令。

export BAM_FILE='/your path /possorted_genome_bam.bam'
# Save the header lines
samtools view -@ 16 -H $BAM_FILE > SAM_header

# Filter alignments using filter.txt. Use LC_ALL=C to set C locale instead of UTF-8
samtools view -@ 16 $BAM_FILE | LC_ALL=C grep -F -f filter.txt > filtered_SAM_body

# Combine header and body
cat SAM_header filtered_SAM_body > filtered.sam

# Convert filtered.sam to BAM format
samtools view -@ 16 -b filtered.sam > filtered.bam

欢迎关注~


公众号二维码.jpg

参考:
https://kb.10xgenomics.com/hc/en-us/articles/360022448251-Is-there-way-to-filter-the-BAM-file-produced-by-10x-pipelines-with-a-list-of-barcodes-

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容