1 / 33

Calling R from .NET: a case-study using Rapid NCA, the non-compartmental analysis workflow tool

Calling R from .NET: a case-study using Rapid NCA, the non-compartmental analysis workflow tool. Chris Campbell. Agenda. Using .NET Identify Opportunity Design Solution Develop Solution Connections with R.NET Complete & Deploy T ool. Using .NET What is .NET?.

banyan
Download Presentation

Calling R from .NET: a case-study using Rapid NCA, the non-compartmental analysis workflow tool

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Calling R from .NET: a case-study using Rapid NCA, the non-compartmental analysis workflow tool Chris Campbell

  2. Agenda • Using .NET • Identify Opportunity • Design Solution • Develop Solution • Connections with R.NET • Complete & Deploy Tool

  3. Using .NETWhat is .NET? • Object-oriented environment to develop applications • Safe execution environment • Choice of programming languages • Framework consisting of: • runtime • class library • Developed with Visual Studio

  4. Using .NETVisual Studio • A graphical programming tool (IDE) • Also, Visual Studio Express is a free version

  5. Using .NETChoice of languages • Tried and tested languages • C# is the main one • F# is a functional language (not a steep learning curve if you know OCaml) • Knowledge of XAML (a Microsoft declarative XML language) is required for state of the art graphics • C++/CLI useful for legacy and bespoke parallel processing (including GPGPU) • Other possibilities.. • Vb.Net is very like C# (no advantage over it) • Third parties have added languages to the CLI platform

  6. Using .NETAn “ajar source” platform • Not exactly open source, but… • Most CLI third party languages are open • C# and VB.Net are not – but many open source projects based on them • Microsoft have made F# open source • There are free (Express) versions of Visual Studio for the languages • Compiler is free and other editors / IDEs are available (but not usually preferred by developers)

  7. Using .NETPerformance and Computation • Performance is very good • On graphics (millions of data points will plot with ease and zoom smoothly) • Computation is fast enough in C#, calling R adds little overhead • Standard Maths library is limited; third parties and MS maths for “drawing” are better • Data parallel computation is possible on the desktop (GPGPU) • F# provides further “big data” capabilities

  8. A Project Case Study

  9. Identify Opportunity • Where can repetitive tasks be automated? • How can regular outputs be generated? • How can we make methods and techniques more accessible to colleagues?

  10. Identify Opportunity • Customer needed to send monthly reports to dozens of trial centres • Small team, so time limited • Normally simple non-compartmental analysis, standard report

  11. Design Solution • What is the simplest way for the task to be performed? • Which steps can be eliminated? • What are barriers to understanding for users?

  12. Design SolutionStreamline WorkflowWhat is Needed? • Import data to analysis software • Map variables • Select units • Select non-compartmental • Select model • Select interpolation • Select rules for BLQ • Select terminal phase calculation method • Perform analysis • Choose partial area • Export results • Export plots • Write report • Format report

  13. Design SolutionAnalysis Engine using R

  14. Let’s get .Net technical..

  15. Connections with R.NET • What will be provided to R? • What will be returned from R? • What happens if something goes wrong?

  16. Connections with R.NETUsing the R Service • R.NET allows R calls to be submitted to an R service • R.NET is not the only option • R.NET connects to R down to Expression level • So objects can effectively be passed back into .NET • Recommend a robust .Net framework to do this

  17. _pluginsManager = newRPluginManager(PluginLocation, RLocation); _pluginsManager.SetActivePlugin(); _session = _pluginsManager.GetSession(); boolsessionOk = _pluginsManager.TryMakeSession(out_session); Connections with R.NET • R is efficiently accessed, via R.Net (as pictured in Visual Studio) via a Plugin (as above)

  18. Connections with R.NET“Engineer’s” framework

  19. Connections with R.NETRobustness • Function may be passed data outside it’s anticipated structure > checkOrderedVector(c(0, 1, 3, 2, 4), + description = "Time") Error in checkOrderedVector(c(0, 1, 3, 2, 4), description = "Time") : Error: Time is not ordered. Actual value is 0 1 3 2 4 >

  20. Connections with R.NETRobustness • The tool expects a certain return object • An error in an R call should be trapped by the communicating function • Return object passed as normal • An error checking element of the return object can report information about the error > check01 <- try(checkOrderedVector(Time, + description = "Time"), silent = TRUE) >

  21. _pluginsManager = newRPluginManager(PluginLocation, RLocation); _pluginsManager.SetActivePlugin(); _session = _pluginsManager.GetSession(); boolsessionOk = _pluginsManager.TryMakeSession(out_session); _session.SetNumericSymbol("TimePtVector", CheckTimePointData(toAnalyse)); _session.SetNumericSymbol("ConcVector", CheckConcentrationPointData(toAnalyse)); varevalString = string.Format("ncaAnalysis(TimePtVector, ConcVector, … MathEngineDataRowDto<double> ncaGetBack = _session.PerformNumericEvaluation(evalString, "ROutput_Error"); _lastErrors = ncaGetBack.ErrorStrings; _session.FlushConsole(); _pluginsManager.RelinquishSession(); Connections with R.NETUsing the framework

  22. A Rapid Solution

  23. Complete & Deploy Tool • Can users understand how to use tool? • How confident are we in tool output?

  24. Deploy Tool

  25. Data Import

  26. Map Variables

  27. Review Analysis

  28. Review Grouping

  29. Generate Report

  30. Select Report Type

  31. Add Group Comments

  32. View Report

  33. Conclusions • Great graphical interfaces can be built using .NET • Intuitive interactive features are available • R.NET allows R analysis to be accessed as a service • Good coding practice will ensure application is robust • Work on a well engineered framework will be rewarded with desktop solutions created at high speed

More Related