Flexible token replay animation for process maps
Flexible token replay animation for process maps created through the processmapR package from the bupaR suite, which uses DiagrammeR and viz.js library to render process maps using GraphViz. ProcessanimateR adds a htmlwidget that uses SVG animations (SMIL) to create the animation. Sizes, colors, and the image used for tokens are customizable based on trace, event attributes, or a secondary data frame if an attribute does not change according to the original event log.
ProcessanimateR is not yet available on CRAN. Please use the remotes package or similar means to install it directly from source.
There are two main functions:
ianimate_process (interactive version).
We use the
patients event log provided by the
library(processanimateR) library(eventdataR) data(patients)
A basic animation with static color and token size:
Default token color, size, or image can be changed as follows:
animate_process(patients, token_size = 2) animate_process(patients, token_color = "red") animate_process(patients, token_image = "https://upload.wikimedia.org/wikipedia/en/5/5f/Pacman.gif", token_size = 15)
Dynamic token colors or sizes based on event attributes can be configured:
animate_process(add_token_color(patients, "time", "color"), token_color = "color") animate_process(add_token_color(patients, "employee", "color", color_mapping = scales::col_factor("Paired", patients$employee)), token_color = "color")
It is also possible to use a secondary data frame to color the tokens irregardless of the event times. This can be useful if measurement are taken throughout a process, but the measurement event itself should not be included in the process map. For example, the lactic acid measurements of the
sepsis data could be used in that way:
library(dplyr) data(sepsis) # Extract only the lacticacid measurements lactic <- sepsis %>% mutate(lacticacid = as.numeric(lacticacid)) %>% filter_activity(c("LacticAcid")) %>% as.data.frame() %>% select("case" = case_id, "time" = timestamp, lacticacid) # Create a numeric color scale cscale <- scales::col_numeric("Oranges", lactic$lacticacid , na.color = "white") # Create colors data frame for animate_process lacticColors <- lactic %>% mutate(color = cscale(lacticacid)) # Remove the measurement events from the sepsis log sepsisBase <- sepsis %>% filter_activity(c("LacticAcid", "CRP", "Leucocytes", "Return ER", "IV Liquid", "IV Antibiotics"), reverse = T) %>% filter_trace_frequency(percentage = 0.95) animate_process(sepsisBase, token_color = lacticColors, animation_mode = "relative", animation_duration = 600)
There is also an interactive variant that starts a Shiny web-application. It expects that attributes are of an appropriate data type to choose a good color scale.
library(edeaR) library(dplyr) ianimate_process(sepsis %>% filter_trace_frequency(percentage = 0.3) %>% # we fix the datatype of some of the attributes to allow proper rendering of the token color # the token size option currently only support numeric attributes mutate_at(c("lacticacid", "leucocytes", "crp", "age"), as.numeric) %>% mutate_at(c("disfuncorg", "sirscriteria2ormore", "infectionsuspected"), as.logical))
This package makes use of the following libraries:
This software is licensed under the MIT License - see the LICENSE file for details
This software was developed in the HUMAN project, which has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement no. 723737 (HUMAN)