Search
Question: Gviz : sort reads in AlignmentsTracks and display reads containing indels
0
13 months ago by
France
Aurélie GABRIEL 0 wrote:

Hello,
I used Gviz to realise alignments plots using BAM files. Here is the code that I used to generate them :

library(Gviz)
library(BSgenome.Hsapiens.UCSC.hg19)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(org.Hs.eg.db)

g=BSgenome.Hsapiens.UCSC.hg19
txdb=TxDb.Hsapiens.UCSC.hg19.knownGene
annotation=org.Hs.eg.db
sTrack <- SequenceTrack(g,cex = 0.6)
chr="chr1"; pos=874816; w=50;

gtrack <- GenomeAxisTrack()
sTrack@chromosome <- chr
ideoTrack <- IdeogramTrack(genome = "hg19", chromosome = chr)
grtrack <- GeneRegionTrack(txdb,chromosome = chr,start = pos-w, end = pos-w,exonAnnotation = "exon",collapseTranscripts = "longest",shape = "arrow",showTitle=FALSE,alpha=0.95)
displayPars(grtrack) <- list(background.title = "white")

alTrack=AlignmentsTrack("BAM_name.bam", isPaired = FALSE,stacking = "squish",alpha=0.95,chromosome=chr,cex.mismatch=0.5,name="Reads",cex.title=1.5)
ht <- HighlightTrack(trackList = c(alTrack,sTrack, grtrack), start = c(pos), width =0,chromosome = chr)
s=c(0.05,0.1,0.72,0.05,0.08)

plotTracks(c(ideoTrack,gtrack,ht),sizes=s,from = pos-w, to = pos+w,add53=TRUE,min.height=4, main=paste0(chr,":",pos),title.width=0.7,littleTicks = TRUE,cex.main=1.5)

The plot resulting from that code :

The alignment at the same position using IGV :

First, I would like to choose the reads that are displayed on the AlignmentsTrack for the given position : is it possible to fix the number of reads displayed  ? By doing this I would like to display as much reads as possible and avoid the blank space between the reads like IGV does.

Besides, is it possible to sort the reads from top to bottom depending on the nucleotide located at the position of the alignment (hilighted here in red) ? This would allow me to display in priority the reads with a specific variant.

Also the position highlighted in the example should be an insertion, but the insertions are not visible and I have the same problem with deletions. Is there a way to display indels using a bam file as argument for the AlignmentTracks function or do I have to use the individual function arguments (like id, cigar ...) ?

Aurélie Gabriel.

modified 12 months ago by florian.hahne@novartis.com1.6k • written 13 months ago by Aurélie GABRIEL 0

I just came across your post and have the same question, did you ever find an answer to this?

Sarah

Aurélie.

0
12 months ago by
Switzerland

You can't really sort reads in these visualisations. Gviz tries to arrange the reads in a way to minimize the vertical space that is needed for display. Also, indels are currently not supported. I am happy to add functionality to the package if somebody else in the developer realm want's to take a first stab at this. I won't have the bandwidth to look at this myself, though.

Florian

Hi,

Aurélie.