Yes, it is working.
Thank you for the quick response
Hello All,
I have bams with multiple samples. I couldnot figure out a way to split them to individual sample bams. Below is the RG tags of my BAM.
According to SM tag, it can be seen that the sample IDs are T9C, T9B, T9A. Can samtools view command do this. Tried with samtools view , but was not successful.
@RG ID:1 PL:ILLUMINA PU:D09B5ACXX.8-BG1.G LB:JV21 DS:capture_id:IS0007,seq_library_id:LID46212,seq_run_id:RD2189A DT:2011-11-21T00:00:00-0500 SM:T9C CN:Center
@RG ID:1.1 PL:ILLUMINA PU:D09B5ACXX.8-BG1.F LB:JV20 DS:capture_id:IS0007,seq_library_id:LID46212,seq_run_id:RD2189A DT:2011-11-21T00:00:00-0500 SM:T9B CN:Center
@RG ID:1.1.1 PL:ILLUMINA PU:D0BK3ACXX.6-BG1.G LB:JV21 DS:capture_id:IS0005-0007,seq_library_id:LID46914,seq_run_id:RD2200B DT:2011-12-02T00:00:00-0500 SM:T9C CN:Center
@RG ID:1.1.2 PL:ILLUMINA PU:D0BK3ACXX.6-BG1.F LB:JV20 DS:capture_id:IS0005-0007,seq_library_id:LID46914,seq_run_id:RD2200B DT:2011-12-02T00:00:00-0500 SM:T9B CN:Center
@RG ID:1.1.3 PL:ILLUMINA PU:D0BK3ACXX.6-BG1.E LB:JV19 DS:capture_id:IS0005-0007,seq_library_id:LID46914,seq_run_id:RD2200B DT:2011-12-02T00:00:00-0500 SM:T9A CN:Center
@RG ID:1.2 PL:ILLUMINA PU:D09B5ACXX.8-BG1.E LB:JV19 DS:capture_id:IS0007,seq_library_id:LID46212,seq_run_id:RD2189A DT:2011-11-21T00:00:00-0500 SM:T9A CN:Center
Help appreciated,
Thanks,
Tinu
Samtools view has an option -R that only output reads in read groups listed in a text file. You can provide a text file containing all the read group IDs for a particular sample of interest. Make sure that the RG IDs should be unique between any two different samples.
You can create multiple text files, each containing RG IDs of read groups for a sample. Then you can write a loop that will take each of these files and extract reads using those read ids.
samtools view -bhR readids_for_sample_A.txt File.bam > File_A.bam
Log in to answer this question.
Can you print first two lines (nom-header) from your bam file?
Here are the first two non header lines from the bam