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]}-

## No comments:

Post a Comment