Hi, I have a coordinate-sorted bam file, and its read group information in the header is:
@RG ID:0 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:1:none
@RG ID:1 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:2:none
@RG ID:2 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:3:none
@RG ID:3 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:4:none
@RG ID:4 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:5:none
@RG ID:5 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:6:none
@RG ID:6 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:7:none
@RG ID:7 PL:ILLUMINA SM:COLO829_Normal_Tgen PU:H0CGCADXX:8:none
I want to extract only the reads with ID:0, and I tried commands:
samtools view -b bam -r '@RG\tID:0\tPL:ILLUMINA\tSM:COLO829_Normal_Tgen\tPU:H0CGCADXX:1:none' ~/mixted.bam > rg_0.bam
and
samtools split -f '@RG\tID:0\tPL:ILLUMINA\tSM:COLO829_Normal_Tgen\tPU:H0CGCADXX:1:none' ~/mixted.bam > rg_0.bam
I just got the header information in the output bam file.
Can someone help me with this? Thank you!
Thanks for your reply. It works now with your help!
Fine if I could help you.
If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
fin swimmer