Making Python Objects R-like with PyR

Abstract

R and Python compose the fundamental tools used by data scientists across industries including pharma and biotech. With a rich set of analytical packages in both language domains, analysts who are able to work with both possess a significantly larger selection of tools in their toolbox compared to single language analysts. To consolidate these camps, the reticulate package has played a fundamental and critical role in enabling the direct use of Python from the R console. Additionally, integration of Python capabilities into the RStudio IDE allows single point of access to both languages and their integration. Once a Python module or class is imported, however, accessing methods and attributes from R requires the usage of the $ operator in a way that is not completely consistent with typical R code and creates challenges for integration of objects or models developed in both languages. The result can become a mixture of R-esque and Python-like code that can resemble two different language structures, despite the efforts to combine them. In order to provide analysts an environment in which Python modules and classes can be used as though they were R-native objects, SomaLogic developed the PyR package. This package consists of a set of Python classes that wrap Python objects and a set of S3 methods providing wrappers to those imported classes. A model object hierarchy defining the expected interfaces for the Python components provides an overall architecture enabling introduction of new Python capabilities in a way that appears to the user to be native R code.

Type
Publication
Presented at 2021 Conference

Related