Thanks for your reply. I'm using output from cellranger and find no such fastq file for faidx. The two files that I have is bam and its bam index file. I try to use the above command with bam index file but it does not work. Do you know any other methods?
Extract bed file of uwanted chromosome names and positions from bam file
Hello everyone,
Besides chr1->22, there are others name like chrM, KI270728.1,.... I want to create a bam file of these chromosome names (which is listed in common_chr.bed) by using samtools
samtools view -L common_chr.bed -U out_bam.bam in_bam.bam
I need to create common_chr.bed but not sure how to do this. Is there any way to create such bed file of distinct chromosome names and their positions from in_bam.bam that excludes chr1->22
Thanks for your help.
• 1,320 views
•
link
1 answer
use the reference.fa.fai file create by samtools faidx
awk -F '\t' '($1 ~ /^(chr)?[0-9]+$/) {printf("%s\t0\t%s\n",$1,$2);}' reference.fa.fai > common.bed
• 0 views
•
link
• 0 views
•
link
find the fasta reference file, index it with samtools faidx /path/to/ref.fasta
• 0 views
•
link
Log in to answer this question.