## Saturday, June 17, 2017

### Another Inhibition Pathway Diagram using TikZ

Originally Posted on  by

Here is another pathway diagram I needed to draw using TikZ. In this case, I needed an inhibited step. This was more tricky because I needed the inhibition line to point midway to a reaction but without touching the reaction itself.

To solve this I had to ask StackOverflow and within 2 hours I had an answer. The linear portion of the pathway is straightforward:

\begin{tikzpicture}[>=latex',node distance = 2cm]

\node (S) {\scalebox{1.4}{$S$}};

\node [left of = S] (Xo) {};
\draw[->,line width = 1.2pt] (Xo) to node[above] {\scalebox{1.3}{$v_1$}} (S);

\node [right of = S] (P) {$P$};
\draw[->,line width = 1.2pt] (S) to node[below] {\scalebox{1.3}{$v_2$}} (P);

\node [right of = P] (X1) {};
\draw[->,line width = 1.2pt] (P) to node[above] {\scalebox{1.3}{$v_3$}} (X1);

\end{tikzpicture}

The question was how to draw the inhibition line from inhibitor I to reaction v2. The trick is to use the tikz calc extension package which can be used to do more advanced coordinate calculations.

\usetikzlibrary{calc}

The line to add that that will draw the vertical inhibition line is:

\draw[|-,line width=1.2pt] ([yshift=4pt]$(S)!.5!(P)$) –++(0,1.5cm)node[above]{$I$};

Let’s decompose this. The first two arguments in the \draw command [[|-,line width=1.2pt] simply set the arrow style (blunt end) and the line width. The second part specifies the coordinates of the line itself and the remainder node[above]{$I$}; indicates what text to draw and where to draw it relative to the line. The real meat is in the drawing line section, that is:

([yshift=4pt]$(S)!.5!(P)$) –++(0,1.5cm)

The basic syntax for a line coordinate is (x1,y1) — (x2,y2). In the example, there is a modification to this where the coordinate is specified as (x1,y1) — ++(x2,y2). The ++ means that the coordinate at x2,y2 is computed relative to x1,y1, that is the coordinate at x2,y2 is actually (x1,y1)+(x2,y2). The (0,1.5cm) then means that the coordinate for the end point has the same x coordinate but the y coordinate is displaced upwards by 1.5cm. Note that the tikz y coordinate is like a normal graph plotting axis.

The trickest bit is computing the starting point for the vertical line. Note that this has to be midpoint between nodes S and P.  This requires some coordinate calculations. The x,y coordinate is specified by $(S)!.5!(P)$). The bit in front, ([yshift=4pt], just moves the computed y coordinates up 4pts.

The text inside the  means that we are doing a coordinate calculation,ie $….$ represents a math calculation. (S) and (P) represent the coordinates of the nodes S and P respectively. The important bit is !.5!. The explanation point is a pathway modifier and can be put between two coordinates.

(S)!.5!(P) means compute the coordinate that is halfway between (S) and (P).

The last thing to add is that I noticed that the blunt end was a bit too sort. To widen the blunt end I used the arrow.meta extension package. This allows one to modify the size of the arrowheads, in this case I used the following to widen the blunt end to 5mm.

{|[width=5mm]}-

## Tuesday, June 13, 2017

### Drawing a Pathway Fragment with Inhibition using Tikz

Originally Posted on  by

Here is another quick pathway fragment I needed today. This won’t scale well because I’ve used some fixed dimensions eg the width of the lines and the size of the text. But these are easily adjusted if you want to size the figure differently. The node distance = 2.5cm gives the sizes for the arrows except for v3. One might be able to calculate the some of the fixed sizes based on the node distance but I didn’t have time to investigate this.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}[>=latex',node distance = 2.5cm]
\node (S) {\scalebox{1.4}{$S$}};

\node [left of = S] (Xo) {};
\draw[->,line width = 1.2pt] (Xo) to node[above] {\scalebox{1.3}{$v_1$}} (S);

\node [right of = S] (X1) {};
\draw[->,line width = 1.2pt] (S) to node[above] {\scalebox{1.3}{$v_2$}} (X1);

\node[above of = S, node distance = 1.5cm] (V3) {};
\draw[-|,line width = 1.2pt] (S) to (V3) {};

\node[left of = V3, node distance = 1.25cm] (Xa) {};
\node[right of = V3, node distance = 1.25cm] (Xb) {};
\draw[->,line width = 1.2pt] (Xa) to node[above] {\scalebox{1.3}{$v_3$}} (Xb);
\end{tikzpicture}
\end{document}

## Thursday, June 8, 2017

### Tikz Code for Drawing Metabolic Feedback Loops

Originally Posted on  by

I was in need of a diagram of a futile cycle. I tried illustrator but I didn’t have the right LaTeX fonts so the figure did blend well with the rest of the document. I decided to make one using TiKz. And here it is.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}

\begin{tikzpicture}[>=latex',node distance = 2.5cm]
\node (S2) {$S_2$};
\node [left of = S2] (S1) {$S_1$};

\node [left of = S1, node distance = 1.5cm] (Xo) {};
\draw[->,thick] (Xo) to node[above] {$v_1$} (S1);

\node [right of = S2, node distance = 1.5cm] (X1) {};
\draw[->,thick] (S2) to node[above] {$v_4$} (X1);

\draw [->,thick] (S2) to [bend left=40] node[below] {$v_3$} (S1);
\draw [->,thick] (S1) to [bend left=40] node[above] {$v_3$} (S2);
\end{tikzpicture}

\end{document}