## Saturday, October 15, 2016

### Tikz Code for Drawing Metabolic Feedback Loops

Originally Posted on  by

I needed some figures that displayed a variety of different negative feedback loops so I created these using Tikz. Nothing particularly special. There are some absolute distances in the code which perhaps could be removed to make it more generic.

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[>=latex', node distance=2cm]
\node (Xo) {};
\node [right of = Xo] (S1) {\Large $x$};
\node [right of = S1] (S2) {};

\draw [->,ultra thick,blue] (Xo) -- node[above, black] {$v_1$} (S1);
\draw [->,ultra thick,blue] (S1) -- node[above, black] {$v_2$} (S2);

% Lets draw a line with a blunt end, -|
\draw [-|,ultra thick,blue]
% start in the middle of S2, and move down 2.75 mm
% ($...$) notation is used to add the coordinates
($(S1) + (0mm,-2.75mm)$)

% Now draw the line down by 3mm
% -- means draw to, + means move by
-- +(0,-3mm)
% Now move back to the left of S2
% The symbol -| means draw horizontal then vertical.
% If we used -- instead the line would be drawn
% diagonally to the reaction edge.
% (S1) is the center of the node. But we want the
% blunt end to end below the S1 line and
% half way to the left. The 10mm is half the node
% distance of 2cm, and 1mm is slightly below
% the reaction line.
-| ($(S1) - (10mm,1mm)$);
\end{tikzpicture}

\vspace{1cm}

\begin{tikzpicture}[>=latex', node distance=2cm]
\node (Xo) {};
\node [right of = Xo] (x1) {\Large $x_1$};
\node [right of = x1] (x2) {\Large $x_2$};
\node [right of = x2] (x3) {};

\draw [->,ultra thick,blue] (Xo) -- node[above, black] {$v_1$} (x1);
\draw [->,ultra thick,blue] (x1) -- node[above, black] {$v_2$} (x2);
\draw [->,ultra thick,blue] (x2) -- node[above, black] {$v_3$} (x3);

% Lets draw a line with a blunt end, -|, using the following coords
\draw [-|,ultra thick,blue]
% start in the middle of x2, and move down 2.75 mm
% ($...$) notation is used to add the coordinates
($(x2) + (0mm,-2.75mm)$)

% Now draw the line down by an additional 3mm
% -- means draw to, + means move by
-- +(0,-3mm)

% Now move back to the left of x2
% The symbol -| means draw horizontal then vertical.
% If we used -- instead the line would be drawn
% diagonally to the reaction edge.
% (S1) is the center of the node. But we want the
% blunt end to end below the S1 line and
% half way to the left. The 10mm is half the node
% distance of 2cm, and 1mm is slightly below
% the reaction line.
-| ($(x1) - (10mm,1mm)$);
\end{tikzpicture}

\vspace{1cm}

\begin{tikzpicture}[>=latex', node distance=2cm]
\node (Xo) {};
\node [right of = Xo] (x1) {\Large $x_1$};
\node [right of = x1] (x2) {\Large $x_2$};
\node [right of = x2] (x3) {\Large $x_3$};
\node [right of = x3] (x4) {};

\draw [->,ultra thick,blue] (Xo) -- node[above, black] {$v_1$} (x1);
\draw [->,ultra thick,blue] (x1) -- node[above, black] {$v_2$} (x2);
\draw [->,ultra thick,blue] (x2) -- node[above, black] {$v_3$} (x3);
\draw [->,ultra thick,blue] (x3) -- node[above, black] {$v_4$} (x4);

% Lets draw a line with a blunt end, -|
\draw [-|,ultra thick,blue]
($(x3) + (0mm,-2.75mm)$)
-- +(0,-3mm)
-| ($(x1) - (10mm,1mm)$);
\end{tikzpicture}

\vspace{1cm}

\begin{tikzpicture}[>=latex', node distance=2cm]
\node (Xo) {};
\node [right of = Xo] (x1) {\Large $x_1$};
\node [right of = x1] (x2) {\Large $x_2$};
\node [right of = x2] (x3) {\Large $x_3$};
\node [right of = x3] (x4) {\Large $x_4$};
\node [right of = x4] (x5) {};

\draw [->,ultra thick,blue] (Xo) -- node[above, black] {$v_1$} (x1);
\draw [->,ultra thick,blue] (x1) -- node[above, black] {$v_2$} (x2);
\draw [->,ultra thick,blue] (x2) -- node[above, black] {$v_3$} (x3);
\draw [->,ultra thick,blue] (x3) -- node[above, black] {$v_4$} (x4);
\draw [->,ultra thick,blue] (x4) -- node[above, black] {$v_5$} (x5);

% Lets draw a line with a blunt end, -|
\draw [-|,ultra thick,blue]
($(x4) + (0mm,-2.75mm)$)
-- +(0,-3mm)
-| ($(x1) - (10mm,1mm)$);
\end{tikzpicture}

\vspace{1cm}

\begin{tikzpicture}[>=latex', node distance=2cm]
\node (Xo) {};
\node [right of = Xo] (x1) {\Large $x_1$};
\node [right of = x1] (x2) {\Large $x_2$};
\node [right of = x2] (x3) {\Large $x_3$};
\node [right of = x3] (x4) {};

\draw [->,ultra thick,blue] (Xo) -- node[above, black] {$v_1$} (x1);
\draw [->,ultra thick,blue] (x1) -- node[above, black] {$v_2$} (x2);
\draw [->,ultra thick,blue] (x2) -- node[above, black] {$v_3$} (x3);
\draw [->,ultra thick,blue] (x3) -- node[above, black] {$v_4$} (x4);

% Lets draw a line with a blunt end, -|
\draw [-|,ultra thick,blue] (10mm, -8mm)
-- +(0,6mm);
\node (x) at (10mm,-11mm) {\Large $x$};
\end{tikzpicture}

\end{document}