How to do it...

Follow these steps to get started:

  1. Let's start by doing some imports:
import osfrom IPython.display import Imageimport rpy2.robjects as robjectsimport pandas as pdfrom rpy2.robjects import pandas2rifrom rpy2.robjects import default_converterfrom rpy2.robjects.conversion import localconverter

We will be using pandas on the Python side. R DataFrames map very well to pandas.

  1. We will read the data from our file using R's read.delim function:
read_delim = robjects.r('read.delim')seq_data = read_delim('sequence.index', header=True, stringsAsFactors=False)#In R:# seq.data <- read.delim('sequence.index', header=TRUE, stringsAsFactors=FALSE)

The first thing that we do after importing is access the read.delim R function, which allows ...

Get Bioinformatics with Python Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.