# Convert TPM-normalized matrices back to UMI in python

I want to process a plenty of scRNAseq datasets in python, and I want to run TMM normalization on all of them. Unfortunately some of them are already normalized with TPM method. Is there a way of either converting it back to UMImatrix, so that TMM normalization could be applied to it or could we just apply TMM directly to TPM-normalized matrices? Would that work? Any suggestions would be greatly appreciated.

## 1 Answer

It depends what your downstream requirement is. If you want to do count based statisitcs, then you definately shouldn't just do TMM normalisation on the TPM data as count statistics only work on real count data.

If you are intersted in doing something like clustering or dimensionality reduction, then I wouldn't use TMM, I'd probably use rLog, which includes normalisation.

You can have a crack at converting the TPMs back to something that looks like counts, but I not sure how well its going to work. To convert them back to REAL counts, you are going to need to know: the total number UMIs in the original dataset and the precise gene length used for each gene. Its posible the data set provides this ... Otherwise you are going to have problems.

$\frac{TPM_i}{1,000,000}$ is the fraction of all transcripts in a sample that belong to a given gene.

If $$fL_i = \frac{length_i}{\Sigma_{j\in G} length_j}$$ is the fraction of the transcribed genome in a gene i. Thus $fR_i = fL_i \times \frac{TPM_i}{1,000,000}$ should be the fraction of all counts that come from a gene $i$. Multiply this by the total number of reads to get the original counts.

The total number of reads may or may not be critcal, I think this might come out in the wash of the normalization, but it might mess with the disperision estimates, I'm not sure. But it is absolutely critical that

1) The TPM dataset was counted across exactly the same annotation as the count datasets

2) The gene lengths used are identical.

This could be untrue for several reasons:

• Different annotation or annotation version (ENSEMBL, UCSC, REFSEQ, CCDS etc).
• Different subset of transcripts used, or different way of combinng transcripts.
• Different ways of calculating "effective length", used to correct for things like which parts of the gene reads can or can't map to (reads too close to ends, unmappable regions of the gene etc).

Much safer to convert the count sets to TPM, but this would preclude doing count based statisitcs (e.g. DESeq2, edgeR, voom).

However I'd also worry that if these datasets were processed at this point differently, they are going to have been processed in different ways, and that the data is basically uncomparable.

• Thank you very much for the answer. Could you give any links to python (or R) packages that implement rlog? Could I apply rlog both to UMIs and TPMs? Even if not, then it might be a choice for me to do TPM for all the samples and then rlog. – Nikita Vlasenko Sep 2 '18 at 21:41
• rLog is comes from the deseq2 r package. It is designed counts, but as far as I'm aware it makes no assumptions that wouldn't also hold true for TPM. – Ian Sudbery Sep 3 '18 at 6:49