Hi Matt,
the XS strand is only added to spliced alignments based on their intron motifs.
It does not take into account the strandedness information.
For stranded RNA-seq, Cufflinks can be run with the --library-type parmameter, while StringTie for some reason lacks this option, and requires XS to be supplied for each alignment. I have a simple script that can add XS flag to all alignments for stranded data:
It works on a SAM file:
$ awk -v strType=2 -f tagXSstrandedData.awk Aligned.out.sam > Aligned.XS.sam
For a BAM file:
samtools view -h Aligned.out.bam | awk -v strType=2 -f tagXSstrandedData.awk | samtools view -bS - > Aligned.XS.bam
strType defines the strandedness of the RNA-seq library prep, and specifies the read (1 or 2) which strand agrees with the RNA strand.
For the Illumina Tru-Seq dUTP protocol strType=2.
If the reads are unpaired, they are assumed to be “read 1”.
I have not tested this code with StringTie - please let me know whether it works for you, and I will add it to the official STAR release.
Cheers
Alex