This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Quick code question in TPM conversion from raw counts RNAseq

I am using the below code to calculate TPM which I found on GitHub. Can anyone just confirm please what the '2' in the tpms code equates to please? I am new to RNAseq and normalisation analysis and what to understand the code fully.

Thank you kindly

`tpm <- function(counts, lengths) { rate <- counts / lengths rate / sum(rate) * 1e6 }

tpms <- apply(counts, 2, function(x) tpm(x, genes$Length))`

rnaseq tpm r

1 answer

It is the argument (MARGIN) of the apply function; i.e. apply the tpm function to each column (2) of a data frame or matrix

Thank you for your kind reply, that is most helpful, thank you, Victoria

Log in to answer this question.