I appreciate your help. I've been tinkering with cgat off and on and finally got it working. Thought I'd share some "gotchas":
- This is a little one, but the first command should be
cgat gff2bed --is-gtf. - You have to either use the Ensembl gtf, or you need to modify the gencode gtf to have a field named
gene_biotype.gff2bedwill not let you specify any arbitrary field ID (unless I missed something) - If I remember correctly, the second command (
bam_vs_bed) should also specify the output using-Srather than redirectingstdoutto a file. bam_vs_bedshould also specify--assume-sorted, if you know your.bedand.bamare sorted the same way. I wasted a bunch of time trying to figure out what was "wrong" with either my.bedor.bambecause I didn't realizebam_vs_bedsorts your.bedby default using the standard unix sort method (lexigraphic rather than "natural" or historic karyotypic sorting).- I still haven't figured this one out, but somehow, the "total" number of alignments are fewer than those for "protein_coding" (by an order of magnitude), rather than being the sum.
- I also need to remove secondary alignments from the
.bamsince there doesn't seem to be an option forbam_vs_bedto ignore secondary alignments. Perhaps this issue will resolve #5 as well, if "total" somehow ignores the secondary alignments.
Really appreciate your help!
Not sure about existing software, but couldn't you just transform your GTF file into a BED file and use that with RSeQC?