RGUI
description
Transcript of RGUI
Developing R
Graphical User
Interfaces
SETIA PRAMANA
Outlines
• Motivations
• R GUI• IsoGeneGUI
• neaGUI
• How to develop an R GUI?• Independent GUI
• Embedded GUI (RcmdrPlugin.BiclustGUI)
• Summary
2R
GU
I
R Pros and Con
Free open source and widely used.
Can be integrated with other languages (C/C++, Java).
R can interact with many data sources and other statistical packages (SAS, Stata, SPSS, and Minitab).
For the high performance computing task multiple cores, either on a single machine or across a network.
3R
GU
I
R: A Command line
interface (CLI)
Users type commands to perform a statistical analysis.
Is preferred for advanced users allows direct control, more accurate, flexible and the analysis is reproducible.
4R
GU
I
R: A Command line
interface (CLI)
Requires good knowledge of the language difficult for beginners or less frequent users.
R provides tools for building GUIs RGUI
5R
GU
I
Graphical User Interface
(GUI)
A tool to provide an event-driven user interface.
An extra layer between the user and the program
Based on menus, dialog boxes, icons and controls.
Window, icon, menu, and pointing device (WIMP) paradigm
6R
GU
I
R GUI Projects
Integrated development environment (IDE)/Script Editors aimed to provide feature-rich environments to edit R scripts and code: Rstudio (www.rstudio.com), and architect (www.Openanalytics.eu)
Web based application: the Rweb (Banfield, 1999), R.Net (www.u.arizona.edu/~ryckman/Net.php), or gWidgetsWWW (Verzani, 2012).
7R
GU
I
R Studio
Download from
Rstudio.com
Powerfull IDE
(Integrated
Development
Environment) for
R.
R G
UI
8
R GUI Projects
Python: OpenMeta-Analyst (Wallace et al, 2012) Java: JGR (Java GUI for R), Deducer (Fellows,
2012), and Glotaran (Snellenburg, 2012). Php: R-php (http://dssm.unipa.it/R-php/) Shiny C++, C# Other extensions connect R to graphical
toolboxes for developing menus and dialog boxes: Tcltk, Gtk.
We focus on Tcltk and Shiny
9R
GU
I
R GUI Tcl/Tk
Most commonly used: easy, no additional software needed and ready to be used in R (tcltk package)
R-Tcl/Tk interface from the tcltk package (Dalgaard, 2001 and Welch, 2000).
The tcltk package allows the use of the Tk(toolkit) graphical user interface elements within R by embedding Tk commands into the R language.
10R
GU
I
RGUI Developed using
tcltk R G
UI
11
R GUI Tcl/Tk
R GUIs developed by using tcl/tk or RGtk:• LimmaGUI (Wettenhall and Smyth, 2004),
• LMMNorm (Haldermans, 2010),
• IsoGeneGUI (Pramana et al. , 2010, 2012)
• NeaGUI (Pramana et.al, 2013)
• Rcommander (Fox, 2005)
• RcmdrPlugin.biclustGUI (Pramana, 2011)
12R
GU
I
R GUI Tcl/Tk
R GUIs developed by using tcl/tk or RGtk:• LimmaGUI (Wettenhall and Smyth, 2004),
• LMMNorm (Haldermans, 2010),
• IsoGeneGUI (Pramana et al. , 2010, 2012)
• NeaGUI (Pramana et.al, 2013)
• Rcommander (Fox, 2005)
• RcmdrPlugin.biclustGUI (Pramana, 2011)
13
Independent
GUI
R G
UI
R GUI Tcl/Tk
R GUIs developed by using tcl/tk or RGtk:• LimmaGUI (Wettenhall and Smyth, 2004),
• LMMNorm (Haldermans, 2010),
• IsoGeneGUI (Pramana et al. , 2010, 2011)
• NeaGUI (Pramana et.al, 2013)
• Rcommander (Fox, 2005)
• RcmdrPlugin.biclustGUI (Pramana, 2011)
14
Embeded
GUI
R G
UI
neaGUI
To help interpretation of differentially expressed (DE) genes in context of biological processes, pathways and networks.
Perform network enrichment analysis.
Input: DE genes
Output: enriched pathways statistics based on gene interaction networks.
15R
GU
I
neaGUI Output 16R
GU
I
neaGUI Output 17R
GU
I
RGUI: RCommander
Rcommander.com
Helpful for R
beginner
Install inside R
R G
UI
18
RGUI using C#: Wires
Developed by STIS
students
For Spatial Data
Analysis
Still developing…
R G
UI
19
RGUI using C#: WiresR
GU
I20
RGUI: Web Based App
R G
UI
21
WebBUGS
Conducting
Bayesian Statistical
Analysis Online
Combines
OpenBUGS and R
www.webbugs.psychstat.org
R G
UI
22
RGUI: Shiny
A new package from Rstudio to build
interactive web applications with R.
Really Easy!
Build useful web applications with only a
few lines of code—no JavaScript required.
Self learning: http://shiny.rstudio.com/
http://www.showmeshiny.com/
R G
UI
23
RGUI using Shiny: FAST
Figure 5. FAST main page
Figure 7. Cluster Analysis in FAST
24
RGUI, How to Build One?
Choose one of RGUI categories, and tools to be used (tcltk, java, etc.) which suit with the package purpose.
Make sketches of the window box and consider:
• Input
• Options
• Output
Can all functions be run in a single window (e.g. neaGUI)? Or a main window with menu (IsoGeneGUI) and separate dialog boxes are needed?
25R
GU
I
Create Main Window
tt <- tktoplevel()
tkwm.title(tt,"My New GUI")
topMenu <- tkmenu(tt)
tkconfigure (tt,menu=topMenu)
fileMenu <- tkmenu(topMenu,tearoff=FALSE)
openMenu <- tkmenu(topMenu,tearoff=FALSE)
tkadd(openMenu,"command",label="xls file",
command= getXls)
tkadd(openMenu,"command",label="text file”)
26R
GU
I
Create Main Window
tt <- tktoplevel()
tkwm.title(tt,"My New GUI")
topMenu <- tkmenu(tt)
tkconfigure (tt,menu=topMenu)
fileMenu <- tkmenu(topMenu,tearoff=FALSE)
openMenu <- tkmenu(topMenu,tearoff=FALSE)
tkadd(openMenu,"command",label="xls file",
command= getXls)
tkadd(openMenu,"command",label="text file”)
27
getXls <- function () {
fileName <- tclvalue(tkgetOpenFile(filetypes=
gettext(' {"Excel Files" {".xls"}} {"All Files"
{"*"}}')))
data <- get( fileName) }
R G
UI
Create Main Window
tt <- tktoplevel()
tkwm.title(tt,"My New GUI")
topMenu <- tkmenu(tt)
tkconfigure (tt,menu=topMenu)
fileMenu <- tkmenu(topMenu,tearoff=FALSE)
openMenu <- tkmenu(topMenu,tearoff=FALSE)
tkadd(openMenu,"command",label="xls file",
command= getXls)
tkadd(openMenu,"command",label="text file")
tkadd(fileMenu,"cascade",label="Open data",
menu=openMenu)
tkadd(fileMenu,"cascade",label="Edit data")
tkadd(fileMenu,"command",label="Quit",command=function() tkdestroy(tt))
tkadd(topMenu,"cascade",label="File",menu=fileMenu)
tkadd(topMenu,"cascade",label="Help")
tkfocus(tt)
28R
GU
I
Create a Dialog Box
Create the windowrequire(tcltk)
tt<-tktoplevel()
tkwm.title(tt,"Input Window")
Edit BoxName <- tclVar("")
entry.Name <-tkentry(tt,width="20",
textvariable=Name)
tkgrid(tklabel(tt,text="Name:"), entry.Name)
29R
GU
I
Create a Dialog Box
Radio buttonrb1 <- tkradiobutton(tt)
rb2 <- tkradiobutton(tt)
rbValue <- tclVar("Male")
tkconfigure(rb1,variable=rbValue,
value="Male")
tkconfigure(rb2,variable=rbValue,
value="Female")
tkgrid(tklabel(tt,text="Sex:"))
tkgrid(tklabel(tt,text="Male"),rb1)
tkgrid(tklabel(tt,text="Female"),rb2)
30R
GU
I
Create a Dialog Box
List box with scroll barscr <- tkscrollbar(tt, repeatinterval=5,
command=function(...) tkyview(tl,...))
tl<-tklistbox(tt,height=4,selectmode="single",
background="white")
tkgrid(tklabel(tt,text="City:"), tl, scr)
city <- c("Brussels","Jakarta", "London",
"Stockholm")
for (i in (1:4)) tkinsert(tl,"end",city [i])
tkselection.set(tl,1)
tkgrid.configure(scr,rowspan=4,sticky="nsw")
31R
GU
I
Create a Dialog Box
OK buttonOK.but <-tkbutton(tt,text=" OK ",
command=OnOK)
tkgrid(OK.but)
tkgrid.configure(OK.but)
tkfocus(tt)
32R
GU
I
Run the function (OK
button)
33R
GU
I
Run the function (OK
button)
OnOK <- function() {
NameVal <- tclvalue(Name)
rbVal <- as.character(tclvalue
(rbValue))
if (rbVal=="Male") pref = "Mr."
if (rbVal=="Female") pref = "Mrs.“
cityChoice <- city [as.numeric(tkcurselection(tl))+1]
tkdestroy(tt)
msg <- paste("Good morning ",pref , NameVal , "from", cityChoice, sep=" ")
tkmessageBox(message=msg)
}
34R
GU
I
Summary
A GUI could help novice R users for utilizing all the power of R.
Increase the use of our package/methods especially by scientists with no/less knowledge of R.
35R
GU
I
Summary
A GUI could help novice R users for utilizing all the power of R.
Increase the use of our package/methods especially by scientists with no/less knowledge of R.
Things to consider in developing a GUI:
• Type of GUI (spreadsheets, menu/dialog boxes),
• Tool to develop (tcltk, java)
• Embedded/Independent.
• Single/Multi dialog boxes
36R
GU
I
Summary
Make sure GUI is simple and user friendly.
Design Development Trial Packaging and Storing
37R
GU
I