napistu.rpy2.callr

Functions

bioconductor_org_r_function(object_type, species)

Bioconductor Organism R Function

get_napistu_r([r_paths])

Get Napistu R package.

get_rbase([r_paths])

Get the base R package.

pandas_to_r_dataframe(df)

Convert a pandas dataframe to an R dataframe.

r_dataframe_to_pandas(rdf)

Convert an R dataframe to a pandas dataframe.

napistu.rpy2.callr._get_py2rpy_pandas_conv()

Get the py2rpy arrow converter for pandas.

This is a high-performance converter using the rpy2-arrow functionality: https://rpy2.github.io/rpy2-arrow/version/main/html/index.html

Returns:

The converter function

Return type:

Callable

napistu.rpy2.callr.bioconductor_org_r_function(object_type: str, species: str, r_paths: list[str] | None = None)

Bioconductor Organism R Function

Calls “bioconductor_org_function” from the R cpr package to pull a mapping object out of a species specific library.

Parameters: object_type (str): Type of function to call species (str): Species name r_paths (list[str], optional): Paths to add to .libPaths() in R.

Alternatively consider setting the R_HOME env variable.

Returns: pd.DataFrame or a function for non-tabular results

napistu.rpy2.callr.get_napistu_r(r_paths: list[str] | None = None)

Get Napistu R package.

Parameters:

r_paths (list[str], optional) – Paths to add to .libPaths() in R

Returns:

napistu.r R package

napistu.rpy2.callr.get_rbase(r_paths: list[str] | None = None)

Get the base R package.

Parameters:

r_paths (list[str], optional) – Optional additional r_paths. Defaults to None.

Returns:

Base R package

napistu.rpy2.callr.pandas_to_r_dataframe(df: DataFrame)

Convert a pandas dataframe to an R dataframe.

This uses the rpy2-arrow functionality to increase the performance of conversion by orders of magnitude.

Parameters:

df (pd.DataFrame) – Pandas dataframe

Returns:

R dataframe

Return type:

rpy2.robjects.DataFrame

napistu.rpy2.callr.r_dataframe_to_pandas(rdf)

Convert an R dataframe to a pandas dataframe.

Parameters:

rdf (rpy2.robjects.DataFrame) – R dataframe

Returns:

Pandas dataframe

Return type:

pd.DataFrame