Skip to content

Commit

Permalink
Merge branch 'main' of github.com:saeyslab/polygloty
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Sep 4, 2024
2 parents 75fd179 + e395e04 commit e0b48d3
Showing 1 changed file with 85 additions and 23 deletions.
108 changes: 85 additions & 23 deletions slides/slides.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,67 @@ exectute:
echo: true
---

Todo: refer to sc best practices
Todo: paper Lior Pachter differences R & Python

# Introduction

# File formats
1. How do you interact with a package in another language?
2. How do you make you package useable for developers in other languages?

# Calling Python from R and vice versa
or: in-memory interoperability
We will be focusing on R & Python

## Overview
reticulate:
# How do you interact with a package in another language?

1. File format based interoperability
2. In-memory interoperability

# How do you make your package useable for developers in other languages?

1. Package-based interoperability
2. Best practices

## Package-based interoperability
or: the question of reimplementation.

1. Call Python in R
2. embed a Python session within your R session
Consider the pros:
- Discoverability
- Can your package be useful in other domains?
- Very user friendly

basilisk allows managing Python environments within the BioConductor ecosystem
Consider the cons:
- Think twice: is it worth it?
- It's a lot of work
- How will you keep it up to date?
- How will you ensure parity?

## Best practices
1. Work with the standards
2. Work with matrices, arrays and dataframes
3. Provide vignettes on interoperability

rpy2:
# File format based interoperability

1. Call R in Python
2. run R in a Python process
# In-memory interoperability
Calling Python in an R environment and vice versa.
- No need to write out datasets.
- Best suited to calling functions

rpy2 and reticulate

## Overview

advantages & disadvantaes

rpy2
1. overview
2. usage
3. pitfalls

reticulate:
1. overview
2. usage
3. pitfalls

## in-memory interoperability advantages
- no need to write & read results
Expand All @@ -53,25 +94,46 @@ rpy2:
- ensure that the method accepts this
- you need to be familiar with using & managing both environments
- data duplication
- you need to manage the environments

## accessing R from Python
## rpy2
Accessing R from Python

rpy2
Example: code block

`rpy2.rinterface`, the low-level interface
`rpy2.robjects`, the high-level interface

Example for calling R functions

Example for conversion of arrays

## rpy2
Conversion:
numpy & pandas

Example: code block

sparse matrices: anndata2ri

## rpy2

Jupyter(like) notebooks:
make use of the Magic command interface

`%load_ext rmagic`
`%R -i input -o output`

Jupyter notebooks:
- Use IPython magic interface
- most useful for matrices & arrays
example

e.g. `%%R -i input -o output`
## rpy2

- use anndata2ri: converts anndata objects to SingleCellExperiment
1. let your method be run with matrices and arrays as input
2. anndata2ri
?

## accessing Python from R
reticulate
basilisk
## reticulate

# Package-based interoperability
or: the question of reimplementation

# Workflows

Expand Down

0 comments on commit e0b48d3

Please sign in to comment.