What is the length of gene when calculating TPM (transcripts per million)
Assume we have 

$$ \: \: \begin{bmatrix} Gene \: Name &amp; Rep1 \: Count &amp; Rep2 \: Count &amp; Rep3 \: Count \\  A \: (2kb) &amp; 10 &amp; 15 &amp; 30 \\ B\: (5kb) &amp; 25 &amp; 25 &amp; 70 \\C\: (2kb) &amp; 6 &amp; 10 &amp; 17 \\D\: (8kb) &amp; 1 &amp; 1 &amp; 3 \end{bmatrix} \: \:$$ 


To transform this into TPM format, we need to normalize for gene length, and then normalize for gene depth, in that order. 





Normalizing for gene length..


Step(s) To Perform: Divide each replicate count by the length of its respective gene.


For $Gene A$, it has a length of $2kb$ (kilobases), with replicate counts $10, 15,$ and $30$. Performing this operation on the entire table,

$$ \: \: \begin{bmatrix} Gene \: Name &amp; Rep1 \: Count &amp; Rep2 \: Count &amp; Rep3 \: Count \\  A \: (2kb) &amp; \frac{10}{2} &amp; \frac{15}{2} &amp; \frac{30}{2} \\ B\: (5kb) &amp; \frac{25}{5} &amp; \frac{25}{5} &amp; \frac{70}{5} \\C\: (2kb) &amp; \frac{6}{2} &amp; \frac{10}{2} &amp; \frac{17}{2} \\D\: (8kb) &amp; \frac{1}{8} &amp; \frac{1}{8} &amp; \frac{3}{8} \end{bmatrix} \: \:$$

yields 

$$ \: \: \begin{bmatrix} Gene \: Name &amp; Rep1 \: Count &amp; Rep2 \: Count &amp; Rep3 \: Count \\  A \: (2kb) &amp; 5 &amp; 7.5 &amp; 15 \\ B\: (5kb) &amp; 5 &amp; 5 &amp; 35 \\C\: (2kb) &amp; 3 &amp; 5 &amp; 8.5 \\D\: (8kb) &amp; .125 &amp; .125 &amp; .375 \end{bmatrix} \: \:$$





Normalizing for gene depth..


Step(s) To Perform: 1) Sum all counts within each replicate column; 2) Divide each column sum by the desired depth (this yields scaling factors); 3) Divide each replicate count within a column by its respective scaling factor.


$Rep1$


Sum: $5 + 5 + 3 + .125 = 13.125$
Scaling Factor:  $\frac{13.125}{1,000,000} = 1.325 \times 10^{-5}$


$Rep2$


Sum: $7.5 + 5 + 5 + .125 = 17.625$
Scaling Factor: $\frac{17.625}{1,000,000} = 1.7625 \times 10^{-5}$


$Rep3$


Sum: $15 + 35 + 8.5 + .375 = 58.875$
Scaling Factor: $\frac{13.125}{1,000,000} = 5.8875 \times 10^{-5}$




Applying these values to the table, 

$$ \: \: \begin{bmatrix} Gene \: Name &amp; Rep1 \: Count &amp; Rep2 \: Count &amp; Rep3 \: Count \\  A \: (2kb) &amp; \frac{5}{1.325 \times 10^{-5}} &amp; \frac{7.5}{1.7625 \times 10^{-5}} &amp; \frac{15}{5.8875 \times 10^{-5}} \\ B\: (5kb) &amp; \frac{5}{1.325 \times 10^{-5}} &amp; \frac{5}{1.7625 \times 10^{-5}} &amp; \frac{35}{5.8875 \times 10^{-5}} \\C\: (2kb) &amp; \frac{3}{1.325 \times 10^{-5}} &amp; \frac{5}{1.7625 \times 10^{-5}} &amp; \frac{8.5}{5.8875 \times 10^{-5}} \\ D\: (8kb) &amp; \frac{.125}{1.325 \times 10^{-5}} &amp; \frac{.125}{1.7625 \times 10^{-5}} &amp; \frac{.375}{5.8875 \times 10^{-5}} \end{bmatrix} \: \: $$

yields

$$ \: \: \begin{bmatrix} Gene \: Name &amp; Rep1 \: Count &amp; Rep2 \: Count &amp; Rep3 \: Count \\  A \: (2kb) &amp; 377358.49 &amp; 425531.91 &amp; 254777.07 \\ B\: (5kb) &amp; 377358.49 &amp; 283687.94 &amp; 594479.83 \\C\: (2kb) &amp; 226415.09 &amp; 283687.94 &amp; 144373.67 \\ D\: (8kb) &amp; 9433.96 &amp; 7092.20 &amp; 6369.43 \end{bmatrix} \: \:$$ 



The dataset is now TPM formatted, which offers an easier analysis of read proportions throughout the sample.