This is a test version of Biostars. For the public version, visit https://www.biostars.org.
GVIZ plotTracks plots dense features under each other

I am using gviz from a bioconductor to plot SNPs data using chromosome and genome axis:

My problem is that it plots dense located SNPs under each other and I could not find a parameter to avoid. I also could not find if it is possible to plot the name of the SNPs to the corresponding bar or mark one specific SNP with another color.

gr99 <- GRanges(seqnames = c("chr7","chr7","chr7","chr7","chr7","chr7"),
                IRanges(start=c(128580042,128580052,128575552,128576086,128579202,128579666),
                        end=c(128580042,128580052,128575552,128576086,128579202,128579666)))

atrack2=AnnotationTrack(gr99, name = "SNP")
gen = c()
gen[chr] =genome(atrack2)="hg19"
gtrack <- GenomeAxisTrack()
itrack <- IdeogramTrack(genome = gen, chromosome = "chr7")
plotTracks(list(itrack,gtrack, atrack2),panel.only == TRUE)
snp

Not the best solution. Make two or more tracks and plot them together

a <- seq(1,length(gr99),2)
​plotTracks(list(itrack,gtrack, atrack2[a],atrack2[-a]))

2 answers

AnnotationTrack has a stacking parameter:

atrack = AnnotationTrack(gr99, name = "CREDIBLE SET", id = set$X.SNPID,stacking ="dense")

And here it is:

atrack1=AnnotationTrack(gr99, name = "SNP", id = paste0("rs",c(1:6))) # id == the SNP names
displayPars(atrack1) <- list(fontcolor.group="#80808000",col=NULL,fill="black",showId=T,showFeatureId=T,cex=1.2,fontcolor.item="red")
plotTracks(list(itrack,gtrack, atrack1))

You can play with the displayPars to get your picture of choice

displayPars(atrack1)

Log in to answer this question.