alexdobin/STAR — pull request #4 by godotgildor (2014-10-27 18:59:13+00:00)
Title: Read Groups in Transcriptome BAM and slight bug fix

I am supplying read groups to my run of STAR and also asking for the transcriptome bam to be generated. In addition, I am asking for unmapped reads to be placed within the output bams. The overall command line looks something like:

/STAR --genomeDir genome --runThreadN 32 --genomeLoad NoSharedMemory --outSAMtype BAM SortedByCoordinate --readFilesIn infile1_1.fq.gz,infile2_1.fq.gz infile1_2.fq.gz,infile2_2.fq.gz --outSAMattrRGline ID:C0FPV.3	PL:illumina	PU:C0FPVACXX120305.3.CATGCTTA	LB:Pond-140785	DT:2012-03-05T00:00:00-0500	SM:BICR	16	CN:BI , ID:C0FPV.4	PL:illumina	PU:C0FPVACXX120305.4.CATGCTTA	LB:Pond-140785	DT:2012-03-05T00:00:00-0500	SM:BICR	16	CN:BI --readFilesCommand zcat --quantMode TranscriptomeSAM --outSAMunmapped Within --outSAMattributes NH HI AS NM MD

What I found was that while the normal genome bam looked pretty much as expected (slight caveat explained a bit later), the transcriptome bam was somewhat malformed. In particular, no read group information was given in the bam header and no read group info was included on mapped reads. Unmapped reads however did have read group information. This mixture of both RG and not RG in the bam caused tools like samtools to complain. I have made a few mods to the code to add the RG info to the bam header in the transcriptome bam and output the RG in mapped reads as well as unmapped reads in the transcriptome bam.

The one other minor bug I found was that when I specified the RG, the RG in the header had the ID placed twice in each read group line. I made a simple patch that fixes this.