Change the features and colors in BiomartGeneRegionTrack
3
0
Entering edit mode
@tiphaine-martin-6416
Last seen 5.5 years ago
France

Dear Florian,

 

I would like to change the color of some exons in genes from ENSEMBL. In some case, it works well, cf below

gen<- "hg19"

chr <- "chr15"
start <- 75011669
end <- 75019876
interestfeatures <- rbind(c("75017782","75017835","bad"),c("75013755","75013844","good"))
interestcolor <- list("bad"="red", "good"="green")
martENSEMBL=useMart(host='grch37.ensembl.org', biomart='ENSEMBL_MART_ENSEMBL',
                        dataset='hsapiens_gene_ensembl')
biomTrack <- BiomartGeneRegionTrack(genome = genTrunk, biomart=martENSEMBL,
                                        chromosome = chr, start = start,
                                        end = end,  name = "transcript ENSEMBL of interest",
                                        fontcolor="black",groupAnnotation = "group",
                                        just.group = "above",showId=showId,size=2,
                                        col.line = NULL, col = NULL, collapse= FALSE)
  myfeatures <- feature(biomTrack)
  for( f in 1:length(myfeatures)){
    for (i in 1:nrow(as.data.frame(interestfeatures))){
      if (start(biomTrack)[f] == as.numeric(interestfeatures[i,1]) & end(biomTrack)[f] == as.numeric(interestfeatures[i,2])){
        feature(biomTrack)[f] <- as.character(interestfeatures[i,3])
      }
    }
  }
 
  displayPars(biomTrack) <- interestcolor
 
    plotTracks(biomTrack, from=start, to=end)

 

but sometimes, I don't have the good features with the good colors even if the data is correct in the object "biomTrack". Cf example below. Only the coordinate of good genes change.

 

gen<- "hg19"

chr <- "chr15"
start <- 75011669
end <- 75019876
interestfeatures <- rbind(c("75017782","75017835","bad"),c("75011883","75012829","good"))
interestcolor <- list("bad"="red", "good"="green")

martENSEMBL=useMart(host='grch37.ensembl.org', biomart='ENSEMBL_MART_ENSEMBL',
                        dataset='hsapiens_gene_ensembl')

biomTrack <- BiomartGeneRegionTrack(genome = genTrunk, biomart=martENSEMBL,
                                        chromosome = chr, start = start,
                                        end = end,  name = "transcript ENSEMBL of interest",
                                        fontcolor="black",groupAnnotation = "group",
                                        just.group = "above",showId=showId,size=2,
                                        col.line = NULL, col = NULL, collapse= FALSE)
  myfeatures <- feature(biomTrack)
  for( f in 1:length(myfeatures)){
    for (i in 1:nrow(as.data.frame(interestfeatures))){
      if (start(biomTrack)[f] == as.numeric(interestfeatures[i,1]) & end(biomTrack)[f] == as.numeric(interestfeatures[i,2])){
        feature(biomTrack)[f] <- as.character(interestfeatures[i,3])
      }
    }
  }
 
  displayPars(biomTrack) <- interestcolor
 
    plotTracks(biomTrack, from=start, to=end)

Do you know what I need to change to have good colors in the good place ?

Regards

Tiphaine

sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu precise (12.04.5 LTS)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_GB.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_GB.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
 [1] parallel  stats4    grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] XVector_0.8.0        coMET_0.99.10        psych_1.5.4          Gviz_1.12.1          GenomicRanges_1.20.5
 [6] GenomeInfoDb_1.4.1   IRanges_2.2.5        S4Vectors_0.6.1      BiocGenerics_0.14.0  biomaRt_2.24.0      

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.6              biovizBase_1.16.0        lattice_0.20-31          Rsamtools_1.20.4        
 [5] Biostrings_2.36.1        digest_0.6.8             plyr_1.8.3               futile.options_1.0.0    
 [9] acepack_1.3-3.3          RSQLite_1.0.0            ggplot2_1.0.1            zlibbioc_1.14.0         
[13] GenomicFeatures_1.20.1   rpart_4.1-10             hash_2.2.6               ggbio_1.16.0            
[17] proto_0.3-10             splines_3.2.1            BiocParallel_1.2.7       stringr_1.0.0           
[21] foreign_0.8-65           RCurl_1.95-4.7           munsell_0.4.2            rtracklayer_1.28.6      
[25] mnormt_1.5-3             tcltk_3.2.1              nnet_7.3-10              gridExtra_0.9.1         
[29] colortools_0.1.5         Hmisc_3.16-0             matrixStats_0.14.2       gWidgets_0.0-54         
[33] XML_3.98-1.3             reshape_0.8.5            GenomicAlignments_1.4.1  MASS_7.3-42             
[37] bitops_1.0-6             RBGL_1.44.0              GGally_0.5.0             gtable_0.1.2            
[41] DBI_0.3.1                magrittr_1.5             gWidgetstcltk_0.0-55     scales_0.2.5            
[45] graph_1.46.0             stringi_0.5-5            pbapply_1.1-1            trackViewer_1.4.0       
[49] reshape2_1.4.1           latticeExtra_0.6-26      futile.logger_1.4.1      Formula_1.2-1           
[53] lambda.r_1.1.7           RColorBrewer_1.1-2       tools_3.2.1              dichromat_2.0-0         
[57] BSgenome_1.36.2          Biobase_2.28.0           OrganismDbi_1.10.0       survival_2.38-3         
[61] AnnotationDbi_1.30.1     colorspace_1.2-6         cluster_2.0.2            VariantAnnotation_1.14.6
gviz • 1.5k views
ADD COMMENT
0
Entering edit mode
@florianhahnenovartiscom-3784
Last seen 5.5 years ago
Switzerland

Hi Tiphaine,

I'd say that the logic in these nested for loops is buggy. I am assuming you want to do this:

interestcolor <- list("bad"="red", "good"="green")
martENSEMBL=useMart(host='grch37.ensembl.org', biomart='ENSEMBL_MART_ENSEMBL', dataset='hsapiens_gene_ensembl')
biomTrack <- BiomartGeneRegionTrack(genome = genTrunk, biomart=martENSEMBL, chromosome = chr, start = start, end = end,  name = "transcript ENSEMBL of interest", fontcolor="black",groupAnnotation = "group", just.group = "above",showId=showId,size=2, col.line = NULL, col = NULL, collapse= FALSE)

feature(biomTrack)[start(biomTrack) >= 75017782 & end(biomTrack) <= 75017835] <- "bad"

feature(biomTrack)[start(biomTrack) >= 75011883 & end(biomTrack) <= 75012829] <- "good"

displayPars(biomTrack) <- interestcolor
plotTracks(biomTrack, from=start, to=end)
ADD COMMENT
0
Entering edit mode
@tiphaine-martin-6416
Last seen 5.5 years ago
France

Hi Florian,

 

If you prefer to do this way, it looks better and more straightway but I still have the same issue because in theory,  only the first 5'UTR of  two first transcript should be in green and not the first 5'UTR and the 6th exon for 3 other transcripts.

but I want to have only the features with these starts and these end. So more like that

interestcolor <- list("bad"="red", "good"="green")
martENSEMBL=useMart(host='grch37.ensembl.org', biomart='ENSEMBL_MART_ENSEMBL', dataset='hsapiens_gene_ensembl')
biomTrack <- BiomartGeneRegionTrack(genome = genTrunk, biomart=martENSEMBL, chromosome = chr, start = start, end = end,  name = "transcript ENSEMBL of interest", fontcolor="black",groupAnnotation = "group", just.group = "above",showId=showId,size=2, col.line = NULL, col = NULL, collapse= FALSE)

feature(biomTrack)[start(biomTrack) == 75017782 & end(biomTrack) == 75017835] <- "bad"

feature(biomTrack)[start(biomTrack) == 75011883 & end(biomTrack) == 75012829] <- "good"

displayPars(biomTrack) <- interestcolor
plotTracks(biomTrack, from=start, to=end)

 

Moreover for the first transcript, the first exon is composed to 5'UTR and exon coding for protein, but in this case everything have the same color. I can understand that 5'UTR of 2 first transcript change the size (1/2 size in the normal version and basic size with this extra type of feature), but unfortunately, it change the size of 5'UTR of the 3rd and 4th transcript. I suspect that the bug come from  that the end of 5'UTR of these transcripts  are similar than the end of my "good" features.

but if I look at the type of features,  there are mistake related to  their start and end and the color of features are not associated with the type of features

The bold features are the features that expected to change their color.

Hope it helps you to understand my issue.

 

Feature on the original data

feature(biomTrack)
 [1] "utr3"           "utr3"           "utr3"           "utr3"           "protein_coding" "protein_coding"
 [7] "protein_coding" "protein_coding" "protein_coding" "utr3"           "utr3"           "utr3"          
[13] "protein_coding" "protein_coding" "protein_coding" "protein_coding" "protein_coding" "utr3"          
[19] "utr3"           "protein_coding" "protein_coding" "protein_coding" "protein_coding" "protein_coding"
[25] "protein_coding" "utr3"           "utr3"           "protein_coding" "protein_coding" "protein_coding"
[31] "protein_coding" "protein_coding" "protein_coding" "utr3"           "utr3"           "protein_coding"
[37] "protein_coding" "protein_coding" "protein_coding" "protein_coding" "protein_coding" "utr3"          
[43] "utr3"           "protein_coding" "protein_coding" "utr3"           "utr3"           "protein_coding"
[49] "protein_coding" "protein_coding" "protein_coding" "utr5"           "utr5"           "protein_coding"
[55] "protein_coding" "protein_coding" "protein_coding" "utr5"           "utr5"           "utr5"          
[61] "utr5"           "utr5"           "utr5"           "utr5"           "utr5"           "utr5"          
[67] "utr5"           "utr5"           "utr5"           "utr5"           "utr5"        

their start

start(biomTrack)
 [1] 75011883 75011883 75012497 75012771 75012830 75012830 75012830 75012830 75013061 75013061 75013061 75013061
[13] 75013304 75013308 75013308 75013308 75013308 75013308 75013308 75013540 75013540 75013540 75013540 75013540
[25] 75013540 75013540 75013540 75013755 75013755 75013755 75013755 75013755 75013755 75013755 75013755 75013932
[37] 75013932 75013932 75013932 75013932 75013932 75013932 75013932 75014614 75014614 75014614 75014614 75014614
[49] 75014614 75014614 75014614 75014656 75014656 75014676 75014676 75014876 75014876 75015439 75015439 75015439
[61] 75015439 75015439 75015439 75017506 75017782 75017782 75017782 75017782 75017782 75017782 75017782

 

their end

end(biomTrack)
 [1] 75012829 75012829 75012829 75012829 75013115 75013115 75013115 75013115 75013115 75013115 75013115 75013303
[13] 75013394 75013394 75013394 75013394 75013394 75013394 75013394 75013663 75013663 75013663 75013663 75013663
[25] 75013663 75013663 75013663 75013844 75013844 75013844 75013844 75013844 75013844 75013844 75013844 75014058
[37] 75014058 75014058 75014058 75014058 75014058 75014058 75014410 75014655 75014655 75014675 75014675 75015438
[49] 75015438 75015438 75015438 75014875 75014875 75014682 75014682 75015438 75015438 75015464 75015464 75015464
[61] 75015467 75015467 75015467 75017711 75017832 75017832 75017832 75017832 75017835 75017877 75017951

Features after the modification

feature(biomTrack)
 [1] "good"           "good"           "good"           "good"           "protein_coding" "protein_coding"
 [7] "protein_coding" "protein_coding" "protein_coding" "utr3"           "utr3"           "utr3"          
[13] "protein_coding" "protein_coding" "protein_coding" "protein_coding" "protein_coding" "utr3"          
[19] "utr3"           "protein_coding" "protein_coding" "protein_coding" "protein_coding" "protein_coding"
[25] "protein_coding" "utr3"           "utr3"           "protein_coding" "protein_coding" "protein_coding"
[31] "protein_coding" "protein_coding" "protein_coding" "utr3"           "utr3"           "protein_coding"
[37] "protein_coding" "protein_coding" "protein_coding" "protein_coding" "protein_coding" "utr3"          
[43] "utr3"           "protein_coding" "protein_coding" "utr3"           "utr3"           "protein_coding"
[49] "protein_coding" "protein_coding" "protein_coding" "utr5"           "utr5"           "protein_coding"
[55] "protein_coding" "protein_coding" "protein_coding" "utr5"           "utr5"           "utr5"          
[61] "utr5"           "utr5"           "utr5"           "utr5"           "bad"            "bad"           
[67] "bad"            "bad"            "bad"            "utr5"           "utr5"    

 

BW, thank for your advices to change my code in order to avoid the loop,

 

Tiphaine

ADD COMMENT
0
Entering edit mode
@tiphaine-martin-6416
Last seen 5.5 years ago
France

Ok, it works now !

ADD COMMENT
0
Entering edit mode

Hi Tiphaine,

Do you mind sharing how you solved the problem with exons which have an UTR and a protein coding region having the same color?

Sathiya

ADD REPLY

Login before adding your answer.

Traffic: 925 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6