Keep just chromosomes in a .bam file
0
0
Entering edit mode
4.7 years ago
jaafari.omid ▴ 80

Dears all,

Hello. I have some merged bam files and now I want to keep only the reads related to the chromosomes, not MT and not the unlocated reads. I tried using the following command but still I saw MT and the unlocated ones in my file.

samtools view -b CF-F0-filtered.bam NC_031965.2 NC_031966.2 \
                 NC_031967.2 NC_031969.2 NC_031970.2 NC_031971.2 NC_031972.2 \
                 NC_031973.2 NC_031974.2 NC_031975.2 NC_031976.2 NC_031977.2 \
                 NC_031978.2 NC_031979.2 NC_031980.2 NC_031981.2 NC_031982.2 \
                 NC_031983.2 NC_031984.2 NC_031985.2 NC_031986.2 NC_031987.2 \
                 > CF-F0-ChrOnly.bam

Any help is appreciated in advance.

Regards,
Omid

genome next-gen assembly snp alignment • 1.2k views
ADD COMMENT
1
Entering edit mode

but still I saw MT and the unlocated ones in my file.

what is the output of

samtools view CF-F0-ChrOnly.bam |  |cut -f 3 | uniq | sort | uniq
ADD REPLY
0
Entering edit mode

The out put is just the Chromosomes! Here is the results:

samtools view CF-F0-ChrOnly.bam | cut -f 3 | uniq | sort | uniq

NC_031965.2
NC_031966.2
NC_031967.2
NC_031969.2
NC_031970.2
NC_031971.2
NC_031972.2
NC_031973.2
NC_031974.2
NC_031975.2
NC_031976.2
NC_031977.2
NC_031978.2
NC_031979.2
NC_031980.2
NC_031981.2
NC_031982.2
NC_031983.2
NC_031984.2
NC_031985.2
NC_031986.2
NC_031987.2
ADD REPLY
0
Entering edit mode

so, how can you say:

. I tried using the following command but still I saw MT and the unlocated ones in my file. ?

ADD REPLY
0
Entering edit mode

Yes it is weird to me. I said it based on my mpileup. Actually based on two sorted .bam files I generated the mpileup file and when I took its tail command I saw the MT there. Based on your command I checked the two .bam files and there is just Chromosomes but why in mpileup file I have both MT and the unlocated ones?! Maybe it is because of one option that I used in mpileup command. It is running now and will back soon.

ADD REPLY
0
Entering edit mode

Yes, it was because of the option that I used for mpileup generation.

Thank you very much for your great help.

Best regards,
Omid

ADD REPLY

Login before adding your answer.

Traffic: 1842 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6