GithubHelp home page GithubHelp logo

ivanek / gviz Goto Github PK

View Code? Open in Web Editor NEW
70.0 2.0 10.0 36.82 MB

This is the Gviz development repository. Gviz plots data and annotation information along genomic coordinates.

Home Page: https://bioconductor.org/packages/Gviz/

License: Artistic License 2.0

R 99.75% TeX 0.25%

gviz's Introduction

Gviz - Plotting data and annotation information along genomic coordinates

Software status

Project Status: Active - The project has reached a stable, usable state and is being actively developed. How long since the package was first in a released Bioconductor version Bioconductor-devel Downloads Support site activity in last 6 months: agged questions/avg. answers per question/avg. comments per question/accepted answers, or 0 if no tagged posts License: Artistic-2.0 GitHub issues

 

Bioc (release) Bioc (devel)
OS Platforms Platforms
Bioc Last Update Bioconductor-release Last Commit Bioconductor-devel Last Commit
Bioc Status Bioconductor-release Build Status Bioconductor-devel Build Status
GitHub Last Commit GitHub last commit (Bioconductor-release) GitHub last commit (Bioconductor-devel)
GitHub Actions R build status R build status
Coverage Codecov.io (Bioconductor-release) Codecov.io (Bioconductor-devel)

Authors

  • Florian Hahne
  • Steffen Durinck
  • Robert Ivanek
  • Arne Mueller
  • Steve Lianoglou
  • Ge Tan
  • Lance Parsons
  • Shraddha Pai

Overview

Gviz UCSC like screenshot

Genomic data analyses requires integrated visualization of known genomic information and new experimental data. Gviz uses the biomaRt and the rtracklayer packages to perform live annotation queries to Ensembl and UCSC and translates this to e.g. gene/transcript structures in viewports of the grid graphics package. This results in genomic information plotted together with your data.

Installation

Release version

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("Gviz", version = "release")

Developmental version

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")
BiocManager::install("Gviz", version = "devel")

Github

if (!requireNamespace("remotes", quietly = TRUE))
    install.packages("remotes")
remotes::install_github("ivanek/Gviz")

Usage

For detailed instructions check the package vignette (release or developmental version). Or check the GitHub.io page.

Citation

  • Hahne F, Ivanek R (2016). "Statistical Genomics: Methods and Protocols." In Mathé E, Davis S (eds.), chapter Visualizing Genomic Data Using Gviz and Bioconductor, 335–351. Springer New York, New York, NY. ISBN 978-1-4939-3578-9, doi: 10.1007/978-1-4939-3578-9_16.

gviz's People

Contributors

aoles avatar dtenenba avatar felixernst avatar grimbough avatar hpages avatar ivanek avatar jwokaty avatar lianos avatar lparsons avatar muellar2 avatar nturaga avatar twmccart avatar vjcitn avatar vobencha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gviz's Issues

Modify BiomartGeneRegionTrack parameters

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" 

display annotations in separate lines

Hi,
Is there way to separate peaks in separate lines? (met H3k27ac annotation track in this example)
Screen Shot 2021-04-01 at 12 53 46 PM

I wish I can separate individual peaks in separate lines so that I can read individual peak's name.

Thanks!

Issue aggregating discontinous genome scores

Hi,
thanks for this versatile package! I'm currently using it to generate DataTracks based on scores.
I believe I'm encountering an issue when trying to plot aggregated scores using a sliding window. The scores in question are discontinuous and range from 0-1 (e.g. methylation scores).
Ranges without score are not represented in my initial object.

It seems that when averaging within a window all positions are used (those without score probably set to 0). As a result a region in which all scores are set to 1 does not return a uniform value of 1, but instead varies based on the density of the positions with score in that region).

Here is an example of a region using different window sizes and all scores set to 1:
GVIZ_example_with_uniform_scores_window_sizes.pdf

The desired behavior for this (for me at least) would be to treat ranges without score as NA and disregard them during aggregation. I tried to supply ranges with 'NA' instead, however this didn't yield any tracks. I am not sure how GVIZ is dealing with NAs, but it seems that the calculation of the mean would not remove NAs (if this is the correct line):

runwin <- suppressWarnings(runmean(Rle(as.numeric(rm)), k=windowSize, endrule="constant"))

It would be great to get advice on how to plot such data properly. Is there are way to do this in the current set up and I'm just not seeing it? Do you have a tip for a work around?

Thank you!

White line overlaps axis in DataTrack

Hi,

Thank you for maintaining this package. I find it very useful.

I notice the following issue when plotting multiple tracks on top of each other. There is a white line that covers the lowest axis label, see attached screenshot:

Screen Shot 2019-12-04 at 1 48 25 PM

Is there a parameter that can be altered to make this transparent? Or eliminate it? Please advise.

If possible, it would also be nice to be able to customize the axis more, like specify the exact values and not have it choose them automatically (so one can just plot the min and max values, for example).

Thanks,

Dave

Alignments track for chimeric reads

Hello,
Is it possible to generate an alignments track showing a pileup and coverage of chimeric reads? In my case, I have aligned to a concatenated viral+hg19 reference fasta to identify viral integration sites. I was hoping to generate a pileup image of split reads spanning a breakpoint, similar to the output of

plotTracks(peakReads, 
              chromosome="chr5", 
              from=135312577, 
              to=135314146, 
              type=c("pileup","coverage")).

From the documentation, it does not seem that multiple chromosome and 'from/to' entries are supported - I am looking to pileup chimeric reads across a human chr and 'viral chr' (equivalent to a structural variant), for instance. Is this possible?

GeneRegionTrack does not show gene structure

Hi, I am trying to draw a gene annotation track with different isoforms using the following code:

axisTrack <- GenomeAxisTrack()
geneTrack <- GeneRegionTrack(
  range = "gencode.v19.annotation.gff3",
  genome = "hg19",
  chromosome = "chr15",
  start = 27e6,
  end = 30e6
)

plotTracks(list(axisTrack, geneTrack),
           genome = "hg19",
           from = 27e6,
           to = 28e6,
           chromosome = "chr15",
           transcriptAnnotation = "symbol")

The reference file is a GFF3 file downloaded from GENCODE website. However, the resulting figure does not show the gene structure (intron/exon). I am wondering what could be wrong and how I can fix it. Thansk

Output

Issue with NAs in first column of metadata when aggregating genomic scores in running windows

Hi,

I encountered an issue that may be related to #18

When using running windows to smooth the data, the presence of NAs in the first column of values seems to somehow influence the calculation of the average. I noticed this because every time I ordered the columns differently, the line also looked different -- even though the data remained the same.

The most extreme example occurs when the first column contains multiple NAs in straight succession: the result is a "flat line" that covers the whole region containing NAs. This is not the case if that same column is in any other position except for the first. It doesn't happen with non-running windows either.

I include here a reproducible example:

df = data.frame(chr="chr1",start=1:100,end=1:100,value1=c(rep(NA,90),rnorm(10)),value2=rnorm(100),value3=rnorm(100))
gr = makeGRangesFromDataFrame(df,keep.extra.columns = T)`
ref_track <- GenomeAxisTrack(add35=TRUE,add53=TRUE,littleTicks=T,cex=1.2)
dTrack <- DataTrack(gr, type=c('a'),missingAsZero=F,windowSize = 10,window=-1, aggregation="mean", na.rm=T)
plotTracks(list(ref_track,dTrack),from=1,to=100)

Here the first column contains 90 NAs followed by 10 random values, which results in a flat line until position 84.
image

But if I reorder the columns in such a way that the NAs are in the second or third columns, the average is calculated normally. Besides, putting the NAs in the second or the third columns does not seem to have an effect (as one would expect):

df2 = df[,c("chr","start","end","value2","value1","value3")]
gr2 = makeGRangesFromDataFrame(df2,keep.extra.columns = T)
dTrack <- DataTrack(gr2, type=c('a'),missingAsZero=F,windowSize = 10,window=-1, aggregation="mean", na.rm=T)
plotTracks(list(ref_track,dTrack),from=1,to=100)

image

df3 = df[,c("chr","start","end","value3","value1","value2")]
gr3 = makeGRangesFromDataFrame(df3,keep.extra.columns = T)
dTrack <- DataTrack(gr3, type=c('a'),missingAsZero=F,windowSize = 10,window=-1, aggregation="mean", na.rm=T)
plotTracks(list(ref_track,dTrack),from=1,to=100)

image

Is there anything I'm doing wrong or is it a malfunction? I don't understand the reason for this behaviour, and I haven't been able to fix it by changing any of the parameters. Setting missingAsZero to True is not a viable option because the missing data are not 0...

UcscTrack() not recognizing some tracks

Hi there,

What a fantastic package! Really intuitive and flexible; exactly what I've been looking for. That said, I don't seem to be able to access the UCSC nuclei tracks through the UcscTrack() function.
Specifically, the hub_400557_human_microglia_H3K27ac_exvivo_pooled_hg19 table within the nuclei_h3k27ac_hg19_pooled track (though I plan to query the other nuclei tracks as well).

Thanks in advance!,
Brian

Input

  # UCSC Tracks  
  conservation <- UcscTrack(genome="hg19",
                            chromosome="chr12", 
                            from = "40590585", to = "40763013", 
                            width=1,
                            trackType="DataTrack",
                            
                            track="nuclei_h3k27ac_hg19_pooled", 
                            name="nuclei_h3k27ac_hg19_pooled",
                            table="hub_400557_human_microglia_H3K27ac_exvivo_pooled_hg19" 
                            ) 

Output

rror in match.arg(track, sort(c(availTracks, names(availTracks)))) : 
  'arg' should be one of "1000G Ph1 Accsbl", "1000G Ph1 Vars", "1000G Ph3 Accsbl", "1000G Ph3 Vars", "5% Lowest S", "acembly", "AceView Genes", "Affy Exon Array", "Affy GNF1H", "Affy RNA Loc", "Affy U133", "Affy U133Plus2", "Affy U95", "affyExonArray", "affyGnf1h", "affyU133", "affyU133Plus2", "affyU95", "All SNPs(138)", "All SNPs(141)", "All SNPs(142)", "All SNPs(144)", "All SNPs(146)", "All SNPs(147)", "All SNPs(150)", "All SNPs(151)", "Allen Brain", "allenBrainAli", "allHg19RS_BW", "Alt Haplotypes", "altLocations", "Assembly", "AUGUSTUS", "augustusGene", "BAC End Pairs", "bacEndPairs", "Broad ChromHMM", "Broad Histone", "BU ORChID", "Burge RNA-seq", "burgeRnaSeqGemMapperAlign", "Caltech RNA-seq", "Cand. Gene Flow", "CCDS", "ccdsGene", "CD34 DnaseI", "CGAP SAGE", "cgapSage", "chainSelf", "Chromosome Band", "Chromosome Band (Ideogram)", "ClinGen CNVs", "clinvar", "ClinVar Variants", "cnvDevDelay", "Common SNPs(138)", "Common SNPs(141)", "Common SNPs(142)", "Common SNPs(144)", 

Version

R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.5
[1] Gviz_1.28.3

Gene size for biomart track

Hi!
I have been trying to increase the font size of the gene symbols in biomartgene track, but I haven't found the function. The default size is small.Please help.

Alignments error

Hello,
I ran Gviz successfully. But today when I ran Alignments function, I got the following error:
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'sort': different row counts implied by arguments
here is the command:
AlignmentsTrack(thisrangs,cigar=thisrange.cigar,isPaired=FALSE,name=hic_name,type="sashimi", lwd.sashimiMax=3)

Scaling of arrowBar

Hi @ivanek,

I really like the Gviz package because of its flexibility. But I stumbled upon a minor problem:

When i am creating high resolution images of my transcript models, the arrow-bar connecting the different exons does not seem to scale at all. So at high resolutions the arrows are nearly invisible.
I found the default values for W, D and min.height in .arrowBar() to be the culprits.

Would it be possible to let the arrows automatically scale with resolution? Or at least to expose the values (W, D and min.height) in the GeneRegionTrack-class so they can easily be adjusted if needed?

Thanks in advance.


Here is how it looks with default values:
bad

Here is how it looks with adjusted values:
better

Use expression/bquote functions with AnnotationTrack group/feature/id

Hi,

I would like to ask for some tricks on the use of expression/bquote functions with group/feature/id elements in the AnnotationTrack. Rather than setting normal names (characters) to these elements, sometimes we way want to plot with some complex strings including superscripts, subscripts, Greek alphabets, etc.
For my case, I intend to set p-values for some peak regions detected. When I tried with simple characters, everything is fine.
AT = AnnotationTrack(range = TF_binding_site, genome = "hg38", id = paste0("p=10^-", mcols(TF_binding_site)$p_value))
plotTracks(AT, ...)
MYBL1 binding sites
But when I tried to make the use of expression/bquote functions like this:
AT = AnnotationTrack(range = TF_binding_site, genome = "hg38", id = as.expression(sapply(mcols(TF_binding_site)$p_value, function(var) bquote(p == 10^-.(var)))))
plotTracks(AT, ...)
I got errors as:
Error in h(simpleError(msg, call)) : error in evaluating the argument 'f' in selecting a method for function 'split': cannot coerce class '"expression"' to a data.frame
Are there any solutions for this?
Thanks a lot in advance!

Mu

Error in .normarg_at2(at, x) for plotTracks()

Hi,

Thanks for this wonderful tool. I am facing an issue when I'm trying to run plotTracks with an alignment track I generated with a long-read (i.e. PromoethION) BAM file. My script looks like following;

options(ucscChromosomeNames=TRUE)
chr <- 'chr1'
from <- 45511035
to <- 45523047

rnatrack <- AlignmentsTrack(
  range = "H838_chr.bam", 
  name= "RNA-Seq",
  chromosome = chr,
  fill = '#34D13F') 

plotTracks(rnatrack, from=from, to=to, chromosome=chr)

The error I'm getting is:

Error in .normarg_at2(at, x) : 
  some ranges in 'at' are off-limits with respect to their corresponding sequence
  in 'x'

I'm wondering whether this has to got to do with the fact that the BAM file is from long reads? I'm adding a subset of my BAM file here as well.
H838_chr_p1subset.bam.gz

traceback() if it helps:

traceback()
21: stop(.wrap_msg("some ranges in 'at' are off-limits with respect to ", 
        "their corresponding sequence in 'x'"))
20: .normarg_at2(at, x)
19: replaceAt(x, at, value = value)
18: replaceAt(x, at, value = value)
17: sequenceLayer(reads$seq, reads$cigar)
16: x@stream(x@reference, subRegion)
15: mcols(data)
14: colnames(mcols(data))
13: eval(quote(list(...)), env)
12: eval(quote(list(...)), env)
11: eval(quote(list(...)), env)
10: standardGeneric("paste")
9: paste(colnames(mcols(data)), "orig", sep = "__.__")
8: .resolveColMapping(x@stream(x@reference, subRegion), x@args, 
       x@mapping)
7: .local(x, ...)
6: subset(x, from = from, to = to, chromosome = chromosome, sort = FALSE, 
       stacks = FALSE, use.defaults = FALSE)
5: subset(x, from = from, to = to, chromosome = chromosome, sort = FALSE, 
       stacks = FALSE, use.defaults = FALSE)
4: FUN(X[[i]], ...)
3: lapply(trackList, function(x) {
       chromosome(x) <- chromosome
       subset(x, from = from, to = to, chromosome = chromosome, 
           sort = FALSE, stacks = FALSE, use.defaults = FALSE)
   })
2: lapply(trackList, function(x) {
       chromosome(x) <- chromosome
       subset(x, from = from, to = to, chromosome = chromosome, 
           sort = FALSE, stacks = FALSE, use.defaults = FALSE)
   })
1: plotTracks(rnatrack, from = from, to = to)

My R session:

session_info()
- Session info ------------------------------------------------------------------------
 setting  value                       
 version  R version 3.6.0 (2019-04-26)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_Australia.1252      
 ctype    English_Australia.1252      
 tz       Australia/Sydney            
 date     2020-01-10                  

- Packages ----------------------------------------------------------------------------
 package                           * version    date       lib
 acepack                             1.4.1      2016-10-29 [2]
 AnnotationDbi                     * 1.46.1     2019-08-20 [1]
 AnnotationFilter                    1.9.0      2019-05-14 [2]
 askpass                             1.1        2019-01-13 [2]
 assertthat                          0.2.1      2019-03-21 [2]
 backports                           1.1.5      2019-10-02 [1]
 base64enc                           0.1-3      2015-07-28 [2]
 bedr                              * 0.0.0.9000 2020-01-10 [1]
 Biobase                           * 2.45.1     2019-09-04 [2]
 BiocFileCache                       1.8.0      2019-05-02 [1]
 BiocGenerics                      * 0.31.6     2019-09-19 [2]
 BiocManager                         1.30.9     2019-10-23 [2]
 BiocParallel                      * 1.19.1     2019-08-06 [2]
 biomaRt                             2.41.8     2019-08-19 [2]
 Biostrings                          2.53.2     2019-07-09 [2]
 biovizBase                          1.33.1     2019-08-23 [2]
 bit                                 1.1-14     2018-05-29 [1]
 bit64                               0.9-7      2017-05-08 [1]
 bitops                              1.0-6      2013-08-17 [2]
 blob                                1.2.0      2019-07-09 [1]
 BSgenome                            1.53.2     2019-09-01 [2]
 callr                               3.3.2      2019-09-22 [1]
 checkmate                           1.9.4      2019-07-04 [2]
 cli                                 1.1.0      2019-03-19 [2]
 cluster                             2.1.0      2019-06-19 [2]
 colorspace                          1.4-1      2019-03-18 [2]
 crayon                              1.3.4      2017-09-16 [2]
 curl                                4.2        2019-09-24 [2]
 data.table                          1.12.6     2019-10-18 [2]
 DBI                                 1.0.0      2018-05-02 [1]
 dbplyr                              1.4.2      2019-06-17 [1]
 DelayedArray                      * 0.10.0     2019-05-02 [1]
 desc                                1.2.0      2018-05-01 [1]
 devtools                          * 2.2.1      2019-09-24 [1]
 dichromat                           2.0-0      2013-01-24 [2]
 digest                              0.6.22     2019-10-21 [1]
 dplyr                               0.8.3      2019-07-04 [2]
 ellipsis                            0.3.0      2019-09-20 [2]
 ensembldb                           2.9.6      2019-09-10 [2]
 evaluate                            0.14       2019-05-28 [2]
 fansi                               0.4.0      2018-10-05 [2]
 foreign                             0.8-72     2019-08-02 [2]
 Formula                             1.2-3      2018-05-03 [2]
 fs                                  1.3.1      2019-05-06 [1]
 GenomeInfoDb                      * 1.21.2     2019-09-27 [2]
 GenomeInfoDbData                    1.2.1      2019-09-23 [2]
 GenomicAlignments                   1.21.7     2019-09-11 [2]
 GenomicFeatures                   * 1.37.4     2019-07-09 [2]
 GenomicRanges                     * 1.37.16    2019-09-13 [2]
 ggplot2                           * 3.2.1      2019-08-10 [2]
 glue                                1.3.1      2019-03-12 [2]
 gridExtra                           2.3        2017-09-09 [2]
 gtable                              0.3.0      2019-03-25 [2]
 Gviz                              * 1.28.3     2019-09-16 [1]
 Hmisc                               4.2-0      2019-01-26 [2]
 hms                                 0.5.1      2019-08-23 [2]
 htmlTable                           1.13.2     2019-09-22 [2]
 htmltools                           0.4.0      2019-10-04 [1]
 htmlwidgets                         1.5.1      2019-10-08 [1]
 httr                                1.4.1      2019-08-05 [1]
 IRanges                           * 2.19.16    2019-09-13 [2]
 jsonlite                            1.6        2018-12-07 [2]
 knitr                               1.25       2019-09-18 [2]
 labeling                            0.3        2014-08-23 [2]
 lattice                             0.20-38    2018-11-04 [2]
 latticeExtra                        0.6-28     2016-02-09 [2]
 lazyeval                            0.2.2      2019-03-15 [2]
 magrittr                            1.5        2014-11-22 [2]
 Matrix                              1.2-17     2019-03-22 [2]
 matrixStats                       * 0.55.0     2019-09-07 [2]
 memoise                             1.1.0      2017-04-21 [1]
 munsell                             0.5.0      2018-06-12 [2]
 nnet                                7.3-12     2016-02-02 [2]
 openssl                             1.4.1      2019-07-18 [2]
 pheatmap                            1.0.12     2019-01-04 [2]
 pillar                              1.4.2      2019-06-29 [2]
 pkgbuild                            1.0.6      2019-10-09 [1]
 pkgconfig                           2.0.3      2019-09-22 [2]
 pkgload                             1.0.2      2018-10-29 [1]
 plyr                                1.8.4      2016-06-08 [2]
 prettyunits                         1.0.2      2015-07-13 [2]
 processx                            3.4.1      2019-07-18 [1]
 progress                            1.2.2      2019-05-16 [2]
 ProtGenerics                        1.17.4     2019-08-20 [2]
 ps                                  1.3.0      2018-12-21 [1]
 purrr                               0.3.3      2019-10-18 [1]
 R6                                  2.4.0      2019-02-14 [2]
 rappdirs                            0.3.1      2016-03-28 [1]
 RColorBrewer                        1.1-2      2014-12-07 [2]
 Rcpp                                1.0.2      2019-07-25 [2]
 RCurl                               1.95-4.12  2019-03-04 [2]
 remotes                             2.1.0      2019-06-24 [1]
 reshape2                            1.4.3      2017-12-11 [2]
 rlang                               0.4.0      2019-06-25 [2]
 rmarkdown                           1.16       2019-10-01 [2]
 rpart                               4.1-15     2019-04-12 [2]
 rprojroot                           1.3-2      2018-01-03 [2]
 Rsamtools                           2.1.6      2019-09-30 [2]
 RSQLite                             2.1.2      2019-07-24 [1]
 rstudioapi                          0.10       2019-03-19 [2]
 rtracklayer                         1.45.6     2019-09-17 [2]
 S4Vectors                         * 0.23.24    2019-09-29 [2]
 scales                              1.0.0      2018-08-09 [2]
 sessioninfo                         1.1.1      2018-11-05 [1]
 SingleCellExperiment              * 1.7.11     2019-09-29 [2]
 stringi                             1.4.3      2019-03-12 [2]
 stringr                             1.4.0      2019-02-10 [2]
 SummarizedExperiment              * 1.15.9     2019-09-11 [2]
 survival                            2.44-1.1   2019-04-01 [2]
 testthat                            2.2.1      2019-07-25 [1]
 tibble                              2.1.3      2019-06-06 [2]
 tidyselect                          0.2.5      2018-10-11 [2]
 TxDb.Hsapiens.UCSC.hg38.knownGene * 3.4.6      2020-01-10 [1]
 usethis                           * 1.5.1      2019-07-04 [1]
 utf8                                1.1.4      2018-05-24 [2]
 VariantAnnotation                   1.31.4     2019-08-17 [2]
 vctrs                               0.2.0      2019-07-05 [2]
 withr                               2.1.2      2018-03-15 [2]
 xfun                                0.10       2019-10-01 [2]
 XML                                 3.98-1.20  2019-06-06 [1]
 XVector                             0.24.0     2019-05-02 [1]
 zeallot                             0.1.0      2018-01-28 [2]
 zlibbioc                            1.30.0     2019-05-02 [1]
 source                        
 CRAN (R 3.6.1)                
 Bioconductor                  
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 Github (davetang/bedr@dad127d)
 Bioconductor                  
 Bioconductor                  
 Bioconductor                  
 CRAN (R 3.6.0)                
 Bioconductor                  
 Bioconductor                  
 Bioconductor                  
 Bioconductor                  
 CRAN (R 3.6.0)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 Bioconductor                  
 Bioconductor                  
 Bioconductor                  
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.0)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 CRAN (R 3.6.1)                
 CRAN (R 3.6.0)                
 CRAN (R 3.6.0)                
 Bioconductor                  
 CRAN (R 3.6.1)                
 Bioconductor                  

[1] C:/Users/amarasinghe.s/Documents/R/win-library/3.6
[2] C:/Program Files/R/R-3.6.0/library

Thanks a lot in advance for your help!
Shani.

Incorrect Labeling of DataTrack

Hi there,

I am new to gviz and love the ease of using this package to plot different types of genomic data together. However, I have recently tried to make a DataTrack and found that the points were mislabeled after plotting and don't match the labeling in the rownames(DataTrack@data).

Here is an example to demonstrate the issue. This is the dTrack@metadata so you can see that there should be points for beta_iPSC_Cluster3 and beta_fibroblast_Cluster3
image

But when I plot them, they are labeled as beta_iPSC_Cluster3 and beta_fibroblast_Cluster5

dTrackPlot

Here is the code that I have used

dTrack <- DataTrack(SPAST_GR, name = "Beta")
plotTracks(dTrack, groups = rownames(dTrack@data),
           type = c("p"), legend=TRUE, ylim=c(0,2), background.title="darkgrey", fontcolor = "black", col=c(iPSC_ClusterColors$color,ClusterColors$color), fontsize=15, cex = 3)

I would appreciate any advice you have on how to fix this.

groups only works in alphabetical order

Hi,

From your example,

data(twoGroups)
dTrack <- DataTrack(twoGroups, name = "uniform")
plotTracks(dTrack, groups=rep(c("control", "treated"), each=3), type=c("a", "p", "confint"))

I realized that no matter how I define the group ordering, it always sort in alphabetical order.

For example, when I replot but with the labels renamed:
plotTracks(dTrack, groups=rep(c("2control","1treated"), each=3), type=c("a", "p", "confint"))

test.pdf

This can be an issue when my data columns are not sorted in alphabetical order.

Thanks,
MJ

Reverse-strand alignment sorted by end position in AlignmentsTrack pileup

Hi Robert, I would like to use Gviz to visualize long-read data alignments. My main issue is a sort/order of reads mapped to the reverse strand. The pileups are by default sorted by start coordinates which makes it difficult to read. Would it be possible to sort the alignments by the end position instead? Maybe only when reverseStrand=T. I believe it would make sense for short-read visualization as well. Another option would be to allow a custom order for the alignments.

Forward strand read alignment looks nice (example here) and I would like the reverse strand read alignment to look the same (right now I have this). The style I would like to have is the top left corner to the bottom right corner diagonal in the forward strand alignments.

BiomartGeneRegionTrack and depreciated dplyr functions

Hello,

I am having a problem when I run BiomartGeneRegionTrack(). When I try to run the command, I have an error that reads,

select_() was deprecated in dplyr 0.7.0.
Please use select() instead.filter_() was deprecated in dplyr 0.7.0.
Please use filter() instead.
See vignette('programming') for more helpError in UseMethod("filter_") :
no applicable method for 'filter_' applied to an object of class "c('tbl_SQLiteConnection', 'tbl_dbi', 'tbl_sql', 'tbl_lazy', 'tbl')"

Is there any way to fix this problem?

Thank you so much!

Gaps displayed as matches

Hello,

I am visualizing BAM alignments (minimap2 -> SAMTools) of some Pacbio genomic reads. It seems that gaps in alignments are showing up as matches in Gviz. See the screenshots from Gviz vs IGV below. I was not able to find any previous reports of this behavior. Any advice would be appreciated. Thanks!

Viewed using Gviz
image

Same BAM fle viewed in IGV
image

Code:

alTrack1 <- AlignmentsTrack("alignments.bam", name="SRR8833180", fill="blue", col="black", col.gap="black", type=c("coverage", "pileup"), lwd.gap=10000)

itrack <- IdeogramTrack(genome = "hg19", chromosome = chr)
bmt <- BiomartGeneRegionTrack(genome="hg19", chromosome=chr, start=afrom, 
                              end=ato, name="Gene Model", 
                              stacking="pack",
                              transcriptAnnotation="symbol", # gene for Ensembl ID
                              collapseTranscripts = "gene",
                              filter = list(with_ox_refseq_mrna = TRUE))
gtrack <- GenomeAxisTrack()

plotTracks(c(itrack, gtrack, alTrack1, bmt), from=afrom, to=ato, chromosome=chr)

Session info

R version 3.6.0 (2019-04-26)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

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

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

other attached packages:
 [1] Gviz_1.28.3                 tibble_2.1.3                kableExtra_1.1.0           
 [4] magrittr_1.5                rtracklayer_1.44.4          VariantAnnotation_1.30.1   
 [7] Rsamtools_2.0.3             Biostrings_2.52.0           XVector_0.24.0             
[10] SummarizedExperiment_1.14.1 DelayedArray_0.10.0         BiocParallel_1.18.1        
[13] matrixStats_0.55.0          Biobase_2.44.0              GenomicRanges_1.36.1       
[16] GenomeInfoDb_1.20.0         IRanges_2.18.3              S4Vectors_0.22.1           
[19] BiocGenerics_0.30.0         ggplot2_3.2.1              

loaded via a namespace (and not attached):
 [1] ProtGenerics_1.16.0      bitops_1.0-6             bit64_0.9-7             
 [4] webshot_0.5.1            RColorBrewer_1.1-2       progress_1.2.2          
 [7] httr_1.4.1               tools_3.6.0              backports_1.1.5         
[10] R6_2.4.1                 rpart_4.1-15             Hmisc_4.3-0             
[13] DBI_1.0.0                lazyeval_0.2.2           colorspace_1.4-1        
[16] nnet_7.3-12              withr_2.1.2              tidyselect_0.2.5        
[19] gridExtra_2.3            prettyunits_1.0.2        curl_4.2                
[22] bit_1.1-14               compiler_3.6.0           rvest_0.3.5             
[25] htmlTable_1.13.2         xml2_1.2.2               labeling_0.3            
[28] checkmate_1.9.4          scales_1.1.0             readr_1.3.1             
[31] stringr_1.4.0            digest_0.6.22            foreign_0.8-71          
[34] rmarkdown_1.17           dichromat_2.0-0          base64enc_0.1-3         
[37] pkgconfig_2.0.3          htmltools_0.4.0          highr_0.8               
[40] ensembldb_2.8.1          BSgenome_1.52.0          htmlwidgets_1.5.1       
[43] rlang_0.4.1              rstudioapi_0.10          RSQLite_2.1.2           
[46] farver_2.0.1             acepack_1.4.1            dplyr_0.8.3             
[49] RCurl_1.95-4.12          GenomeInfoDbData_1.2.1   Formula_1.2-3           
[52] Matrix_1.2-17            Rcpp_1.0.3               munsell_0.5.0           
[55] lifecycle_0.1.0          stringi_1.4.3            zlibbioc_1.30.0         
[58] blob_1.2.0               crayon_1.3.4             lattice_0.20-38         
[61] cowplot_1.0.0            splines_3.6.0            GenomicFeatures_1.36.4  
[64] hms_0.5.2                zeallot_0.1.0            knitr_1.23              
[67] pillar_1.4.2             biomaRt_2.40.5           XML_3.98-1.20           
[70] glue_1.3.1               packrat_0.5.0            evaluate_0.14           
[73] biovizBase_1.32.0        latticeExtra_0.6-28      data.table_1.12.6       
[76] vctrs_0.2.0              gtable_0.3.0             purrr_0.3.3             
[79] assertthat_0.2.1         xfun_0.8                 AnnotationFilter_1.8.0  
[82] survival_2.44-1.1        viridisLite_0.3.0        GenomicAlignments_1.20.1
[85] AnnotationDbi_1.46.1     memoise_1.1.0            cluster_2.0.8           

Coverage plots from reverse strand data

Hello,

I'm trying to get some coverage plots for data of the reverse strand. I have only wiggle files to produce these plots. Some of the files have very narrow reads cause I need to plot them for comparison. My problem is that for most of my data creating the plot works without problems. But for some of the libraries it doesn't give me a correct plot.

I attached a sample with two plots. On the first plot "BHI-" you can see the issue, while the second one "BHI+" got plotted correctly.
Rplot

`dt <- DataTrack(range=range, name=name, strand = "-", chromosome=chromosome, type="hist", fill.histogram=color, fontsize = 12, cex.axis=1,
collapse = FALSE, cex.title = 1, size = 5, window = -1, alpha.title = 1, alpha = 0.5)

plotTracks(tracks, from=from, to=to, background.title = "white",
col.histogram="NA", col.frame="white", col.axis="black", col="black",
col.title="black", extend.right = 10, extend.left = 10, reverseStrand = TRUE)
`

I hope you can help me with this issue.
Best regards,
Vanessa

request for GenomeAxisTrack: add "bp" to small scale bars

hi again,

I'm enjoying using Gviz - thanks for all your hard work on it.

I'm using code similar to GenomeAxisTrack(scale=0.5) to create a very simple scale bar.

When the scale bar ends up with size >=1kb, the label includes "kb". But when the scale bar is <1kb, the label is simply a number with no unit (in Gviz v1.36.2). Would it be easy to add "bp" to the label, just like "kb" gets added? That would be very nice from an end-user perspective.

thanks!

Janet

GenomeAxisTrack hangs with large negative 'from'

hi there,

I've found a weird issue with GenomeAxisTrack.

I'm using negative 'from' coordinates in plotTracks (perhaps that's odd, but I'm looking at how far upstream things are from a fixed point, and it's nice for me to have that fixed point be 1).

With small negative 'from' values, things works OK, but with larger negative numbers, I get halfway through plotting the GenomeAxisTrack and then things just hang.

Hopefully the code below is reproducible. Thanks for checking this out,

Janet

library(Gviz)

gr <- GRanges(seqnames="chr1",  ranges=IRanges(start=10,end=20), strand="+") 

myPlotFunction <- function(thisFrom) {
    plotTracks( list(GenomeAxisTrack(), AnnotationTrack(gr)), from=thisFrom, to=300)
}

myPlotFunction(thisFrom = 1)      # works
myPlotFunction(thisFrom = -1000)  # works
myPlotFunction(thisFrom = -2000)  # hangs!  gets partway through plotting the axis, but doesn't get any further

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.4

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
    [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
    [1] Gviz_1.36.1          GenomicRanges_1.44.0 GenomeInfoDb_1.28.0  IRanges_2.26.0      
[5] S4Vectors_0.30.0     BiocGenerics_0.38.0 

loaded via a namespace (and not attached):
    [1] ProtGenerics_1.24.0         bitops_1.0-7                matrixStats_0.59.0         
[4] bit64_4.0.5                 filelock_1.0.2              RColorBrewer_1.1-2         
[7] progress_1.2.2              httr_1.4.2                  backports_1.2.1            
[10] tools_4.1.0                 utf8_1.2.1                  R6_2.5.0                   
[13] rpart_4.1-15                lazyeval_0.2.2              Hmisc_4.5-0                
[16] DBI_1.1.1                   colorspace_2.0-2            nnet_7.3-16                
[19] tidyselect_1.1.1            gridExtra_2.3               prettyunits_1.1.1          
[22] bit_4.0.4                   curl_4.3.2                  compiler_4.1.0             
[25] Biobase_2.52.0              htmlTable_2.2.1             xml2_1.3.2                 
[28] DelayedArray_0.18.0         rtracklayer_1.52.0          scales_1.1.1               
[31] checkmate_2.0.0             rappdirs_0.3.3              stringr_1.4.0              
[34] digest_0.6.27               Rsamtools_2.8.0             foreign_0.8-81             
[37] XVector_0.32.0              dichromat_2.0-0             htmltools_0.5.1.1          
[40] base64enc_0.1-3             jpeg_0.1-8.1                pkgconfig_2.0.3            
[43] MatrixGenerics_1.4.0        ensembldb_2.16.0            dbplyr_2.1.1               
[46] fastmap_1.1.0               BSgenome_1.60.0             htmlwidgets_1.5.3          
[49] rlang_0.4.11                rstudioapi_0.13             RSQLite_2.2.7              
[52] BiocIO_1.2.0                generics_0.1.0              BiocParallel_1.26.0        
[55] dplyr_1.0.7                 VariantAnnotation_1.38.0    RCurl_1.98-1.3             
[58] magrittr_2.0.1              GenomeInfoDbData_1.2.6      Formula_1.2-4              
[61] Matrix_1.3-4                Rcpp_1.0.6                  munsell_0.5.0              
[64] fansi_0.5.0                 lifecycle_1.0.0             stringi_1.6.2              
[67] yaml_2.2.1                  SummarizedExperiment_1.22.0 zlibbioc_1.38.0            
[70] BiocFileCache_2.0.0         blob_1.2.1                  crayon_1.4.1               
[73] lattice_0.20-44             Biostrings_2.60.1           splines_4.1.0              
[76] GenomicFeatures_1.44.0      hms_1.1.0                   KEGGREST_1.32.0            
[79] knitr_1.33                  pillar_1.6.1                rjson_0.2.20               
[82] biomaRt_2.48.1              XML_3.99-0.6                glue_1.4.2                 
[85] biovizBase_1.40.0           latticeExtra_0.6-29         data.table_1.14.0          
[88] png_0.1-7                   vctrs_0.3.8                 gtable_0.3.0               
[91] purrr_0.3.4                 assertthat_0.2.1            cachem_1.0.5               
[94] ggplot2_3.3.5               xfun_0.24                   AnnotationFilter_1.16.0    
[97] restfulr_0.0.13             survival_3.2-11             tibble_3.1.2               
[100] GenomicAlignments_1.28.0    AnnotationDbi_1.54.1        memoise_2.0.0              
[103] cluster_2.1.2               ellipsis_0.3.2             

plotTracks: mm10 gene symbols not appearing when transcriptAnnotation="symbol"

Hello,

When trying to annotate mm10 transcripts with gene symbols using the mm10 TxDb object in GeneRegionTrack() and setting transcriptAnnotation="symbol" within plotTracks(), the resulting plots label the transcripts with the Ensembl transcript ID's anyway.

library(Gviz)
library(GenomicFeatures)
library(TxDb.Mmusculus.UCSC.mm10.knownGene)

txdb <- TxDb.Mmusculus.UCSC.mm10.knownGene
gene_track <- GeneRegionTrack(txdb, name = "Genes")

plotTracks(list(ideo_track, axis_track, highlight_track, gene_track),
           from = start, to = end, chromosome =chr, transcriptAnnotation = "symbol")

Rplot

individual base colors in alignment tracks

Hi,

I was wondering if there's a way that specific bases in the alignment track can be colored differently on a single read level according to a user-defined tag in the bam. This is especially helpful in visualizing single long read methylation data.

Thanks!

Collapse multiple transcripts per gene from geneRegionTrack

Hi,

I'm wondering if there is any way to collapse multiple transcripts (under same gene, MLH1 here) into one.

Screen Shot 2020-03-16 at 10 29 43 PM

collapseTranscripts="longest" works great for same transcript ID. However, when the same gene has multiple unique transcripts, the plot shows as above. I've tried to use ncbiRefSeqSelect from UcscTrack so that each gene can show one major transcript, however, it doesn't cover whole genes.

I'm currently using following settings for gene region track.

grtrack <- GeneRegionTrack(ucscGenes.gr, genome = "hg38", chromosome = chr, name = "UCSC Genes", background.title="brown", shape="arrow", min.width=4, min.height=5)
plotTracks(grtrack, chromosome=chr, from=from, to=to, collapse=T, transcriptAnnotation = 'symbol', collapseTranscripts="longest")

Thanks in advance,
MJ

AlignmentsTrack: show all bases

Hi,
Is there any easy way to show all the bases in an AlignmentsTrack? Currently the mismatching bases can be shown as colors or letters, and I'd like to show all the bases in a similar manner. Ideally, the output would be similar to "samtools tview" with "dot view off" and "color for nucleotide".

I suppose one could edit the mismatch information at displayPars(plot$atrack,".__mismatches") but that looks really cumbersome. I had to stop as I didn't understand the relation of "stack" and "read" in that data.frame and in plot$atrack@range and plot$atrack@stacks.

Thanks a lot in advance!

BR, Ari

Incorrect plotting of a sequence track with index (.fa.idx)

When running this code:

refseq <- Gviz::SequenceTrack("sequence.fa")
Gviz::plotTracks(
  trackList=c(refseq),
  from=200,
  to=600,
  chromosome="chr1")

When sequence.fa does not have an index, refseq is of class "SequenceDNAStringSetTrack" and everything displays correctly.

However if I add an index:

samtools faidx sequence.fa

refseq is now a "ReferenceSequenceTrack" class and the track is not displayed correctly. Depending on the 'from' and 'to' nothing or an incorrect snippet is displayed.

Since the index works correctly in other programs, my guess is that there's some problem with "ReferenceSequenceTrack" but I'm unsure how to proceed.

Alex

plotTrack() into a grob

Hi!
Is it possible to make a plotTrack() into a grob-object so I can arrange multiple plots with cowplot?

Cheers,
Andrey

How to assign different colours to dots depending on another column

Hi @ivanek,
Thanks so much for developing such wonderful package.

I wonder if there is an option in Gviz to assign different colours to dots depending on another column with factor levels, something similar to what can be accomplished with the scale_color_manual() function of ggplot.

I am trying to create a data track that shows a dot plot like this:
exampleplot

I generated the example plot with ggplot:

library(ggplot2)
p <- ggplot(ChiSqr_subset, aes(x = end, y = log10P)) + 
  geom_point(aes(colour = as.factor(effect))) +
  scale_color_manual(name = "Effect categories",
                     values = c('missense_variant' = '#e31a1c',
                                'synonymous_variant' = '#1f78b4',
                                '5_prime_UTR_variant' = '#feb24c', 
                                '3_prime_UTR_variant' = '#feb24c',
                                'upstream_gene_variant' = '#feb24c',
                                'downstream_gene_variant' = '#feb24c',
                                'intron_variant' = 'gray',
                                'intergenic_region' = 'gray'#,
                                #NA = 'black'
                                ),
                     breaks = effect_order,
                     labels = c('Coding non-synonymous', 'Coding synonymous', '5-prime UTR', 
                                '3-prime UTR', '5kb upstream', '5kb downstream', 
                                'Intron', 'Intergenic')) +
  labs(x = "SNP", y = "-log10(P-value)") +
  theme_classic() +
  theme(axis.text.x = element_blank(), axis.ticks.x = element_blank())
p

The input data frame ChiSqr_subset looks like:

  chromosome start  end log10P            effect
1       chr1   757  757              3.838054 intergenic_region
2       chr1  1383 1383              1.789974 intergenic_region
3       chr1  1403 1403              1.409600 intergenic_region
4       chr1  2684 2684              1.506558 5_prime_UTR_variant
5       chr1  2685 2685              1.491539 intergenic_region
6       chr1  2689 2689              1.212418 synonymous_variant

Note that the column "effect" is of type character and the categories repeat.

To try to generate this plot using Gviz, I followed these steps:

  • converted the input data frame into GRanges using the makeGRangesFromDataFrame() function:
ChiSqr_GR <- makeGRangesFromDataFrame(ChiSqr_subset,
                                      keep.extra.columns = TRUE)
  • converted the resulting Granges object to a Gviz data track using the DataTrack() constructor:
dTrack_ChiSqr <- DataTrack(range = ChiSqr_GR,
                        name = '-log10(P-value)',
                        cex = 0.5,
                        #chromosome = Chr, from = Start, to = End,
                        #cex.axis = 1,
                        #col.axis = 'black', col.title = 'black', background.title = 'white', background.panel = 'white',
                        options(ucscChromosomeNames = FALSE)
)

The "effect" column is being discarded by the dataTrack constructor because it is not numeric:

Warning message:
In .prepareDtData(data, len = length(range)) :
  The following non-numeric data column has been dropped: effect

Then I tried to add the categorical groupings to the data track by setting groups = to the vector equivalent to the effect column from the original data frame ChiSqr_subset, but it does not work:

plotTracks(dTrack, groups = factor(ChiSqr_subset$effect, levels = effect_order), type = c("p"), legend = TRUE)

The vector given as "levels" was:

effect_order <- c('missense_variant', 'synonymous_variant', '5_prime_UTR_variant', 
                  '3_prime_UTR_variant', 'upstream_gene_variant', 'downstream_gene_variant', 
                  'intron_variant', 'intergenic_region')

Get this error message:

Error in .local(GdObject, ...) : 
  'groups' must be a vector of similar length as the number of rows in the data matrix (1)

But confirmed the length is the same between the groups vector and the dataTrack object:

> length(dTrack_ChiSqr)
[1] 47049
> length(ChiSqr_subset$effect)
[1] 47049

Any recommendation on how to solve this problem will be greatly appreciated.

Thanks,
Angela

Include pairwise LD information in a track?

Is there a way in Gviz to include anything like a plot of which SNPs are in pairwise LD with each other? Something like this, for example:

gwas

I haven't managed to figure out a way to include something like this, but it would be a nice addition.

Gviz is fantastic, by the way; thank you for all your work on it.

Missing dependency: xml2

Hi, it looks like xml2 needs to be added to Suggests, or alternatively test conditionally on requireNamespace("xml2"). I spotted this while running revdep checks on my matrixStats package. Here is what I get:

* using log directory ‘/c4/home/henrik/repositories/matrixStats/revdep/checks/Gviz/new/Gviz.Rcheck’
* using R version 4.1.0 (2021-05-18)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘Gviz/DESCRIPTION’ ... OK
* this is package ‘Gviz’ version ‘1.36.0’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘Gviz’ can be installed ... OK
* checking installed package size ... NOTE
  installed size is 10.3Mb
  sub-directories of 1Mb or more:
    R         1.7Mb
    doc       4.7Mb
    extdata   2.5Mb
* checking package directory ... OK
* checking ‘build’ directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking contents of ‘data’ directory ... OK
* checking data for non-ASCII characters ... OK
* checking data for ASCII and uncompressed saves ... OK
* checking installed files from ‘inst/doc’ ... OK
* checking examples ... OK
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ... ERROR
  Running ‘testthat.R’
Running the tests in ‘tests/testthat.R’ failed.
Last 50 lines of output:
  Attaching package: 'S4Vectors'
  
  The following objects are masked from 'package:base':
  
      I, expand.grid, unname
  
  Loading required package: IRanges
  Loading required package: GenomicRanges
  Loading required package: GenomeInfoDb
  Loading required package: grid
  > 
  > test_check("Gviz")
  Loading required package: BSgenome
  Loading required package: Biostrings
  Loading required package: XVector
  
  Attaching package: 'Biostrings'
  
  The following object is masked from 'package:grid':
      pattern
  
  The following object is masked from 'package:base':
  
      strsplit
  
  Loading required package: rtracklayer
  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Error (test_AllClasses.R:168:5): interaction with biomart works ─────────────
  Error: Please install xml2 package
  Backtrace:
       █
    1. └─Gviz::BiomartGeneRegionTrack(...) test_AllClasses.R:168:4
    2.   └─methods::new(...)
    3.     ├─methods::initialize(value, ...)
    4.     └─Gviz::initialize(value, ...)
    5.       └─Gviz:::.local(.Object, ...)
    6.         └─Gviz:::.cacheMartData(.Object, chromosome, staged)
    7.           └─Gviz:::.fetchBMData(bmtrack, chromosome, staged)
    8.             └─biomaRt::getBM(...)
    9.               └─biomaRt:::.createHash(...)
   10.                 └─biomaRt::listEnsemblArchives()
   11.                   └─biomaRt:::.listEnsemblArchives(https = https, httr_config = list())
   12.                     ├─XML::htmlParse(content(html))
   13.                     └─httr::content(html)
   14.                       └─httr:::parse_auto(raw, type, encoding, ...)
   15.                         └─httr:::parser(...)
   16.                           └─httr:::need_package("xml2")
  
  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 293 ]
  Error: Test failures
  Execution halted
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in ‘inst/doc’ ... OK
* checking running R code from vignettes ... NONE
  ‘Gviz.Rmd’ using ‘UTF-8’... OK
* checking re-building of vignette outputs ... SKIPPED
* DONE
Status: 1 ERROR, 1 NOTE

Error in .local(.Object, ...) : Failed to obtain 'hguid' cookie

Hi,

I'm getting following errors frequently when I submitted several jobs with slurm on the server.

Error in .local(.Object, ...) : Failed to obtain 'hguid' cookie
Calls: IdeogramTrack ... browserSession -> new -> initialize -> initialize -> .local

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS/LAPACK: /app/software/OpenBLAS/0.3.1-GCC-7.3.0-2.30/lib/libopenblas_haswellp-r0.3.1.so

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


Seems like I'm getting this error when it fetches the data from UCSC, is there way to avoid this issues? For example, if it's possible to download ideogram information in advance and load the data instead.

I also found this options(Gviz.ucscUrl="http://genome-euro.ucsc.edu/cgi-bin/". from document. what's the default ucscUrl that's been used for standard run?

Thanks!

y ticks not showing correct values for custmized aggregation function

Hi @ivanek ,

Thanks for the great package!

I'm trying to display a SNP density track with log10 transformed values for 'hist' type DataTracks, the code snipet was used:

snp_track <- DataTrack( GRanges(seqnames = chrom,
                                IRanges(start=snp_anno$POS,
                                        wsidth = 1,
                                        genome = "mm10")),
                        name = "SNPs denstiy",
                        data = rep(1,nrow(snp_anno)),
                        window = nwindow,
                        aggregation  = function(x) { log10(sum(x)+1)},
                        type=plot_type)

It gives the correct histogram shape but the scale and ticks on the y axis are off:
image

The scale on y should be from [0,4] but it is all under 1 as shown.

If comparing to using the "sum" as the aggregation function:
image

Any idea about how to fix this?

Thanks,
Ruqian

Details AnnotationTrack swap densityplot and connectors

Hi,
I'm creating some plots with GVIZ and for the sake of the plot order, it would be great to swap the densityplot and the "connectionsplot" in den DetailsAnnotationTrack.

So instead of showing the densityplot above the connectors (as shown here I would like to have it the other way around. Arrows above the densityplot.

Did I oversee the argument for that, or could you help me with a solution?

best

Recent update to Gviz inverts colors in CAGEfightR

Thanks for developing a great package!

I'm developing the CAGEfightR package which provides many functions for interfacing with Gviz.

It seems a recent upgrade to Gviz made some changes to how colors are ordered, causing the CAGEfightR minus/plus strand coloring to swap.

Can you provide some insight into what was changed in Gviz regarding this?

Representing SV arcs

Hi,

I have list of SV breaks points, for example

SV.id | chromosome_1 | start_1 | chromosome_2 | start_2
1 | chr1 | 2688849 | chr1 | 2746318
2 | chr1 | 146316299 | chr1 | 149363109
3 | chr1 | 169254858 | chr1 | 16927779

I want to represent breakpoints as arcs connecting each start site.

I've tried to combine datatrack and alignment track to represent this.

Here is my code:

dat = cna.dat #logR copy number
dat.gr <- as(dat, "GRanges")
dtrack <- DataTrack(dat.gr, genome="hg38", type=c("p"),chromosome="chr1", name = "Copy Number")

sv = read.csv('SV_test.txt',sep='\t')
sv.gr <- as(sv, "GRanges")
alTrack <- AlignmentsTrack(sv.gr)

pdf('sv_test.pdf')
plotTracks(trackList=c(dtrack, alTrack), from=from, to=to, chromosome="chr1", type=c("p","sashimi"))
dev.off()

And sv.gr looks like this

sv.gr
GRanges object with 1 range and 2 metadata columns:
seqnames ranges strand | strand1 strand2
|
[1] chr1 203598556-207630962 * | + -

It generated plot as below:

Screen Shot 2020-03-09 at 9 34 23 AM

I want the arc to be curved line instead of flat one.

Your comments would be greatly appreciated!

Thanks,
MJ

Rasterize datatrack layer

Any chance we can rasterize the datatrack layer? I'm saving the output image as SVG and file sizes get quite large due to a large degree of overlap on the datatrack layers.

Allow circle as alternative shape for centromere, different color?

Based on user request: How to modify centromere depiction in Gviz IdeogramTrack?:
https://support.bioconductor.org/p/123093/

library(Gviz)

cyto.bands <- data.frame(chrom = rep("chrI", 4),
                         chromStart = c(0, 148071, 151524, 154977),
                         chromEnd = c(148071, 151524, 154977, 230218),
                         name = c(NA, "CEN1", "CEN1", NA),
                         gieStain = c("gneg", "acen", "acen", "gneg"))

ideogram.track <- IdeogramTrack(chromosome = "chrI", genome = "sacCer3", bands = cyto.bands)

plotTracks(ideogram.track, from = 180e3, to = 220e3)

In the resulting plot, the centromere is depicted as two head-to-head triangles with brownish red filling. Is it possible to change how the centromere is depicted? Can one change the fill color? Can one change the shape (e.g. one filled circle instead of the triangles)?

Gviz AlignmentsTrack: how to prevent reads from overlapping each other

Hi,

I'd like to show bam reads with mismatches. I use the following code:

plottracks <- function(bpath,spath,chr,from,to) {
    options(ucscChromosomeNames=FALSE)
    seqs <- readDNAStringSet(spath)
    seqTrack <- SequenceTrack(seqs, from=from, to=to, chrom = chr)
    bamTrack<-AlignmentsTrack(bpath, fill.reads="pink", from=from, to=to, chrom = chr)
    plotTracks(c(bamTrack,seqTrack), from=from, to=to, chrom = chr) 
}

plottracks("lg17.bam","lg17.fa","LG17",1693000,1693120)

The resulting plot is here: https://ibb.co/0yB76yg

How could I prevent reads from overlapping each other? Should I prepare the bam file somehow or is there something wrong in my R code?

Thanks for any help!

Regards, Ari

H3K4Me3 not working: Error fetching data from UCSC

Hi I was trying to plot H3K4Me3 with Gviz and I ran into the following problem:

H3K4Me3 <- UcscTrack(genome=gen,
chromosome=chr,
from=from,
to=to,
track="Layered H3K4Me3",
trackType = "DataTrack",
start="start", end="end", data="score",
type = "hist", window = "auto",
col.histogram = "darkred",
fill.histogram = "darkred",
background.title = "#E4BBB0",
name="H3K4me3")

It gave me the following error message:
Error in UcscTrack(genome = gen, chromosome = chr, from = from, to = to, :
Error fetching data from UCSC
In addition: Warning messages:
1: In .local(x, ...) :
'track' parameter is deprecated now you go by the 'table' instead
Use ucscTables(genome, track) to retrieve the list of tables for a track
2: In UcscTrack(genome = gen, chromosome = chr, from = from, to = to, :
Error in stop_if_wrong_length("'seqnames'", ans_len) :
'seqnames' must have the length of the object to construct (31) or length 1

However, if I remove trackType = "DataTrack" it will work fine but the plot is not acceptable because of wrong trackType I suppose. just wondering how can I solve this issue?

thank you!

Is it possible to arrange Gviz plots in a grid?

I'd like to know if there is a way to arrang multiple Gviz plots in a grid. For example, I have two plots p1 and p2, both were produced using plotTracks and contains only DataTracks.

p1 <- plotTracks()
p2 <- plotTracks()

I tried

gridExtra::grid.arrange(p1, p2)

and

cowplot::plot_grid(p1, p2)

Both obviously return errors but I am using them to illustrate what I am trying to do

Issue in .barsAndLabels()

Hi,
thanks for this wonderful package.

I stumbled upon a quite rare issue, for which I unfortunately can not provide an reproducible example. But I tracked the error down quite a bit, so I hope this already helps:

In

Gviz/R/Gviz-methods.R

Lines 1779 to 1785 in 33370fb

"above"={
cx <- start(grpRangesCut) + width(grpRangesCut)/2
indx <- which(seq_len(length(grpRanges)) %in% queryHits(findOverlaps(grpRanges, grpRangesCut)))
cy <- yloc[indx] + 0.5
labs <- labs[indx]
algn <- c("center", "top")
},

it is possible for cx and cy to have a different length (depending on what indx returns).
This leads to an error in

labels <- data.frame(txt=labs, x=cx, y=cy, stringsAsFactors=FALSE)

Error in data.frame(txt = labs, x = cx, y = cy, stringsAsFactors = FALSE) : 
  arguments imply differing number of rows: #length(cx), #length(cy)

I did not take the time to fully track down what exactly is happening in this function, but one workaround for the above error would be to just add an cx <- cx[indx] to assure the same lengths for the vectors.
The same holds true for the "below" case.

Thanks in advance.

Best,
Tobias

OverlayTrack shows wrong values

The original track values don't show up properly when overlaying tracks

# minimal example #

gr1 = GRanges(seqnames = "chr1",ranges = IRanges(start = seq(1,100,by = 10),width = 5))

dt1 <- DataTrack(
  range = gr1,
  data = 1:10,
  alpha.title = 1, 
  alpha = 0.75,
  groups = factor("forward",levels = c("forward", "reverse")),
  type = "hist",
  name = "forward only"
)

dt2 <- DataTrack(
  range = GenomicRanges::shift(gr1,3),
  data = 10:1 + 89,
  alpha.title = 1, 
  alpha = 0.75,
  groups = factor("reverse",levels = c("forward", "reverse")),
  type = "hist",
  name = "reverse only"
)

ot <- OverlayTrack(trackList = list(dt1, dt2),name = "cannot specify name here?")

ot@trackList[[1]]@name = "overlayed\n(wrong reverse values)" # is this the only way to change name?

plotTracks(list(dt1,dt2,ot))

image

Package: Gviz
Version: 1.20.0

BUG (_R_CHECK_LENGTH_1_LOGIC2_): Error in .dpOrDefault(GdObject, ".__hasAnno", FALSE) && !is.null(bartext) && : 'length(x) = 3 > 1' in coercion to 'logical(1)'

R CMD check with (e.g. in ~/.R/check.Renviron):

## Check for bugs like if (c(TRUE, FALSE)). Supported since R (>= 3.4.0)
_R_CHECK_LENGTH_1_CONDITION_=package:_R_CHECK_PACKAGE_NAME_,verbose

## Check for bugs like c(TRUE, FALSE) && TRUE. Supported since R (>= 3.6.0)
_R_CHECK_LENGTH_1_LOGIC2_=package:_R_CHECK_PACKAGE_NAME_,verbose

produces:

* using log directory ‘/wynton/home/cbi/hb/repositories/matrixStats/revdep/checks/Gviz/new/Gviz.Rcheck’
* using R version 3.6.2 (2019-12-12)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘Gviz/DESCRIPTION’ ... OK
* this is package ‘Gviz’ version ‘1.30.1’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking for hidden files and directories ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking whether package ‘Gviz’ can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking ‘build’ directory ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking for left-over files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the package can be unloaded cleanly ... OK
* checking whether the namespace can be loaded with stated dependencies ... OK
* checking whether the namespace can be unloaded cleanly ... OK
* checking loading without being on the library search path ... OK
* checking dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd metadata ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking Rd contents ... OK
* checking for unstated dependencies in examples ... OK
* checking contents of ‘data’ directory ... OK
* checking data for non-ASCII characters ... OK
* checking data for ASCII and uncompressed saves ... OK
* checking installed files from ‘inst/doc’ ... OK
* checking files in ‘vignettes’ ... OK
* checking examples ... ERROR
Running examples in ‘Gviz-Ex.R’ failed
The error most likely occurred in:

> ### Name: GeneRegionTrack-class
> ### Title: GeneRegionTrack class and methods
> ### Aliases: GeneRegionTrack-class GeneRegionTrack
> ###   coerce,GeneRegionTrack,UCSCData-method
> ###   collapseTrack,GeneRegionTrack-method exon exon,GeneRegionTrack-method
> ###   exon<- exon<-,GeneRegionTrack,character-method
> ###   gene,GeneRegionTrack-method gene
> ###   gene<-,GeneRegionTrack,character-method gene<-
> ###   group,GeneRegionTrack-method group<-,GeneRegionTrack,character-method
> ###   identifier,GeneRegionTrack-method
> ###   identifier<-,GeneRegionTrack,character-method
> ###   initialize,GeneRegionTrack-method
> ###   initialize,ReferenceGeneRegionTrack-method
> ###   show,GeneRegionTrack-method show,ReferenceGeneRegionTrack-method
> ###   symbol,GeneRegionTrack-method
> ###   symbol<-,GeneRegionTrack,character-method symbol symbol<-
> ###   transcript,GeneRegionTrack-method
> ###   transcript<-,GeneRegionTrack,character-method transcript transcript<-
> ###   coerce,GRanges,GeneRegionTrack-method
> ###   coerce,GRangesList,GeneRegionTrack-method
> ###   coerce,TxDb,GeneRegionTrack-method
> ###   subset,ReferenceGeneRegionTrack-method
> ### Keywords: classes
> 
> ### ** Examples
> 
> 
> ## The empty object
> GeneRegionTrack()
GeneRegionTrack 'GeneRegionTrack'
| genome: NA
| active chromosome: chrNA
| annotation features: 0
> 
> ## Load some sample data
> data(cyp2b10)
> 
> ## Construct the object
> grTrack <- GeneRegionTrack(start=26682683, end=26711643,
+ rstart=cyp2b10$start, rends=cyp2b10$end, chromosome=7, genome="mm9",
+ transcript=cyp2b10$transcript, gene=cyp2b10$gene, symbol=cyp2b10$symbol,
+ feature=cyp2b10$feature, exon=cyp2b10$exon,
+ name="Cyp2b10", strand=cyp2b10$strand)
> 
> ## Directly from the data.frame
> grTrack <- GeneRegionTrack(cyp2b10)
> 
> ## From a TxDb object
> if(require(GenomicFeatures)){
+ samplefile <- system.file("extdata", "hg19_knownGene_sample.sqlite", package="GenomicFeatures")
+ txdb <- loadDb(samplefile)
+ GeneRegionTrack(txdb)
+ GeneRegionTrack(txdb, chromosome="chr6", start=35000000, end=40000000)
+ }
Loading required package: GenomicFeatures
Loading required package: AnnotationDbi
Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

GeneRegionTrack 'GeneRegionTrack'
| genome: hg19
| active chromosome: chr6
| annotation features: 71
> 
> 
> 
> ## Don't show: 
> ## For some annoying reason the postscript device does not know about
> ## the sans font
> if(!interactive())
+ {
+ font <- ps.options()$family
+ displayPars(grTrack) <- list(fontfamily=font, fontfamily.title=font)
+ }
> ## End(Don't show)
> 
> ## Plotting
> plotTracks(grTrack)
> 
> ## Track names
> names(grTrack)
[1] "GeneRegionTrack"
> names(grTrack) <- "foo"
> plotTracks(grTrack)
> 
> ## Subsetting and splitting
> subTrack <- subset(grTrack, from=26700000, to=26705000)
> length(subTrack)
[1] 0
> subTrack <- grTrack[transcript(grTrack)=="ENSMUST00000144140"]
> split(grTrack, transcript(grTrack))
$ENSMUST00000005477
GeneRegionTrack 'foo'
| genome: NA
| active chromosome: chr7
| annotation features: 12

$ENSMUST00000072438
GeneRegionTrack 'foo'
| genome: NA
| active chromosome: chr7
| annotation features: 11

$ENSMUST00000144140
GeneRegionTrack 'foo'
| genome: NA
| active chromosome: chr7
| annotation features: 2

> 
> ## Accessors
> start(grTrack)
 [1] 25897620 25897676 25897685 25897685 25911238 25911238 25911554 25911554
 [9] 25913865 25913865 25914748 25914748 25915392 25915392 25916766 25916934
[17] 25916934 25917288 25917288 25917288 25925373 25926068 25926068 25926250
[25] 25926250
> end(grTrack)
 [1] 25897684 25897684 25897855 25897855 25911400 25911400 25911703 25911703
 [9] 25914025 25914025 25914924 25914924 25915533 25915533 25917121 25917121
[17] 25917121 25917429 25917429 25917430 25925399 25926249 25926249 25926559
[25] 25926624
> width(grTrack)
 [1]  65   9 171 171 163 163 150 150 161 161 177 177 142 142 356 188 188 142 142
[20] 143  27 182 182 310 375
> position(grTrack)
 [1] 25897652 25897680 25897770 25897770 25911319 25911319 25911628 25911628
 [9] 25913945 25913945 25914836 25914836 25915462 25915462 25916944 25917028
[17] 25917028 25917358 25917358 25917359 25925386 25926158 25926158 25926404
[25] 25926437
> width(subTrack) <- width(subTrack)+100
> 
> strand(grTrack)
 [1] "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+" "+"
[20] "+" "+" "+" "+" "+" "+"
> strand(subTrack) <- "-"
> 
> chromosome(grTrack)
[1] "chr7"
> chromosome(subTrack) <- "chrX"
> 
> genome(grTrack)
[1] NA
> genome(subTrack) <- "hg19"
> 
> range(grTrack)
IRanges object with 25 ranges and 0 metadata columns:
           start       end     width
       <integer> <integer> <integer>
   [1]  25897620  25897684        65
   [2]  25897676  25897684         9
   [3]  25897685  25897855       171
   [4]  25897685  25897855       171
   [5]  25911238  25911400       163
   ...       ...       ...       ...
  [21]  25925373  25925399        27
  [22]  25926068  25926249       182
  [23]  25926068  25926249       182
  [24]  25926250  25926559       310
  [25]  25926250  25926624       375
> ranges(grTrack)
GRanges object with 25 ranges and 7 metadata columns:
       seqnames            ranges strand |        feature          id
          <Rle>         <IRanges>  <Rle> |       <factor> <character>
   [1]     chr7 25897620-25897684      + |           utr5     unknown
   [2]     chr7 25897676-25897684      + |           utr5     unknown
   [3]     chr7 25897685-25897855      + | protein_coding     unknown
   [4]     chr7 25897685-25897855      + | protein_coding     unknown
   [5]     chr7 25911238-25911400      + | protein_coding     unknown
   ...      ...               ...    ... .            ...         ...
  [21]     chr7 25925373-25925399      + | protein_coding     unknown
  [22]     chr7 25926068-25926249      + | protein_coding     unknown
  [23]     chr7 25926068-25926249      + | protein_coding     unknown
  [24]     chr7 25926250-25926559      + |           utr3     unknown
  [25]     chr7 25926250-25926624      + |           utr3     unknown
                     exon         transcript               gene   symbol
                 <factor>           <factor>           <factor> <factor>
   [1] ENSMUSE00000742021 ENSMUST00000072438 ENSMUSG00000030483  Cyp2b10
   [2] ENSMUSE00000489385 ENSMUST00000005477 ENSMUSG00000030483  Cyp2b10
   [3] ENSMUSE00000742021 ENSMUST00000072438 ENSMUSG00000030483  Cyp2b10
   [4] ENSMUSE00000489385 ENSMUST00000005477 ENSMUSG00000030483  Cyp2b10
   [5] ENSMUSE00000973560 ENSMUST00000072438 ENSMUSG00000030483  Cyp2b10
   ...                ...                ...                ...      ...
  [21] ENSMUSE00000496705 ENSMUST00000005477 ENSMUSG00000030483  Cyp2b10
  [22] ENSMUSE00000498616 ENSMUST00000072438 ENSMUSG00000030483  Cyp2b10
  [23] ENSMUSE00000750625 ENSMUST00000005477 ENSMUSG00000030483  Cyp2b10
  [24] ENSMUSE00000750625 ENSMUST00000005477 ENSMUSG00000030483  Cyp2b10
  [25] ENSMUSE00000498616 ENSMUST00000072438 ENSMUSG00000030483  Cyp2b10
         density
       <numeric>
   [1]         1
   [2]         1
   [3]         1
   [4]         1
   [5]         1
   ...       ...
  [21]         1
  [22]         1
  [23]         1
  [24]         1
  [25]         1
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
> 
> ## Annotation
> identifier(grTrack)
 [1] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
 [8] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
[15] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
[22] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
> identifier(grTrack, "lowest")
 [1] "ENSMUSE00000742021" "ENSMUSE00000489385" "ENSMUSE00000742021"
 [4] "ENSMUSE00000489385" "ENSMUSE00000973560" "ENSMUSE00000973560"
 [7] "ENSMUSE00001043622" "ENSMUSE00001043622" "ENSMUSE00001013991"
[10] "ENSMUSE00001013991" "ENSMUSE00000996531" "ENSMUSE00000996531"
[13] "ENSMUSE00000999790" "ENSMUSE00000999790" "ENSMUSE00000736922"
[16] "ENSMUSE00000963884" "ENSMUSE00000963884" "ENSMUSE00001063063"
[19] "ENSMUSE00001063063" "ENSMUSE00000748299" "ENSMUSE00000496705"
[22] "ENSMUSE00000498616" "ENSMUSE00000750625" "ENSMUSE00000750625"
[25] "ENSMUSE00000498616"
> identifier(subTrack) <- "bar"
> 
> feature(grTrack)
 [1] "utr5"           "utr5"           "protein_coding" "protein_coding"
 [5] "protein_coding" "protein_coding" "protein_coding" "protein_coding"
 [9] "protein_coding" "protein_coding" "protein_coding" "protein_coding"
[13] "protein_coding" "protein_coding" "protein_coding" "protein_coding"
[17] "protein_coding" "protein_coding" "protein_coding" "protein_coding"
[21] "protein_coding" "protein_coding" "protein_coding" "utr3"          
[25] "utr3"          
> feature(subTrack) <- "foo"
> 
> exon(grTrack)
 [1] "ENSMUSE00000742021" "ENSMUSE00000489385" "ENSMUSE00000742021"
 [4] "ENSMUSE00000489385" "ENSMUSE00000973560" "ENSMUSE00000973560"
 [7] "ENSMUSE00001043622" "ENSMUSE00001043622" "ENSMUSE00001013991"
[10] "ENSMUSE00001013991" "ENSMUSE00000996531" "ENSMUSE00000996531"
[13] "ENSMUSE00000999790" "ENSMUSE00000999790" "ENSMUSE00000736922"
[16] "ENSMUSE00000963884" "ENSMUSE00000963884" "ENSMUSE00001063063"
[19] "ENSMUSE00001063063" "ENSMUSE00000748299" "ENSMUSE00000496705"
[22] "ENSMUSE00000498616" "ENSMUSE00000750625" "ENSMUSE00000750625"
[25] "ENSMUSE00000498616"
> exon(subTrack) <- letters[1:2]
> 
> gene(grTrack)
 [1] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
 [4] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
 [7] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
[10] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
[13] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
[16] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
[19] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
[22] "ENSMUSG00000030483" "ENSMUSG00000030483" "ENSMUSG00000030483"
[25] "ENSMUSG00000030483"
> gene(subTrack) <- "bar"
> 
> symbol(grTrack)
 [1] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
 [8] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
[15] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
[22] "Cyp2b10" "Cyp2b10" "Cyp2b10" "Cyp2b10"
> symbol(subTrack) <- "foo"
> 
> transcript(grTrack)
 [1] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000072438"
 [4] "ENSMUST00000005477" "ENSMUST00000072438" "ENSMUST00000005477"
 [7] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000072438"
[10] "ENSMUST00000005477" "ENSMUST00000072438" "ENSMUST00000005477"
[13] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000144140"
[16] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000072438"
[19] "ENSMUST00000005477" "ENSMUST00000144140" "ENSMUST00000005477"
[22] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000005477"
[25] "ENSMUST00000072438"
> transcript(subTrack) <- c("foo", "bar")
> chromosome(subTrack) <- "chr7"
> plotTracks(subTrack)
> 
> values(grTrack)
          feature      id               exon         transcript
1            utr5 unknown ENSMUSE00000742021 ENSMUST00000072438
2            utr5 unknown ENSMUSE00000489385 ENSMUST00000005477
3  protein_coding unknown ENSMUSE00000742021 ENSMUST00000072438
4  protein_coding unknown ENSMUSE00000489385 ENSMUST00000005477
5  protein_coding unknown ENSMUSE00000973560 ENSMUST00000072438
6  protein_coding unknown ENSMUSE00000973560 ENSMUST00000005477
7  protein_coding unknown ENSMUSE00001043622 ENSMUST00000072438
8  protein_coding unknown ENSMUSE00001043622 ENSMUST00000005477
9  protein_coding unknown ENSMUSE00001013991 ENSMUST00000072438
10 protein_coding unknown ENSMUSE00001013991 ENSMUST00000005477
11 protein_coding unknown ENSMUSE00000996531 ENSMUST00000072438
12 protein_coding unknown ENSMUSE00000996531 ENSMUST00000005477
13 protein_coding unknown ENSMUSE00000999790 ENSMUST00000072438
14 protein_coding unknown ENSMUSE00000999790 ENSMUST00000005477
15 protein_coding unknown ENSMUSE00000736922 ENSMUST00000144140
16 protein_coding unknown ENSMUSE00000963884 ENSMUST00000072438
17 protein_coding unknown ENSMUSE00000963884 ENSMUST00000005477
18 protein_coding unknown ENSMUSE00001063063 ENSMUST00000072438
19 protein_coding unknown ENSMUSE00001063063 ENSMUST00000005477
20 protein_coding unknown ENSMUSE00000748299 ENSMUST00000144140
21 protein_coding unknown ENSMUSE00000496705 ENSMUST00000005477
22 protein_coding unknown ENSMUSE00000498616 ENSMUST00000072438
23 protein_coding unknown ENSMUSE00000750625 ENSMUST00000005477
24           utr3 unknown ENSMUSE00000750625 ENSMUST00000005477
25           utr3 unknown ENSMUSE00000498616 ENSMUST00000072438
                 gene  symbol density
1  ENSMUSG00000030483 Cyp2b10       1
2  ENSMUSG00000030483 Cyp2b10       1
3  ENSMUSG00000030483 Cyp2b10       1
4  ENSMUSG00000030483 Cyp2b10       1
5  ENSMUSG00000030483 Cyp2b10       1
6  ENSMUSG00000030483 Cyp2b10       1
7  ENSMUSG00000030483 Cyp2b10       1
8  ENSMUSG00000030483 Cyp2b10       1
9  ENSMUSG00000030483 Cyp2b10       1
10 ENSMUSG00000030483 Cyp2b10       1
11 ENSMUSG00000030483 Cyp2b10       1
12 ENSMUSG00000030483 Cyp2b10       1
13 ENSMUSG00000030483 Cyp2b10       1
14 ENSMUSG00000030483 Cyp2b10       1
15 ENSMUSG00000030483 Cyp2b10       1
16 ENSMUSG00000030483 Cyp2b10       1
17 ENSMUSG00000030483 Cyp2b10       1
18 ENSMUSG00000030483 Cyp2b10       1
19 ENSMUSG00000030483 Cyp2b10       1
20 ENSMUSG00000030483 Cyp2b10       1
21 ENSMUSG00000030483 Cyp2b10       1
22 ENSMUSG00000030483 Cyp2b10       1
23 ENSMUSG00000030483 Cyp2b10       1
24 ENSMUSG00000030483 Cyp2b10       1
25 ENSMUSG00000030483 Cyp2b10       1
> 
> ## Grouping
> group(grTrack)
 [1] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000072438"
 [4] "ENSMUST00000005477" "ENSMUST00000072438" "ENSMUST00000005477"
 [7] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000072438"
[10] "ENSMUST00000005477" "ENSMUST00000072438" "ENSMUST00000005477"
[13] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000144140"
[16] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000072438"
[19] "ENSMUST00000005477" "ENSMUST00000144140" "ENSMUST00000005477"
[22] "ENSMUST00000072438" "ENSMUST00000005477" "ENSMUST00000005477"
[25] "ENSMUST00000072438"
> group(subTrack) <- "Group 1"
> transcript(subTrack)
[1] "Group 1" "Group 1"
> plotTracks(subTrack)
> 
> ## Collapsing transcripts
> plotTracks(grTrack, collapseTranscripts=TRUE, showId=TRUE,
+ extend.left=10000, shape="arrow")
 ----------- FAILURE REPORT -------------- 
 --- failure: length > 1 in coercion to logical ---
 --- srcref --- 
: 
 --- package (from environment) --- 
Gviz
 --- call from context --- 
.local(GdObject, ...)
 --- call from argument --- 
.dpOrDefault(GdObject, ".__hasAnno", FALSE) && !is.null(bartext) && 
    !is.na(bartext)
 --- R stacktrace ---
where 1: .local(GdObject, ...)
where 2: .nextMethod(GdObject = GdObject, ... = ...)
where 3: callNextMethod()
where 4: drawGD(expandedTrackList[[i]], minBase = ranges["from"], maxBase = ranges["to"], 
    subset = FALSE)
where 5: drawGD(expandedTrackList[[i]], minBase = ranges["from"], maxBase = ranges["to"], 
    subset = FALSE)
where 6: plotTracks(grTrack, collapseTranscripts = TRUE, showId = TRUE, 
    extend.left = 10000, shape = "arrow")

 --- value of length: 3 type: logical ---
                    txt    x    y
ENSMUSG00000030483 TRUE TRUE TRUE
 --- function from context --- 
function (GdObject, minBase, maxBase, prepare = FALSE, subset = TRUE, 
    ...) 
{
    debug <- .dpOrDefault(GdObject, "debug", FALSE)
    if ((is.logical(debug) && debug) || debug == "prepare") 
        browser()
    imageMap(GdObject) <- NULL
    if (!length(GdObject)) 
        return(invisible(GdObject))
    if (prepare) {
        GdObject <- callNextMethod(GdObject, ...)
        bins <- stacks(GdObject)
        stacks <- max(bins)
        pushViewport(dataViewport(xData = c(minBase, maxBase), 
            extension = 0, yscale = c(1, stacks + 1), clip = TRUE))
        GdObject <- collapseTrack(GdObject, diff = .pxResolution(coord = "x"), 
            xrange = c(minBase, maxBase))
        popViewport(1)
        return(invisible(GdObject))
    }
    if ((is.logical(debug) && debug) || debug == "draw") 
        browser()
    bins <- stacks(GdObject)
    stacks <- max(bins)
    rev <- .dpOrDefault(GdObject, "reverseStrand", FALSE)
    xscale <- if (!rev) 
        c(minBase, maxBase)
    else c(maxBase, minBase)
    yscale <- if (!.dpOrDefault(GdObject, "reverseStacking", 
        FALSE)) 
        c(1, stacks + 1)
    else c(stacks + 1, 1)
    pushViewport(dataViewport(xscale = xscale, extension = 0, 
        yscale = yscale, clip = TRUE))
    res <- .pxResolution(coord = "x")
    curVp <- vpLocation()
    if (curVp$size["height"]/stacks < .dpOrDefault(GdObject, 
        "min.height", 3)) 
        stop("Too many stacks to draw. Either increase the device size or limit the drawing to a smaller region.")
    if (.dpOrDefault(GdObject, "showOverplotting", FALSE)) {
        dens <- as.numeric(values(GdObject)$density)
        if (length(unique(dens)) != 1) {
            minSat <- max(0.25, 1/max(dens))
            minDens <- min(dens)
            rDens <- diff(range(dens))
            saturation <- minSat + ((dens - minDens)/rDens/(1/(1 - 
                minSat)))
            bc <- unique(.getBiotypeColor(GdObject))
            baseCol <- rgb2hsv(col2rgb(bc))
            desatCols <- unlist(lapply(saturation, function(x) hsv(baseCol[1, 
                ], x, baseCol[3, ])))
            names(desatCols) <- paste(unique(feature(GdObject)), 
                rep(dens, each = length(bc)), sep = "_")
            feature(GdObject) <- paste(feature(GdObject), dens, 
                sep = "_")
            desatCols <- desatCols[unique(names(desatCols))]
            displayPars(GdObject) <- as.list(desatCols)
        }
    }
    box <- .boxes(GdObject, (stacks - bins) + 1)
    barsAndLab <- .barsAndLabels(GdObject)
    bar <- barsAndLab$bars
    bartext <- barsAndLab$labels
    shape <- .dpOrDefault(GdObject, "shape", "arrow")
    col.line <- .dpOrDefault(GdObject, "col.line")[1]
    border <- .dpOrDefault(GdObject, "col")[1]
    if (is.null(border)) 
        border <- ifelse(is(GdObject, "GeneRegionTrack"), NA, 
            "transparent")
    lwd <- .dpOrDefault(GdObject, "lwd", 2)
    lty <- .dpOrDefault(GdObject, "lty", 1)
    alpha <- .dpOrDefault(GdObject, "alpha", 1)
    rotation <- .dpOrDefaultFont(GdObject, "rotation", "item", 
        0)
    rotation.group <- .dpOrDefaultFont(GdObject, "rotation", 
        "group", 0)
    just <- .dpOrDefault(GdObject, "just.group", "left")
    if (nrow(box) > 0) {
        drawLabel <- .dpOrDefault(GdObject, ".__hasAnno", FALSE) && 
            !is.null(bartext) && !is.na(bartext) && nrow(bartext) > 
            0 && stacking(GdObject) != "dense"
        bs <- as.vector((stacks - bins) + 1)
        if (drawLabel && just %in% c("above", "below")) {
            labelHeights <- max(.getStringDims(GdObject, bartext$txt, 
                subtype = "group")$height)
            labelSpace <- as.numeric(convertHeight(unit(2, "points"), 
                "native"))
            avSpace <- (1 - max(box$cy2 - box$cy1))/2
            vadjust <- max(0, (labelHeights + (2 * labelSpace)) - 
                avSpace)
            bh <- 1 - (avSpace * 2)
            bhNew <- bh - vadjust
            sfac <- bhNew/bh
            if (just == "above") {
                bar$y <- bar$y - (vadjust/2)
                box$textY <- box$textY - (vadjust/2)
                bartext$y <- bartext$y - labelSpace
                box$cy1 <- bs + ((box$cy1%%1 - avSpace) * sfac) + 
                  avSpace
                box$cy2 <- bs + ((box$cy2%%1 - avSpace) * sfac) + 
                  avSpace
            }
            else {
                bar$y <- bar$y + (vadjust/2)
                box$textY <- box$textY + (vadjust/2)
                bartext$y <- bartext$y + labelSpace
                box$cy1 <- bs + ((box$cy1%%1 - avSpace) * sfac) + 
                  avSpace + vadjust
                box$cy2 <- bs + ((box$cy2%%1 - avSpace) * sfac) + 
                  avSpace + vadjust
            }
        }
        if (nrow(bar) > 0) 
            .arrowBar(bar$sx1, bar$sx2, y = bar$y, bar$strand, 
                box[, 1:4, drop = FALSE], W = .dpOrDefault(GdObject, 
                  "arrowFeatherWidth", 3), D = .dpOrDefault(GdObject, 
                  "arrowFeatherDistance", 20), col = if (is.null(col.line)) 
                  bar$col
                else rep(col.line, length(bar$col)), lwd = lwd, 
                lty = lty, alpha = alpha, barOnly = (!"smallArrow" %in% 
                  .dpOrDefault(GdObject, "shape", "box") || stacking(GdObject) == 
                  "dense"), diff = res, min.height = .dpOrDefault(GdObject, 
                  "min.height", 3))
        box$col <- if (is.na(border)) 
            box$fill
        else border
        if ("box" %in% shape || ("smallArrow" %in% shape && !("arrow" %in% 
            shape || "ellipse" %in% shape))) {
            .filledBoxes(box, lwd = lwd, lty = lty, alpha = alpha)
        }
        if ("ellipse" %in% shape) {
            ellCoords <- .box2Ellipse(box)
            grid.polygon(x = ellCoords$x1, y = ellCoords$y1, 
                id = ellCoords$id, gp = gpar(col = if (is.na(border)) 
                  box$fill
                else border, fill = box$fill, lwd = lwd, lty = lty, 
                  alpha = alpha), default.units = "native")
        }
        if ("arrow" %in% shape && !"box" %in% shape) {
            .filledArrow(box, lwd = lwd, lty = lty, alpha = alpha, 
                min.width = 4 * res, max.width = .dpOrDefault(GdObject, 
                  "arrowHeadMaxWidth", 40) * res)
        }
        if ("fixedArrow" %in% shape && !"box" %in% shape) {
            .filledArrow(box, lwd = lwd, lty = lty, alpha = alpha, 
                min.width = 4 * res, absoluteWidth = TRUE, W = .dpOrDefault(GdObject, 
                  "arrowHeadWidth", 30) * res)
        }
        if (.dpOrDefault(GdObject, "showFeatureId", FALSE)) 
            grid.text(box$text, box$textX, box$textY, rot = rotation, 
                gp = .fontGp(GdObject, subtype = "item"), default.units = "native", 
                just = c("center", "center"))
        if (drawLabel) {
            grid.text(bartext$txt, bartext$x, bartext$y, rot = rotation.group, 
                gp = .fontGp(GdObject, subtype = "group"), default.units = "native", 
                just = barsAndLab$align)
        }
    }
    popViewport(1)
    im <- if (!is.null(box)) {
        coords <- as.matrix(box[, c("x1", "y1", "x2", "y2"), 
            drop = FALSE])
        restCols <- setdiff(colnames(box), c("x1", "x2", "y1", 
            "y2", "cx1", "cx2", "cy1", "cy2", "textX", "textY"))
        tags <- sapply(restCols, function(x) {
            tmp <- as.character(box[, x])
                box$textY <- box$textY - (vadjust/2)
                bartext$y <- bartext$y - labelSpace
                box$cy1 <- bs + ((box$cy1%%1 - avSpace) * sfac) + 
                  avSpace
                box$cy2 <- bs + ((box$cy2%%1 - avSpace) * sfac) + 
                  avSpace
            }
            else {
                bar$y <- bar$y + (vadjust/2)
                box$textY <- box$textY + (vadjust/2)
                bartext$y <- bartext$y + labelSpace
                box$cy1 <- bs + ((box$cy1%%1 - avSpace) * sfac) + 
                  avSpace + vadjust
                box$cy2 <- bs + ((box$cy2%%1 - avSpace) * sfac) + 
                  avSpace + vadjust
            }
        }
        if (nrow(bar) > 0) 
            .arrowBar(bar$sx1, bar$sx2, y = bar$y, bar$strand, 
                box[, 1:4, drop = FALSE], W = .dpOrDefault(GdObject, 
                  "arrowFeatherWidth", 3), D = .dpOrDefault(GdObject, 
                  "arrowFeatherDistance", 20), col = if (is.null(col.line)) 
                  bar$col
                else rep(col.line, length(bar$col)), lwd = lwd, 
                lty = lty, alpha = alpha, barOnly = (!"smallArrow" %in% 
                  .dpOrDefault(GdObject, "shape", "box") || stacking(GdObject) == 
                  "dense"), diff = res, min.height = .dpOrDefault(GdObject, 
                  "min.height", 3))
        box$col <- if (is.na(border)) 
            box$fill
        else border
        if ("box" %in% shape || ("smallArrow" %in% shape && !("arrow" %in% 
            shape || "ellipse" %in% shape))) {
            .filledBoxes(box, lwd = lwd, lty = lty, alpha = alpha)
        }
        if ("ellipse" %in% shape) {
            ellCoords <- .box2Ellipse(box)
            grid.polygon(x = ellCoords$x1, y = ellCoords$y1, 
                id = ellCoords$id, gp = gpar(col = if (is.na(border)) 
                  box$fill
                else border, fill = box$fill, lwd = lwd, lty = lty, 
                  alpha = alpha), default.units = "native")
        }
        if ("arrow" %in% shape && !"box" %in% shape) {
            .filledArrow(box, lwd = lwd, lty = lty, alpha = alpha, 
                min.width = 4 * res, max.width = .dpOrDefault(GdObject, 
                  "arrowHeadMaxWidth", 40) * res)
        }
        if ("fixedArrow" %in% shape && !"box" %in% shape) {
            .filledArrow(box, lwd = lwd, lty = lty, alpha = alpha, 
                min.width = 4 * res, absoluteWidth = TRUE, W = .dpOrDefault(GdObject, 
                  "arrowHeadWidth", 30) * res)
        }
        if (.dpOrDefault(GdObject, "showFeatureId", FALSE)) 
            grid.text(box$text, box$textX, box$textY, rot = rotation, 
                gp = .fontGp(GdObject, subtype = "item"), default.units = "native", 
                just = c("center", "center"))
        if (drawLabel) {
            grid.text(bartext$txt, bartext$x, bartext$y, rot = rotation.group, 
                gp = .fontGp(GdObject, subtype = "group"), default.units = "native", 
                just = barsAndLab$align)
        }
    }
    popViewport(1)
    im <- if (!is.null(box)) {
        coords <- as.matrix(box[, c("x1", "y1", "x2", "y2"), 
            drop = FALSE])
        restCols <- setdiff(colnames(box), c("x1", "x2", "y1", 
            "y2", "cx1", "cx2", "cy1", "cy2", "textX", "textY"))
        tags <- sapply(restCols, function(x) {
            tmp <- as.character(box[, x])
            names(tmp) <- rownames(coords)
            tmp
        }, simplify = FALSE)
        tags$title <- identifier(GdObject)
        ImageMap(coords = coords, tags = tags)
    }
    else NULL
    imageMap(GdObject) <- im
    return(invisible(GdObject))
}
<environment: namespace:Gviz>
 --- function search by body ---
 ----------- END OF FAILURE REPORT -------------- 
Error in .dpOrDefault(GdObject, ".__hasAnno", FALSE) && !is.null(bartext) &&  : 
  'length(x) = 3 > 1' in coercion to 'logical(1)'
Calls: plotTracks ... drawGD -> drawGD -> callNextMethod -> .nextMethod -> .local
Execution halted
* checking for unstated dependencies in ‘tests’ ... OK
* checking tests ... OK
  Running ‘testthat.R’
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in ‘inst/doc’ ... OK
* checking running R code from vignettes ... NONE
  ‘Gviz.Rmd’using ‘UTF-8’... OK
* checking re-building of vignette outputs ... SKIPPED
* DONE
Status: 1 ERROR

See also

You can read about the type of bug in HenrikBengtsson/Wishlist-for-R#48

Unable to save plot to file

Is it possible to save the plots using R built-in devices: pdf(), png() ?

So far, I've been using an assigment like p <- plotTracks(atrack). But that stills brings the plot on the screen (which I is no trouble, a priori)... But when I do print(p) I get text on console:

$CpG
AnnotationTrack 'CpG'
| genome: hg19
| active chromosome: chr7
| annotation features: 10

$titles
An object of class "ImageMap"
Slot "coords":
    x1 y1      x2  y2
CpG  6  6 39.5622 667

Slot "tags":
$title
  CpG 
"CpG" 

Other libraries (like ggplot2) print the actual plot to the active device (by default, the screen. That enables you to get a PDF file simply:

pdf("myPlot.pdf")
print(plot)
dev.off()

But this of course is not the case with Gviz plots. How can I achieve such behaviour? Thanks in advance.

Unified line width for sashimi plot?

Hi, thanks for the great package. This is one of the very few tools that meet our need for Sashimi plot. I am wondering whether there is a way to set a unified linewidth range for more than one tracks. Right now different tracks have their different ranges of linewidths. This difference clearly represented in the y-axis. But I hope to make comparisons among samples (tracks) by just looking at the line width without the need to read the axis. I think that would make the difference among samples visually clearer.
Thanks

plotting 10 or more variables in a custom datatrack bug

Hi all,

Thank you for developing and maintaining this awesome resource!

I encountered a bug that happens once you try to plot 10 or more variables in a single datatrack. The data is plotted in the wrong order- here is a simple example. As seems typical with R, ordering gets funky once you're over 9 (ie 1, 10, 11, ..., 2). I'm using the S. cerevisiae genome as that's what I typically work with.

mycolors <- c("dodgerblue2", "blue2", "skyblue3", "darkturquoise", "brown", "olivedrab", "tomato", "chocolate", "burlywood4", "saddlebrown", "magenta4", "maroon2", "mediumpurple", "darkcyan", "cornsilk4", "mediumvioletred", "slategray3")
data <- data.frame(matrix(1:51, nrow = 3))
grTest <- GRanges(seqnames = 'chrI', ranges = IRanges(start = c(10, 20, 30), end = c(10, 20, 30)))
mcols(grTest) <- data
grouping <- names(mcols(grTest))
dtrackTest <- DataTrack(range = grTest, genome = "sacCer3", groups = grouping, name = "Test", type = "b", col = mycolors, frame = FALSE, lwd = 3, jitter.x = FALSE, cex = 1, ylim = c(0,55), lty = 1, legend = TRUE)
plotTracks(list(dtrackTest), from = 10, to = 33, cex.axis = 1, cex.title = 1, col.title = "black", col.axis = "black", chromosome = 'chrI').

Thanks for taking a look!

Best,
Rob

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.