Skip to content

Instantly share code, notes, and snippets.

View lgautier's full-sized avatar

Laurent Gautier lgautier

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.11.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from rpy2.robjects.packages import importr
In [2]: reticulate = importr('reticulate')
WARNING: The R package "reticulate" only fixed recently
an issue that caused a segfault when used with rpy2:
@lgautier
lgautier / multiproc_lab.py
Created January 3, 2020 23:02
"Lab" to show how to perform parallel R computing using `multiprocessing`.
import argparse
import multiprocessing as mp
import uuid
import rpy2.rinterface as ri
import rpy2.rinterface_lib.embedded
R_ID_TAG = '_rpy2_R_id_'
def print_setup(args):
@lgautier
lgautier / rpy2-ld-library-path.sh
Created December 31, 2019 17:55
Set LD_LIBRARY_PATH for rpy2 when R is in a non-system location
export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
@lgautier
lgautier / demo_benchmark_mashingp.sh
Last active January 30, 2017 04:37
Demo/benchmark mashing-pumpkins to build minhash sketches
#!/bin/sh
echo
echo '---------------'
echo ' test w/ FASTA '
echo '---------------'
testchrom=chr1.fa.gz
if [ ! -f "${testchrom}" ]; then
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
power <- function(x, n) {
# a not-so-useful reimplementation
x ^ n
}
square <- function(x) {
x^2
}
cube <- function(x) {
# This is a setup snippet for an ipython notebook.
# It requires the presence of variable 'setup_digest',
# defined in the cell controlling the setup.
if 'setup_digest' not in locals():
import rpy2
%load_ext rpy2.ipython
# pigheaded / slow rpy2 developpers,
# customize away:
from rpy2.robjects.conversion import ri2py
{
"metadata": {
"name": "",
"signature": "sha256:cd75955d68d7ca272ff32886ce865002acb49b25f2e1cfba237539e70925eeda"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@lgautier
lgautier / gist:955e14077322480803e2
Created September 30, 2014 02:36
rpy2 and HTML display in ipython
{
"metadata": {
"name": "",
"signature": "sha256:e814b7d85c1dc274b3c62ca6849951326dee84fa31b999f9735064f46fb45a7a"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [