Invalid schema for gantt chart
Opened this issue · 0 comments
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')
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)
Interestingly, when I change the datatype to Ordinal, it does plot more of data:
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.