Hello,
I'm trying to plot a multi-tracked figure with ggbio, and I'm consistently having issues with a couple of the tracks scaling correctly. Particularly, the repeats gff3 and the VCF file are not properly limited by xlim, and when all tracks are plotted together the xlim I specified is ignored. However, the coverage and gene tracks scale just fine.
Any suggestions?
Here are the links to the three input files you will need to reproduce the plot:
GFF3 file: https://drive.google.com/open?id=1GIzOmbcNwU29X6LecFPMABzvspBkQ4mA
repeats gff3: https://drive.google.com/open?id=11Is4lq6Qay9T_co5K21H9tV7yvw8GW_v
VCF file: https://drive.google.com/open?id=1pMvmVl1ejG14yJNmf746Q3vABwfRAbZo
Here is the code:
#Load appropriate libraries
library(GenomicFeatures)
library(rtracklayer)
library(ggbio)
library(VariantAnnotation)
library(dplyr) #Make sure to load dplyr after GenomicFeatures and VariantAnnotation to avoid issues with the select function
#Make txdb
txdb <- makeTxDbFromGFF(file="Puccinia_coronata_avenae_12SD80.000036F.gff3",
                        dataSource="gff3 from 12SD80 000036F primary contig",
                        organism="Puccinia coronata")
#Subset to just genes
wh <- subset(genes(txdb))
#Make plot of just gene track in the region of interest on 000036
gene_track <- ggbio::autoplot(txdb, aes(fill = gene_id), which = wh, label = FALSE) + xlim(220000, 360000) + guides(fill=FALSE)
#The repeats have a consistent issue with not showing up with the correct scaling
#Read in repeats with rtracklayer
repeats_gr <- import("Puccinia_coronata_avenae_12SD80.000036F.repeats.gff3")
repeats <- ggbio::autoplot(repeats_gr) + xlim(220000, 360000)
#Plot coverage
cov <- ggbio::autoplot("15MN10-4.000036F.bam", which = wh) + xlim(220000, 360000)
#Plot all variants
#The VCF file also does not properly scale
vcf <- readVcf(file="15MN10-4_000036F.vcf")
vcf_track <- ggbio::autoplot(vcf, geom = "rect") + xlim(220000, 360000)
#The VCF and repeat files and not limited by xlim
tracks(Genes = gene_track, Variants = vcf_track, Coverage = cov)
                    
                
                