thanks, does closest also works with a gtf file?
Hi,
I'm looking for a method/tool for annotating a bam file.
After running the mapping with STAR, I have filtered my bam file for specific reads, I am interested in. I would now like to assign a gene (nearest gene) or any other genomic structure, if possible to each of the reads.
Best case scenario, I would like to get as an output a table of the reads and the annotation as a table.
Is there something like that out there?
thanks
1 answer
You can transform the BAM to BED with bamtobed from bedtools and then use bedtools closest to get the closest match for that newly generated BED file, given that the annotation file you have is in a compatible format, e.g. GTF or BED itself.
Not sure, many bedtools commanfs do, check the manual. Alternatively load things into R and use the intersection/nearest functions from GenomicRanges.
Log in to answer this question.
You can complement @ATPoint's solution by pulling reads out with
samtools view region.