RGUI

37
Developing R Graphical User Interfaces SETIA PRAMANA

description

RGUI

Transcript of RGUI

Page 1: RGUI

Developing R

Graphical User

Interfaces

SETIA PRAMANA

Page 2: RGUI

Outlines

• Motivations

• R GUI• IsoGeneGUI

• neaGUI

• How to develop an R GUI?• Independent GUI

• Embedded GUI (RcmdrPlugin.BiclustGUI)

• Summary

2R

GU

I

Page 3: RGUI

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

Page 4: RGUI

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

Page 5: RGUI

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

Page 6: RGUI

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

Page 7: RGUI

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

Page 8: RGUI

R Studio

Download from

Rstudio.com

Powerfull IDE

(Integrated

Development

Environment) for

R.

R G

UI

8

Page 9: RGUI

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

Page 10: RGUI

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

Page 11: RGUI

RGUI Developed using

tcltk R G

UI

11

Page 12: RGUI

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

Page 13: RGUI

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

Page 14: RGUI

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

Page 15: RGUI

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

Page 16: RGUI

neaGUI Output 16R

GU

I

Page 17: RGUI

neaGUI Output 17R

GU

I

Page 18: RGUI

RGUI: RCommander

Rcommander.com

Helpful for R

beginner

Install inside R

R G

UI

18

Page 19: RGUI

RGUI using C#: Wires

Developed by STIS

students

For Spatial Data

Analysis

Still developing…

R G

UI

19

Page 20: RGUI

RGUI using C#: WiresR

GU

I20

Page 21: RGUI

RGUI: Web Based App

R G

UI

21

Page 22: RGUI

WebBUGS

Conducting

Bayesian Statistical

Analysis Online

Combines

OpenBUGS and R

www.webbugs.psychstat.org

R G

UI

22

Page 23: RGUI

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

Page 24: RGUI

RGUI using Shiny: FAST

Figure 5. FAST main page

Figure 7. Cluster Analysis in FAST

24

Page 25: RGUI

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

Page 26: RGUI

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

Page 27: RGUI

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

Page 28: RGUI

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

Page 29: RGUI

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

Page 30: RGUI

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

Page 31: RGUI

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

Page 32: RGUI

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

Page 33: RGUI

Run the function (OK

button)

33R

GU

I

Page 34: RGUI

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

Page 35: RGUI

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

Page 36: RGUI

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

Page 37: RGUI

Summary

Make sure GUI is simple and user friendly.

Design Development Trial Packaging and Storing

37R

GU

I