Skip to content

Instantly share code, notes, and snippets.

@JungeAlexander
Last active August 29, 2015 14:02
Show Gist options
  • Save JungeAlexander/397e47bd00690b365bdd to your computer and use it in GitHub Desktop.
Save JungeAlexander/397e47bd00690b365bdd to your computer and use it in GitHub Desktop.
Sequence-structure alignment of a toy data set consisting of four homologous ncRNA sequences and their joint secondary structure. A small example for vector graphics programming in LaTeX using the tikz package.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
\documentclass{standalone} % Package 'standalone' allows to compile tikz images independently or to incorporate them into LaTeX documents
\usepackage{tikz}
\usetikzlibrary{matrix}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\begin{document}
\begin{tikzpicture}
[cons/.style={rounded corners},
high-cons/.style={cons, draw=red, fill=red!20},
mid-cons/.style={cons, draw=orange, fill=orange!20},
low-cons/.style={cons, draw=green, fill=green!20}]
% Sequence alignment as a matrix of nodes
\matrix (s) [matrix of nodes, row sep=.05em, column sep=.2em, ampersand replacement=\&] {
% 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
human \& \& U \& C \& G \& U \& C \& C \& C \& U \& U \& U \& U \& C \& G \& A \\% 1
chicken \& \& U \& G \& G \& A \& C \& C \& C \& A \& U \& U \& U \& C \& C \& A \\ % 2
mouse \& \& U \& C \& C \& A \& C \& C \& C \& - \& U \& U \& U \& G \& G \& A \\ % 3
pig \& \& U \& A \& C \& A \& C \& C \& - \& U \& U \& U \& U \& G \& U \& A \\ % 4
sec. structure \& \& ( \& ( \& ( \& ( \& . \& . \& . \& . \& . \& . \& ) \& ) \& ) \& ) \\ % 5
};
% Highlight conserved base pairs in different colors
\begin{pgfonlayer}{background}
% Opening brackets
\fill[high-cons] (s-1-3.north west) rectangle (s-4-3.south east);
\fill[low-cons] (s-1-4.north west) rectangle (s-4-4.south east);
\fill[mid-cons] (s-1-5.north west) rectangle (s-4-5.south east);
\fill[high-cons] (s-2-6.north west) rectangle (s-4-6.south east);
% Closing brackets
\fill[high-cons] (s-2-13.north west) rectangle (s-4-13.south east);
\fill[mid-cons] (s-1-14.north west) rectangle (s-4-14.south east);
\fill[low-cons] (s-1-15.north west) rectangle (s-4-15.south east);
\fill[high-cons] (s-1-16.north west) rectangle (s-4-16.south east);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment