Gviz: UcscTrack and "GC Percent" information
1
0
Entering edit mode
@daniel-e-weeks-10677
Last seen 4 months ago
Pittsburgh, Pennsylvania, United States…

Previously working coMET epigenetic plotting code now fails. It appears that this is because now UcscTrack fails when trying to pull information from the GC Percent track, generating the error "Error fetching data from UCSC".

Minimal Working Example

While the initial error was encountered trying to pull a "GC Percent' track for human 'hg19' (second example below) , this first example is directly based on

https://xiaonilee.github.io/post/ucscgenebrowser2/

where this code looks like it previously worked as of 2021-02-14.

library(Gviz)
from <- 65921878
to <- 65980988

knownGenes <- UcscTrack(genome = "mm9", chromosome = "chrX",
                        track = "knownGene", from = from, to = to,
                        trackType = "GeneRegionTrack",
                        rstarts = "exonStarts", rends = "exonEnds",
                        gene = "name", symbol = "name",
                        transcript = "name", strand = "strand",
                        fill = "#8282d2", name = "UCSC Genes")

knownGenes
# This plot works:
# plotTracks(list(knownGenes),
# from = from, to = to, showTitle = TRUE)


gcContent <- UcscTrack(genome = "mm9", chromosome = "chrX",
                       track = "GC Percent", table = "gc5Base",
                       from = from, to = to, trackType = "DataTrack",
                       start = "start", end = "end", data = "score",
                       type = "hist", window = -1, windowSize = 1500,
                       fill.histogram = "black", col.histogram = "black",
                       ylim = c(30, 70), name = "GC Percent")
gcContent


# Human example based on call that coMET generated
chr <- 7
gen <- "hg19"
genTrunk <- "hg19"
title <- "GC Percent"
start <- 33567324
# end <- 33722324
end <- start + 3000

GCTrack <- UcscTrack(genome = genTrunk, chromosome = chr, track = "GC Percent", 
    table = "gc5Base", from = start, to = end, trackType = "DataTrack", 
    start = "start", end = "end", data = "score", type = "hist", 
    window = -1, windowSize = 1500, fill.histogram = "black", 
    col.histogram = "red", ylim = c(30, 70), name = title, 
    col.line = NULL, col = NULL, fontfamily = "sans", fontfamily.title = "sans")

sessionInfo()

Result of running the code above

> suppressMessages(library(Gviz))
> from <- 65921878
> to <- 65980988
> 
> knownGenes <- UcscTrack(genome = "mm9", chromosome = "chrX",
+                         track = "knownGene", from = from, to = to,
+                         trackType = "GeneRegionTrack",
+                         rstarts = "exonStarts", rends = "exonEnds",
+                         gene = "name", symbol = "name",
+                         transcript = "name", strand = "strand",
+                         fill = "#8282d2", name = "UCSC Genes")
Warning messages:
1: In curlSetOpt(..., .opts = .opts, curl = h, .encoding = .encoding) :
  Error setting the option for # 3 (status = 43) (enum = 81) (value = 0x10effe590): A libcurl function was given a bad argument CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!
2: 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
3: 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
4: In curlSetOpt(..., .opts = .opts, curl = h, .encoding = .encoding) :
  Error setting the option for # 3 (status = 43) (enum = 81) (value = 0x13b817be0): A libcurl function was given a bad argument CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!
> 
> knownGenes
GeneRegionTrack 'UCSC Genes'
| genome: mm9
| active chromosome: chrX
| annotation features: 76
> # This plot works:
> # plotTracks(list(knownGenes),
> # from = from, to = to, showTitle = TRUE)
> 
> 
> gcContent <- UcscTrack(genome = "mm9", chromosome = "chrX",
+                        track = "GC Percent", table = "gc5Base",
+                        from = from, to = to, trackType = "DataTrack",
+                        start = "start", end = "end", data = "score",
+                        type = "hist", window = -1, windowSize = 1500,
+                        fill.histogram = "black", col.histogram = "black",
+                        ylim = c(30, 70), name = "GC Percent")
Error in UcscTrack(genome = "mm9", chromosome = "chrX", track = "GC Percent",  : 
  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 .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
3: In curlSetOpt(..., .opts = .opts, curl = h, .encoding = .encoding) :
  Error setting the option for # 3 (status = 43) (enum = 81) (value = 0x295c40830): A libcurl function was given a bad argument CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!
4: In UcscTrack(genome = "mm9", chromosome = "chrX", track = "GC Percent",  :
  Error in errorHandler(responseError) : Too Many Requests


> gcContent
Error: object 'gcContent' not found

> # Human example based on call that coMET generated
> chr <- 7
> gen <- "hg19"
> genTrunk <- "hg19"
> title <- "GC Percent"
> start <- 33567324
> # end <- 33722324
> end <- start + 3000
> 
> GCTrack <- UcscTrack(genome = genTrunk, chromosome = chr, track = "GC Percent", 
+                      table = "gc5Base", from = start, to = end, trackType = "DataTrack", 
+                      start = "start", end = "end", data = "score", type = "hist", 
+                      window = -1, windowSize = 1500, fill.histogram = "black", 
+                      col.histogram = "red", ylim = c(30, 70), name = title, 
+                      col.line = NULL, col = NULL, fontfamily = "sans", fontfamily.title = "sans")
Error in UcscTrack(genome = genTrunk, chromosome = chr, track = "GC Percent",  : 
  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 .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
3: In curlSetOpt(..., .opts = .opts, curl = h, .encoding = .encoding) :
  Error setting the option for # 3 (status = 43) (enum = 81) (value = 0x16fd92240): A libcurl function was given a bad argument CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!
4: In UcscTrack(genome = genTrunk, chromosome = chr, track = "GC Percent",  :
  Error in do.call(rbind.data.frame, results) : 
  second argument must be a list

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.6.7

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Versions/4.2-arm64/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      stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
[1] Gviz_1.42.0          GenomicRanges_1.50.1 GenomeInfoDb_1.34.4 
[4] IRanges_2.32.0       S4Vectors_0.37.2     BiocGenerics_0.44.0 

loaded via a namespace (and not attached):
  [1] ProtGenerics_1.30.0         bitops_1.0-7               
  [3] matrixStats_0.63.0          bit64_4.0.5                
  [5] filelock_1.0.2              RColorBrewer_1.1-3         
  [7] progress_1.2.2              httr_1.4.4                 
  [9] backports_1.4.1             tools_4.2.2                
 [11] utf8_1.2.2                  R6_2.5.1                   
 [13] rpart_4.1.19                lazyeval_0.2.2             
 [15] Hmisc_4.7-2                 DBI_1.1.3                  
 [17] colorspace_2.0-3            nnet_7.3-18                
 [19] tidyselect_1.2.0            gridExtra_2.3              
 [21] prettyunits_1.1.1           bit_4.0.5                  
 [23] curl_4.3.3                  compiler_4.2.2             
 [25] cli_3.4.1                   Biobase_2.58.0             
 [27] htmlTable_2.4.1             xml2_1.3.3                 
 [29] DelayedArray_0.24.0         rtracklayer_1.58.0         
 [31] checkmate_2.1.0             scales_1.2.1               
 [33] rappdirs_0.3.3              stringr_1.5.0              
 [35] digest_0.6.30               Rsamtools_2.14.0           
 [37] foreign_0.8-84              XVector_0.38.0             
 [39] dichromat_2.0-0.1           htmltools_0.5.4            
 [41] base64enc_0.1-3             jpeg_0.1-10                
 [43] pkgconfig_2.0.3             MatrixGenerics_1.10.0      
 [45] ensembldb_2.22.0            dbplyr_2.2.1               
 [47] fastmap_1.1.0               BSgenome_1.66.1            
 [49] htmlwidgets_1.5.4           rlang_1.0.6                
 [51] rstudioapi_0.14             RSQLite_2.2.19             
 [53] BiocIO_1.8.0                generics_0.1.3             
 [55] BiocParallel_1.32.4         dplyr_1.0.10               
 [57] VariantAnnotation_1.44.0    RCurl_1.98-1.9             
 [59] magrittr_2.0.3              GenomeInfoDbData_1.2.9     
 [61] Formula_1.2-4               interp_1.1-3               
 [63] Matrix_1.5-3                Rcpp_1.0.9                 
 [65] munsell_0.5.0               fansi_1.0.3                
 [67] lifecycle_1.0.3             stringi_1.7.8              
 [69] yaml_2.3.6                  SummarizedExperiment_1.28.0
 [71] zlibbioc_1.44.0             BiocFileCache_2.6.0        
 [73] blob_1.2.3                  parallel_4.2.2             
 [75] crayon_1.5.2                deldir_1.0-6               
 [77] lattice_0.20-45             Biostrings_2.66.0          
 [79] splines_4.2.2               GenomicFeatures_1.50.2     
 [81] hms_1.1.2                   KEGGREST_1.38.0            
 [83] knitr_1.41                  pillar_1.8.1               
 [85] rjson_0.2.21                codetools_0.2-18           
 [87] biomaRt_2.54.0              XML_3.99-0.13              
 [89] glue_1.6.2                  biovizBase_1.46.0          
 [91] latticeExtra_0.6-30         data.table_1.14.6          
 [93] png_0.1-8                   vctrs_0.5.1                
 [95] gtable_0.3.1                assertthat_0.2.1           
 [97] cachem_1.0.6                ggplot2_3.4.0              
 [99] xfun_0.35                   AnnotationFilter_1.22.0    
[101] restfulr_0.0.15             survival_3.4-0             
[103] tibble_3.1.8                GenomicAlignments_1.34.0   
[105] AnnotationDbi_1.60.0        memoise_2.0.1              
[107] cluster_2.1.4               ellipsis_0.3.2
Gviz coMET • 1.7k views
ADD COMMENT
0
Entering edit mode

Stepping through the mm9 chrX call above to UcscTrack with the debugger, we see that it sets up a query which then tries to use the track command from the rtracklayer package at this line:

tmp <- try(track(query), silent = TRUE)

This fails with the error message:

Error in do.call(rbind.data.frame, results) : 
  second argument must be a list

as well as with a warning:

Warning: Error setting the option for # 3 (status = 43) (enum = 81) (value = 0x28260ece0): A libcurl function was given a bad argument CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!

How does one change the value of CURLOPT_SSL_VERIFYHOST?

ADD REPLY
0
Entering edit mode

But note that the knownGenes call above works despite also warning about CURLOPT_SSL_VERIFYHOST, suggesting that the relevant error message is the one about the rbind.data.frame.

ADD REPLY
0
Entering edit mode

Looks like the original source of example code that is failing for me is actually from Section 6 of "The Gvis User Guide"

https://bioconductor.org/packages/devel/bioc/vignettes/Gviz/inst/doc/Gviz.html#6_Track_highlighting_and_overlays

where we see:

gcContent <- UcscTrack(genome = "mm9", chromosome = "chrX", 
                       track = "GC Percent", table = "gc5Base",
                       from = from, to = to, trackType = "DataTrack", 
                       start = "start", end = "end", data = "score",
                       type = "hist", window = -1, windowSize = 1500, 
                       fill.histogram = "black", col.histogram = "black",
                       ylim = c(30, 70), name = "GC Percent")
ADD REPLY
0
Entering edit mode

Looks like the error is happening in parseResponse of rtracklayer, where the first few lines are:

  results <- response[[tableName]]
  if (is.null(names(results))) {
    df <- do.call(rbind.data.frame, results)
  }

If we watch this in the debugger, we see when we enter parseResponse, we have:

Browse[2]> tableName
[1] "gc5Base"
Browse[2]> names(response)
 [1] "downloadTime"      "downloadTimeStamp" "genome"           
 [4] "dataTime"          "dataTimeStamp"     "trackType"        
 [7] "track"             "start"             "end"              
[10] "chrom"             "chrX"              "itemsReturned"

where the Wiggle track list information is in the chrX element of the response, but the code is trying to pull out the non-existent gc5Base element of the response instead.

So the line

 results <- response[[tableName]]

sets results to NULL, generating the subsequent error message:

Error in do.call(rbind.data.frame, results) : 
  second argument must be a list
ADD REPLY
0
Entering edit mode
@daniel-e-weeks-10677
Last seen 4 months ago
Pittsburgh, Pennsylvania, United States…

Answer

In

https://github.com/ivanek/Gviz/issues/71

an update that fixes this issue was documented - there it is stated that "from Gviz point of view, it requires now to change the parameter data="score" to data=value."

So this code, where we updated it to use data = "value" as recommended, now pulls the GC Content track layer just fine:

chr <- 7
gen <- "hg19"
genTrunk <- "hg19"
title <- "GC Percent"
start <- 33567324
# end <- 33722324
end <- start + 3000

GCTrack <- UcscTrack(genome = genTrunk, chromosome = chr, track = "GC Percent", 
    table = "gc5Base", from = start, to = end, trackType = "DataTrack", 
    start = "start", end = "end", data = "value", type = "hist", 
    window = -1, windowSize = 1500, fill.histogram = "black", 
    col.histogram = "red", ylim = c(30, 70), name = title, 
    col.line = NULL, col = NULL, fontfamily = "sans", fontfamily.title = "sans")

This was tested using Gviz_1.44.1.

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.7.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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

time zone: America/New_York
tzcode source: internal

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

other attached packages:
 [1] coMET_1.32.0         psych_2.3.9          Gviz_1.44.1         
 [4] GenomicRanges_1.52.0 GenomeInfoDb_1.36.3  IRanges_2.34.1      
 [7] S4Vectors_0.38.2     BiocGenerics_0.46.0  biomaRt_2.56.1      
[10] BiocManager_1.30.22  knitr_1.44          

loaded via a namespace (and not attached):
  [1] mnormt_2.1.1                DBI_1.1.3                  
  [3] bitops_1.0-7                deldir_1.0-9               
  [5] gridExtra_2.3               rlang_1.1.1                
  [7] magrittr_2.0.3              biovizBase_1.48.0          
  [9] matrixStats_1.0.0           compiler_4.3.1             
 [11] RSQLite_2.3.1               GenomicFeatures_1.52.2     
 [13] png_0.1-8                   vctrs_0.6.3                
 [15] ProtGenerics_1.32.0         stringr_1.5.0              
 [17] pkgconfig_2.0.3             crayon_1.5.2               
 [19] fastmap_1.1.1               backports_1.4.1            
 [21] dbplyr_2.3.4                XVector_0.40.0             
 [23] utf8_1.2.3                  Rsamtools_2.16.0           
 [25] rmarkdown_2.25              bit_4.0.5                  
 [27] xfun_0.40                   zlibbioc_1.46.0            
 [29] cachem_1.0.8                progress_1.2.2             
 [31] blob_1.2.4                  DelayedArray_0.26.7        
 [33] BiocParallel_1.34.2         jpeg_0.1-10                
 [35] parallel_4.3.1              prettyunits_1.2.0          
 [37] cluster_2.1.4               VariantAnnotation_1.46.0   
 [39] R6_2.5.1                    stringi_1.7.12             
 [41] RColorBrewer_1.1-3          rtracklayer_1.60.1         
 [43] rpart_4.1.19                Rcpp_1.0.11                
 [45] SummarizedExperiment_1.30.2 base64enc_0.1-3            
 [47] Matrix_1.6-1.1              nnet_7.3-19                
 [49] tidyselect_1.2.0            rstudioapi_0.15.0          
 [51] dichromat_2.0-0.1           abind_1.4-5                
 [53] yaml_2.3.7                  codetools_0.2-19           
 [55] curl_5.1.0                  lattice_0.21-9             
 [57] tibble_3.2.1                Biobase_2.60.0             
 [59] KEGGREST_1.40.0             evaluate_0.22              
 [61] foreign_0.8-85              BiocFileCache_2.8.0        
 [63] xml2_1.3.5                  Biostrings_2.68.1          
 [65] pillar_1.9.0                filelock_1.0.2             
 [67] MatrixGenerics_1.12.3       corrplot_0.92              
 [69] checkmate_2.2.0             generics_0.1.3             
 [71] RCurl_1.98-1.12             ensembldb_2.24.1           
 [73] hms_1.1.3                   ggplot2_3.4.3              
 [75] munsell_0.5.0               scales_1.2.1               
 [77] glue_1.6.2                  Hmisc_5.1-1                
 [79] lazyeval_0.2.2              tools_4.3.1                
 [81] interp_1.1-4                BiocIO_1.10.0              
 [83] data.table_1.14.8           BSgenome_1.68.0            
 [85] GenomicAlignments_1.36.0    XML_3.99-0.14              
 [87] latticeExtra_0.6-30         AnnotationDbi_1.62.2       
 [89] colorspace_2.1-0            nlme_3.1-163               
 [91] GenomeInfoDbData_1.2.10     htmlTable_2.4.1            
 [93] restfulr_0.0.15             Formula_1.2-5              
 [95] cli_3.6.1                   rappdirs_0.3.3             
 [97] fansi_1.0.4                 S4Arrays_1.0.6             
 [99] dplyr_1.1.3                 AnnotationFilter_1.24.0    
[101] gtable_0.3.4                hash_2.2.6.3               
[103] digest_0.6.33               rjson_0.2.21               
[105] htmlwidgets_1.6.2           memoise_2.0.1              
[107] htmltools_0.5.6             lifecycle_1.0.3            
[109] httr_1.4.7                  bit64_4.0.5
ADD COMMENT

Login before adding your answer.

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

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

Powered by the version 2.3.6