A simple example. Calling Python from within R via the R-package rPython is fairly easy. However, very little documentation exists on this package, and some of the commands may appear quirky at first. Also, don’t confuse rPython with RPython (see capitals)! The paucity of written documentation on this package seems to scare away many biologists, […]
Archiv der Kategorie 'bioinformatics'
Concatenating .csv-files by column
A helper script in R I recently needed to concatenate multiple .csv-files, which displayed the same row names. The concatenated matrix would thus consist of columns from different files. To that end, I wrote the following R script. First, let us specify the input directory. inDir = “/home/user/csv_files/” outF = paste(inDir, “concatenated.csv”, sep=””) Second, let […]
Loading BEAST node statistics in R
The issue with hardcoding data formats Various phylogenetic analyses in R work on the ultrametric trees generated by the popular software BEAST. In order to load such trees (including their node metadata) into R, the R packages phyloch and, more recently, ips provide useful tree and data parsers. Specifically, the parsing of the input trees […]
CompoundLocations in Biopython
Compound but not complex The Biopython manual informs the alert reader that ‘join’ locations of EMBL/GenBank files can be handled by CompoundLocation objects. This class of objects is a special object class in Biopython and very straight forward to operate. Assume, for example, the following DNA sequence: >>> from Bio.Seq import Seq >>> s = […]
Phylogenetics and Rmpi – An Example
Better parallel than serial In one of my past projects, I implemented the usage of multiple CPUs for time-intensive phylogenetic computations. I hereby used the R library Rmpi for the coordination of parallel processes. Rmpi is an R wrapper for the MPI communications protocol. The speed gains that my code execution was experiencing through this […]
An example of commutative diagrams in LaTeX
Tricky at first, but immensely helpful. As I become more familiar with Latex, I realize how efficient this markup language is for generating publication-quality diagrams and figures. For a commutative diagram displaying the transition rates of plant leaf shapes, the following Latex code suffices to generate a clear and succinct graph. \documentclass[]{standalone} \usepackage{tikz-cd} \begin{document} \tikzcdset{every […]
Schematic of Plastid Genome in LaTeX
Professional graphics require code In order to visualize the location of oligonucleotide primers as well as structural rearrangements in plastid genomes, I wrote some Latex code. \documentclass[margin=10pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[line cap=rect,line width=3pt] \draw[] (0,0) circle [radius=8cm]; % Draw small intervals, label small intervals \foreach \angle [count=\xi, evaluate=\xi as \xx using int(\xi*10)] in {157.5,135,…,-157.5,-180}{ \draw[line width=1.5pt] […]
Correcting tRNA annotations
How to call the anticodon? Over the past few days I have been correcting genomic annotations using custom bash and Python code. One of the more interesting exercises has been the homogenization of the “product” tags for transfer RNAs, which provide information about the respective anticodon sequences. In the majority of databases familiar to me, […]
Displaying phylogeny over map
A brief, preliminary evaluation For the revision of a new manuscript, I needed to generate a figure, in which a phylogenetic tree is plotted over a geographic map. The tips of the tree shall hereby point to the distribution area of the taxa they represent on the underlying map. Lucky for me, Rod Page has […]
Trees Nex2Phy one-liner
Tree file format conversion for the efficient Today, I needed to convert a series of phylogenetic trees, which were stored in the common nexus format, into newick format. In order to do this efficiently, I wrote the following one-liner. Change into a directory containing your nexus-formatted tree files, then enter in your bash shell: R […]