ivanek / Gviz

This is the Gviz development repository. Gviz plots data and annotation information along genomic coordinates.
https://bioconductor.org/packages/Gviz/
Artistic License 2.0
75 stars 10 forks source link

Modify BiomartGeneRegionTrack parameters #53

Closed eggrandio closed 2 years ago

eggrandio commented 3 years ago

Hello,

I am generating some gene tracks programmatically, and I want to modify some of the parameters from a track generated by BiomartGeneRegionTrack. Specifically, I would like to modify the color and the annotation for one Arabidopsis gene, because Biomart returns a long name for the gene symbol, "BETA-OHASE2". I would like to change it to "BOH2" if possible.

ensembl = useMart("plants_mart",host="plants.ensembl.org")
ensembl = useDataset("athaliana_eg_gene",mart=ensembl)
gene_track = BiomartGeneRegionTrack(genome = "TAIR10", chromosome = "chr5",
                                      transcriptAnnotation = "symbol",
                                      shape = "arrow",
                                      filters=list(ensembl_transcript_id="AT5G52570.1"),
                                      name = "Gene", biomart = ensembl,
                                      col.line = NULL, col= NULL, fill = "black", fontcolor.group= "black",
                                      cex.group = 1, fontface.group = 4)

This generates the track with this as symbol:

symbol(gene_track)
[1] "BETA-OHASE 2" "BETA-OHASE 2" "BETA-OHASE 2" "BETA-OHASE 2" "BETA-OHASE 2" "BETA-OHASE 2" "BETA-OHASE 2" "BETA-OHASE 2"
[9] "BETA-OHASE 2"

When I plot this track I get the long annotation:

plotTracks(gene_track,transcriptAnnotation = "symbol")

image When I try to change the "symbol" on gene_track by:

symbol(gene_track) = "BOH2"
symbol(gene_track)
[1] "BOH2" "BOH2" "BOH2" "BOH2" "BOH2" "BOH2" "BOH2" "BOH2" "BOH2"

When I plot it, I still get the old long annotation, even though the "symbol" of gene_track has been successfully changed. It is interesting that the plot only takes the space for "BOH2", but the long name is still plotted: image

I don't know where is this long annotation stored on the BiomartGeneRegionTrack object. Any ideas?

Also, the second issue, although less important is that when I try to change the BiomartGeneRegionTrack colors, sometimes not all of them are changed. I have to resort to collapseTranscripts = "meta" to make them show black: plotTracks(gene_track,utr3="black",utr5="black",protein_coding="black") image

But for another gene, it only works partially:

gene_track2 = BiomartGeneRegionTrack(genome = "TAIR10", chromosome = "chr4",
                                    transcriptAnnotation = "symbol",
                                    shape = "arrow",
                                    filters=list(ensembl_transcript_id="AT4G16780.1"),
                                    name = "Gene", biomart = ensembl,
                                    col.line = NULL, col= NULL, fill = "black", fontcolor.group= "black",
                                    cex.group = 1,
                                    fontface.group = 4)

plotTracks(gene_track2) image plotTracks(gene_track2,utr3="black",utr5="black",protein_coding="black") image

Even when this gene only has utr5 utr3 and protein_coding features:

feature(gene_track2)
[1] "utr5"           "protein_coding" "protein_coding" "protein_coding" "protein_coding" "utr3" 
ivanek commented 3 years ago

Hi @eggrandio,

In the case of BiomartGeneRegionTrack you need to convert it to GeneRegionTrack to use the modified symbols:

gene_track <- as(gene_track, "GeneRegionTrack")
symbol(gene_track) <- "BOH2"
plotTracks(gene_track, transcriptAnnotation = "symbol")

The coloring issue I could not reproduce I got it correctly colored in black.

gene_track2 <- BiomartGeneRegionTrack(genome = "TAIR10", chromosome = "chr4",
                                     transcriptAnnotation = "symbol",
                                     shape = "arrow",
                                     filters=list(ensembl_transcript_id="AT4G16780.1"),
                                     name = "Gene", biomart = ensembl,
                                     col.line = NULL, col= NULL, 
                                     fill = "black", fontcolor.group= "black",
                                     utr3="black",utr5="black",protein_coding="black",
                                     cex.group = 1,
                                     fontface.group = 4)

plotTracks(gene_track2)
eggrandio commented 3 years ago

Thanks for the quick reply! I was able to rename the gene.

I don't know what could be happening with the coloring. I have the same issue with several genes. I will use the collapseTranscripts option for now.

ivanek commented 3 years ago

Interesting, I do not set collapseTranscripts and still get the black filled polygons.

ivanek commented 2 years ago

No feedback, closing.