Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid schema for gantt chart #82

Open
pdimens opened this issue Mar 11, 2023 · 0 comments
Open

Invalid schema for gantt chart #82

pdimens opened this issue Mar 11, 2023 · 0 comments

Comments

@pdimens
Copy link

pdimens commented Mar 11, 2023

Hello, I'm trying to use vegabrite to generate visuals for genomic structural variants, which in this case are just glorified gantt charts. However, using the package, I get regular errors when attempting to do this.
The error is

Warning message:
Invalid schema for object passed to or created by modify_inner_spec.vegaspec_unit 

Here is a MWE following the gantt chart as interpreted from the VegaLite documention

df <- data.frame(task = c("a", "b", "c"), start = c(1, 3, 8), end = c(3, 8, 10))
vl_chart(height = 50, width = 700 ) %>%
  vl_add_data_frame(values = df) %>%
  vl_mark_bar(tooltip = TRUE) %>% 
  vl_encode_x('start:Q') %>%
  vl_encode_x2('end') %>% 
  vl_encode_y(field = 'task:N')

image

Further, a more advanced example using real data doesn't plot everything and throws the same warning/error.

> head(svfilt)
       contig population position_start position_end length type n_barcodes n_pairs     size
28 CM031716.1          1         124043       124044      1  DUP         11      32 56504578
29 CM031716.1          1         127116       290841 163725  INV         31     148 56504578
30 CM031716.1          1         145152      1048908 903756  DEL         14      32 56504578
31 CM031716.1          1         146432       442535 296103  INV         24     132 56504578
32 CM031716.1          1         146917       146918      1  DUP         27     140 56504578
33 CM031716.1          1         147886       330559 182673  DEL         76     224 56504578
vl_chart(height = 20, width = 700 ) %>%
  vl_add_data_frame(values = svfilt) %>%
  vl_mark_bar(tooltip = TRUE, fillOpacity = 0.6, height = 15) %>% 
  vl_encode_x('position_start:Q') %>%
  vl_encode_x2('position_end:Q') %>% 
  vl_encode_color(field = 'type:N') %>% 
  vl_encode_row(field = "type", type = "nominal", spacing = 0) %>% 
  vl_axis_x(grid = FALSE, domain = FALSE, tickCount = 5)

image

Interestingly, when I change the datatype to Ordinal, it does plot more of data:
image

However it forbids me from modifying the axis labels or number of ticks in an effort to hack it. In addition, it doesn't let me set an arbitrary range for the X axis to be the length of the chromosome (the size column in svfilt).

Is this a bug or user error? I am grateful for any wisdom or insight you can provide, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant