Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
8b3f102
Update compiler so that the levels of each selector is added to plot.…
kferris10 Jul 7, 2015
2a50bbb
Add selector widgets for iris data (initial attempt)
kferris10 Jul 7, 2015
44117e0
Reorganize layout of widgets
kferris10 Jul 7, 2015
6189306
Use a forEach loop to construct buttons (instead of constructing each…
kferris10 Jul 7, 2015
b0c55a4
Delete unnecessary console.log()
kferris10 Jul 7, 2015
ee8cd49
Add class and id to the show/hide button
kferris10 Jul 7, 2015
e423e58
Add class of selector_table to table of selector widgets
kferris10 Jul 7, 2015
803ad4b
Add an ID for each species
kferris10 Jul 7, 2015
806c665
Add some simple tests
kferris10 Jul 7, 2015
d84834b
Loop through all selectors to create widgets. Doesn't work for multi…
kferris10 Jul 8, 2015
8eba652
Update on("click") functionality. Still needs more work
kferris10 Jul 8, 2015
6ad3f1a
Add some comments
kferris10 Jul 8, 2015
ec33cc1
This is how I think that showing the different options for each selec…
kferris10 Jul 8, 2015
ade3673
Merge branch 'master' of https://github.com/tdhock/animint into selec…
kferris10 Jul 14, 2015
7472c75
Merge branch 'master' of https://github.com/tdhock/animint into selec…
kferris10 Jul 16, 2015
9c4f445
Merge branch 'master' of https://github.com/tdhock/animint into selec…
kferris10 Jul 17, 2015
74c0f33
Add selectize.css and selectize.js files
kferris10 Jul 19, 2015
1ae753a
Source in selectize
kferris10 Jul 19, 2015
0af3c2b
Fix folder directory for selectize
kferris10 Jul 19, 2015
f4ca1f1
Commenting out initial attempt at selector widgets
kferris10 Jul 21, 2015
a7725c0
Setting up selector widgets like animation control widgets
kferris10 Jul 21, 2015
817d0a5
Add selectize.js
kferris10 Jul 21, 2015
d38ab18
Add jquery
kferris10 Jul 21, 2015
01c3aa3
Remove selectize.js
kferris10 Jul 21, 2015
fc2edcb
Use selectize on selectors
kferris10 Jul 21, 2015
993276a
Switching to multiple options for the selector
kferris10 Jul 23, 2015
00e6335
Commenting out my attempts to add widgets with data-binds
kferris10 Jul 28, 2015
f25c3be
Creating widgets with a forEach loop :(
kferris10 Jul 28, 2015
75801d9
Trying out selectize
kferris10 Jul 28, 2015
42e9708
When the widget changes, update the selector
kferris10 Jul 28, 2015
5cb78ab
Update call of selectize so that it is called for each widget
kferris10 Jul 28, 2015
2bb5d6b
Fix selectize call to update_selector
kferris10 Jul 28, 2015
f6d5f9b
update selectize options
kferris10 Jul 28, 2015
b470795
Bug fix unrelated to selector widgets
kferris10 Jul 30, 2015
a149ae4
Almost works for multiple selection
kferris10 Jul 30, 2015
fd39107
Closer, but still not quite right for multiple selection.
kferris10 Jul 30, 2015
f4202b6
Update some comments
kferris10 Jul 30, 2015
b10277e
No options selected at beginning
kferris10 Jul 30, 2015
f018af7
Fix indentation
kferris10 Jul 31, 2015
2d3e829
For multiple selection, show selected items at first
kferris10 Jul 31, 2015
0ea8235
Almost the right strategy for multiple selection: if an option is on,…
kferris10 Aug 2, 2015
b782b5a
Fix max levels
kferris10 Aug 2, 2015
1701067
Better JavaScript (I think)
kferris10 Aug 2, 2015
c8d1dba
Fix typo
kferris10 Aug 2, 2015
0fec890
Delete some unnecessary if statements
kferris10 Aug 2, 2015
a67a093
Fix empty selections
kferris10 Aug 2, 2015
2195749
Fix bug with single selection variables.
kferris10 Aug 2, 2015
33dfe9c
Rearrange comments
kferris10 Aug 2, 2015
f44c710
Store selectize objects in an associative array (for later)
kferris10 Aug 8, 2015
9bf9995
Temporarily comment out onChange functionality
kferris10 Aug 8, 2015
d33ccda
When updating the selector, update the selected widgets.
kferris10 Aug 8, 2015
048450f
Fix typo
kferris10 Aug 8, 2015
e92cde5
uncomment
kferris10 Aug 8, 2015
16d9f5a
only update widgets if necessary
kferris10 Aug 8, 2015
0d4e76e
Update first selected widget for single selectors
kferris10 Aug 8, 2015
42ad9d2
Forgot to declare a var a bunch of times
kferris10 Aug 12, 2015
d0a4d24
Start updating test for selector widgets
kferris10 Aug 16, 2015
30e2154
Still working on updating tests
kferris10 Aug 16, 2015
ef9f8cc
Add some ids. Hopefully this will help with testing
kferris10 Aug 16, 2015
4842746
Fix single selection so that it only works for the appropriate selector
kferris10 Aug 16, 2015
64defc6
Removing the blank selection from each selector.
kferris10 Aug 16, 2015
a7fffa6
Delete old comments
kferris10 Aug 16, 2015
4728738
Switch to passing in options with ids and text instead of just the in…
kferris10 Aug 17, 2015
1ae16e9
Set up arrays for selected ids (to pass in to selectize options)
kferris10 Aug 17, 2015
f09ff1e
Extract selector name and specified levels in onChange method for mul…
kferris10 Aug 17, 2015
932c44e
Fix strategy of using selectors
kferris10 Aug 17, 2015
fc593fa
Set up jquery ids in update_selector
kferris10 Aug 17, 2015
860c934
Fix call to update selected widgets
kferris10 Aug 17, 2015
b1ea97e
Update options for single selection
kferris10 Aug 17, 2015
cf42bd3
Delete some unnecessary stuff
kferris10 Aug 17, 2015
e9efce1
Delete an unnecessary line
kferris10 Aug 17, 2015
6ee25f0
Fix onChange functionality for single selectors
kferris10 Aug 17, 2015
d097fe7
Only one item is selected at first for single selectors
kferris10 Aug 17, 2015
4af5881
Fix item for single selectors
kferris10 Aug 17, 2015
fdd5cdb
Fix initial selections and values to handle non-arrays
kferris10 Aug 17, 2015
6fdaa8a
TYPOS!!!!!!!
kferris10 Aug 17, 2015
a2f7ee4
Start fixing empty selections. Still needs work
kferris10 Aug 17, 2015
9d7e704
Update onChange when nothing is entered
kferris10 Aug 18, 2015
6eeb929
Switch to using i in for loops (cleans up global variables somehow).
kferris10 Aug 18, 2015
8aa0e52
Some more modifications to test-selector-widgets
kferris10 Aug 18, 2015
ec0742d
Update .gitignore
kferris10 Aug 18, 2015
60796a7
Trying to click selectize elements
kferris10 Aug 19, 2015
b6fc592
Set initial legend opacity for interactive variables
kferris10 Aug 20, 2015
f3a279d
Change name of jquery_thingy_array and make sure it's not a global va…
kferris10 Aug 21, 2015
7cd8b2c
do not show bar plot since we have selector widgets now
tdhock Aug 31, 2015
c953247
ignore jQuery variable
tdhock Aug 31, 2015
ef0292a
combine additions
tdhock Aug 31, 2015
3bdeca7
test selectize widgets
tdhock Aug 31, 2015
e597c43
enable shiny test on travis
tdhock Sep 2, 2015
7749c62
Replace all periods in ids with underscores
kferris10 Sep 6, 2015
9df282b
Remove test-selector-widgets
kferris10 Sep 6, 2015
f9937fc
max margin interval regression errors viz
tdhock Sep 8, 2015
0787909
version + selectize
tdhock Sep 8, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ animint.Rproj
tests/testthat/animint-htmltest/
tests/testthat/pids.txt
tests/testthat/.httr-oauth
.httr-oauth
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: animint
Maintainer: Toby Dylan Hocking <tdhock5@gmail.com>
Author: Toby Dylan Hocking, Susan VanderPlas, Carson Sievert
Version: 2015.08.31
Version: 2015.09.08
License: GPL-3
Title: Interactive animations
Description: An interactive animation can be defined using a list of
Expand Down
23 changes: 5 additions & 18 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,6 @@ RENDER: Easy legend decoding: draw an arrow next to the legend entry
for the value of the element that the mouse is hovering over, e.g.
http://www.highcharts.com/maps/demo/map-drilldown/dark-unica

RENDER: For each selector variable, render a widget for selecting values:
- single selection variable: <select> or <input type="radio">
- multiple selection categorical variable: <input type="checkbox">
- multiple selection numeric/datetime variable: crossfilter.js
http://square.github.io/crossfilter/
Currently, it is only possible to change the selection by clicking on
data points/lines, not widgets. To implement that you would probably
just have to add a few lines of JavaScript code to add the widgets,
right after the plot meta-data is loaded, in add_selector
https://github.com/tdhock/animint/blob/master/inst/htmljs/animint.js#L261. Also
for an example of adding a button to the web page in JavaScript, see
https://github.com/tdhock/animint/blob/master/inst/htmljs/animint.js#L1114.

DSL: For each widget selector, should we show all available values,
or just the values that are clickable onscreen? Or both? This may be
specified by the designer using an option
widgets=list(var1="onscreen", var2="all", var3="both").

DSL: To accomplish interactivity like in this plot
http://timelyportfolio.blogspot.ca/2014/05/pdf-chart-inkscape-svg-d3-interactive.html
http://kbroman.github.io/qtlcharts/assets/chartexamples/iplotMScanone_example.html
Expand Down Expand Up @@ -194,6 +176,11 @@ https://github.com/mbostock/d3/wiki/SVG-Shapes#symbol_type

RENDER: Determine why border of tiles in pirates example does not seem to be rendering.

2015.09.08

RENDER: For each selector variable, render a widget for selecting
values using selectize.js

2015.08.31

BUGFIX: For geom_point(aes(fill=annotation,
Expand Down
11 changes: 9 additions & 2 deletions R/animint.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ parsePlot <- function(meta){
if(is.null(meta$selector.types[[var_name]])) {
meta$selector.types[[var_name]] <- "multiple"
}
# if first is not specified, create it
if(is.null(meta$first)) {
meta$first <- list()
}
# if first is not specified, add all to first
if(is.null(meta$first[[var_name]])) {
u.vals <- unique(var)
Expand Down Expand Up @@ -444,8 +448,11 @@ saveLayer <- function(l, d, meta){
stopifnot(length(selector.type)==1)
stopifnot(selector.type %in% c("single", "multiple"))
meta$selectors[[v.name]] <-
list(selected=as.character(value),
type=selector.type)
list(
selected=as.character(value),
type=selector.type,
levels=as.character(unique(l$data[[v.name]]))
)
}
meta$selectors[[v.name]]$update <-
c(meta$selectors[[v.name]]$update, as.list(g$classed))
Expand Down
37 changes: 17 additions & 20 deletions inst/examples/WorldBank.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ animint2dir(good, "WorldBank-good")

## This example additionally uses multiple selection on countries.
library(dplyr)
max.years <- not.na %.%
group_by(country) %.%
filter(year==max(year)) %.%
max.years <- not.na %>%
group_by(country) %>%
filter(year==max(year)) %>%
mutate(year=2012)
wb.mult <-
list(ts=ggplot()+
Expand Down Expand Up @@ -134,17 +134,15 @@ wb.mult <-
data=not.na)+
scale_size_animint(breaks=10^(5:9))+
make_text(not.na, 5, 85, "year"),

time=list(variable="year",ms=3000),
bar=ggplot()+
theme_animint(height=2400)+
geom_bar(aes(country, life.expectancy, fill=region,
showSelected=year, clickSelects=country,
key=country),
data=not.na, stat="identity", position="identity")+
coord_flip(),

duration=list(year=1000),

first=list(year=1975, country=c("United States", "Vietnam")),

selector.types=list(country="multiple"),

title="World Bank data (multiple selection)")
animint2dir(wb.mult, "WorldBank-multiple")

Expand All @@ -157,9 +155,9 @@ TS <- function(df)BOTH(df, "Years", "Life expectancy")
SCATTER <- function(df)BOTH(df, "Fertility rate", "Life expectancy")
TS2 <- function(df)BOTH(df, "Fertility rate", "Years")
years <- unique(not.na[, "year", drop=FALSE])
min.years <- not.na %.%
group_by(country) %.%
filter(year==min(year)) %.%
min.years <- not.na %>%
group_by(country) %>%
filter(year==min(year)) %>%
mutate(year=1958)
wb.facets <-
list(ts=ggplot()+
Expand Down Expand Up @@ -204,16 +202,15 @@ wb.facets <-
geom_text(aes(5, 85, label=paste0("year = ", year),
showSelected=year),
data=SCATTER(years)),

time=list(variable="year",ms=3000),
bar=ggplot()+
theme_animint(height=2400)+
geom_bar(aes(country, life.expectancy, fill=region,
showSelected=year, clickSelects=country,
key=country),
data=not.na, stat="identity", position="identity")+
coord_flip(),

duration=list(year=1000),

first=list(year=1975, country=c("United States", "Vietnam")),

selector.types=list(country="multiple"),

title="World Bank data (multiple selection, facets)")

animint2dir(wb.facets, "WorldBank-facets")
106 changes: 103 additions & 3 deletions inst/examples/intreg.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
works_with_R("3.1.1",
"tdhock/animint@adefc133fd71a2ecd344bfaa102e3b5038ddf596")
works_with_R("3.2.2",
"tdhock/animint@9df282ba7b9e1dec9fd16124219870fa25e5df57")

## Example: 4 plots, 2 selectors.
data(intreg)
Expand Down Expand Up @@ -98,6 +98,7 @@ animint2dir(mmir.plot, "intreg-nofacets")
## facets. The simpler facetted version looks like this:
mmir.facet <-
list(signal=mmir.plot$signal,

penalty=ggplot()+
geom_tallrect(aes(xmin=min.L, xmax=max.L,
showSelected=signal,
Expand All @@ -123,7 +124,9 @@ mmir.facet <-
showSelected=signal),
data=data.frame(intreg$selection, what="segments"))+
xlab("penalty value $L=f(x)$")+ # TODO: mathjax.
facet_grid(what~.,scales="free"))
facet_grid(what~.,scales="free"),

title="Max-margin interval regression")
animint2dir(mmir.facet, "intreg-facets")
## This plot has an additional facet for signal, which would not be
## present in the interactive plot, but is useful here to see all
Expand All @@ -134,6 +137,103 @@ too.many.facets <- mmir.facet$penalty+
theme(panel.margin=grid::unit(0, "cm"))
print(too.many.facets)

## Regions with linetype indicating errors.
breaks.by.signal <- split(intreg$breaks, intreg$breaks$signal)
anns.by.signal <- split(intreg$ann, intreg$ann$signal)
error.regions.list <- list()
for(signal in names(breaks.by.signal)){
signal.breaks <- breaks.by.signal[[signal]]
signal.anns <- anns.by.signal[[signal]]
signal.anns$target.breaks <-
ifelse(signal.anns$annotation=="1breakpoint", 1, 0)
for(model.i in 1:20){
model.breaks <- subset(signal.breaks, segments==model.i)
signal.anns$breaks <- NA
for(region.i in 1:nrow(signal.anns)){
region <- signal.anns[region.i, ]
after.start <- region$first.base < model.breaks$base
before.end <- model.breaks$base < region$last.base
signal.anns$breaks[region.i] <- sum(after.start & before.end)
}
signal.anns$error.type <- with(signal.anns, {
ifelse(breaks < target.breaks, "false negative",
ifelse(target.breaks < breaks, "false positive", "correct"))
})
error.regions.list[[paste(model.i, signal)]] <-
data.frame(segments=model.i, signal.anns)
}
}
error.regions <- do.call(rbind, error.regions.list)

intreg.errors <-
list(signal=ggplot()+
theme_animint(height=300, width=800)+
scale_x_continuous("position on chromosome (mega base pairs)",
breaks=c(100,200))+
ylab("noisy copy number logratio signal")+
geom_tallrect(aes(xmin=first.base/1e6, xmax=last.base/1e6,
fill=annotation,
linetype=error.type,
showSelected2=segments,
showSelected=signal),
color="black",
alpha=0.5,
data=error.regions)+
scale_linetype_manual("error type", values=c(correct=0,
"false negative"=3,
"false positive"=1))+
guides(linetype=guide_legend(override.aes=list(fill="white")))+
scale_fill_manual(values=breakpoint.colors)+
geom_blank(aes(first.base/1e6, logratio+2/8), data=intreg$ann)+
geom_point(aes(base/1e6, logratio,
showSelected=signal),
data=intreg$sig)+
geom_segment(aes(first.base/1e6, mean, xend=last.base/1e6, yend=mean,
showSelected=signal,
showSelected2=segments),
data=intreg$seg, colour=signal.colors[["estimate"]])+
geom_vline(aes(xintercept=base/1e6,
showSelected=signal,
showSelected2=segments),
colour=signal.colors[["estimate"]],
linetype="dashed",
data=intreg$breaks),

penalty=ggplot()+
geom_tallrect(aes(xmin=min.L, xmax=max.L,
showSelected=signal,
clickSelects=segments),
data=data.frame(intreg$selection
##,what="segments"
),
alpha=1/2)+
ylab("")+
theme_animint(height=500, width=800)+
geom_segment(aes(min.L, feature, xend=max.L, yend=feature,
clickSelects=signal),
size=5,
data=data.frame(intreg$int, what="regression"))+
geom_segment(aes(min.L, min.feature, xend=max.L, yend=max.feature,
linetype=line),
colour="violet",
size=3,
data=data.frame(intreg$model, what="regression"))+
scale_linetype_manual(values=model.linetypes)+
geom_segment(aes(min.L, cost, xend=max.L, yend=cost,
showSelected=signal),
data=data.frame(intreg$selection, what="error"))+
geom_segment(aes(min.L, segments, xend=max.L, yend=segments,
showSelected=signal),
data=data.frame(intreg$selection, what="segments"))+
xlab("penalty value log(lambda)")+ # TODO: mathjax.
facet_grid(what~., scales="free"),

title="Max-margin interval regression")

animint2dir(intreg.errors, "intreg-errors")

##animint2gist(intreg.errors)

## No annotated regions!
mmir.segs <-
list(signal=ggplot()+
Expand Down
Loading