2
$\begingroup$

What is the length of gene when calculating TPM (transcripts per million)? Assume I have a dataset matrix with k rows(each row is a gene) and n columns (each column is a sample), is there any way I could transfer the data set into TPM? Many thanks!

$\endgroup$
4
  • $\begingroup$ Trusted Platform Module? Total Productive Maintenance? Technology Park Malaysia? Come on, give us a clue! $\endgroup$
    – David
    Aug 14 '17 at 20:30
  • 1
    $\begingroup$ @David I am sorry, TPM is transcripts per million $\endgroup$
    – user133140
    Aug 14 '17 at 20:37
  • $\begingroup$ rna-seqblog.com/rpkm-fpkm-and-tpm-clearly-explained $\endgroup$
    – Joe Healey
    Aug 15 '17 at 16:43
  • $\begingroup$ Nice walkthrough, thanks! When I was using it for implementing it as a function, still I spotted a small error in the calculations. When normalizing for the gene counts, GeneB-rep3 should be 14 (not 35, which you get if you divide by the 2k). F (sorry, could not add as comment due to the newbie status ;) ) $\endgroup$ Jun 4 '18 at 10:28
1
$\begingroup$

Assume we have

$$ \: \: \begin{bmatrix} Gene \: Name & Rep1 \: Count & Rep2 \: Count & Rep3 \: Count \\ A \: (2kb) & 10 & 15 & 30 \\ B\: (5kb) & 25 & 25 & 70 \\C\: (2kb) & 6 & 10 & 17 \\D\: (8kb) & 1 & 1 & 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 & Rep1 \: Count & Rep2 \: Count & Rep3 \: Count \\ A \: (2kb) & \frac{10}{2} & \frac{15}{2} & \frac{30}{2} \\ B\: (5kb) & \frac{25}{5} & \frac{25}{5} & \frac{70}{5} \\C\: (2kb) & \frac{6}{2} & \frac{10}{2} & \frac{17}{2} \\D\: (8kb) & \frac{1}{8} & \frac{1}{8} & \frac{3}{8} \end{bmatrix} \: \:$$

yields

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

yields

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


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

$\endgroup$
9
  • $\begingroup$ Sorry, I didn't make it clear. what I have is the single RNA count data from cells. Each row is a gene, and each column is a different sample (or I should say different cell?). $\endgroup$
    – user133140
    Aug 15 '17 at 20:50
  • $\begingroup$ @user133140 It's okay, no worries. We're still talking about the same thing, and the steps provided in this answer still 100% apply. :) $\endgroup$
    – user22020
    Aug 15 '17 at 20:56
  • $\begingroup$ @user133140 "The entire dataset represents one sample, and each replicate (column) represents an identical copy of that sample." -- What I mean by that is, although you may have a different cell for each column, each of those cells are from the same cell line (sample) and should be identical copies of each other (or as close to it as possible). This is true for your case, yes? $\endgroup$
    – user22020
    Aug 15 '17 at 20:58
  • $\begingroup$ So, the gene length is not included in the data I got and I have to find the length of each gene somewhere else right? $\endgroup$
    – user133140
    Aug 15 '17 at 21:02
  • $\begingroup$ And if one element of the matrix is 0, then after doing this transformation, it is still 0. $\endgroup$
    – user133140
    Aug 15 '17 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.