Skip to content

Instantly share code, notes, and snippets.

View lgautier's full-sized avatar

Laurent Gautier lgautier

View GitHub Profile
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lgautier
lgautier / gist:5426275
Created April 20, 2013 15:05
ipython notebook (Python 3.3.1, R-3.0.0, rpy2-2.4.0-dev
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@lgautier
lgautier / rpy2_ggplot2
Last active December 15, 2015 01:29
rpy2: ggplot2 figures from pandas dataframes
{
"metadata": {
"name": "Untitled0"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@lgautier
lgautier / hctree.jl
Created December 27, 2012 14:56
Hierarchical clustering with the Julia-R bridge
require("Rif")
using Rif
initr()
m = R("matrix(rnorm(100), nrow=20)")
# A Julia matrix mj of type (Array{Float64, 2}) could
# be used with
# m = RArray{Float64,2}(mj)
d = call(R("dist"), [m])
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