Total-mRNA-aware analyses

In this tutorial, we will demonstrate how to conduct differential analysis with total mRNA differences taken into account.

[1]:
import tomas as tm
import scanpy as sc
import pickle
import numpy as np
import pandas as pd
import copy

print(tm.__version__)
0.1.26

Here, we use the pre-analyzed result in mRNA-only scenario as an example to demonstrate how to perform total-mRNA-aware DE analysis. The data is available for download.

[2]:
adata = sc.read_h5ad('../../datasets/adata_mRNAonly_tomas.h5ad') # set the path to match how you save the downloaded data.

The cell clusters/types are arranged in ascending order based on the estimated total mRNA counts. The cell type with the lowest total mRNA count is typically set as the reference during DE analysis.

[3]:
adata.uns['ratio_serial']
[3]:
3
3 1.000000
0 1.986364
2 3.916793
1 5.738651

Toal-mRNA-ratio-based UMI correction

[4]:
adata_rc = tm.auxi.correctUMI(adata, groupby='danno_RNAonly')

Correct UMIs of population 0
100%|██████████████████████████████████████| 2443/2443 [00:06<00:00, 371.91it/s]
Correct UMIs of population 2
100%|██████████████████████████████████████| 1371/1371 [00:03<00:00, 373.25it/s]
Correct UMIs of population 1
100%|██████████████████████████████████████| 1892/1892 [00:05<00:00, 365.95it/s]

Total-mRNA-aware DE

[5]:
tm.fit.logNormal(adata_rc, groupby='danno_RNAonly')

The ratio-corrected data is compatible with various DE methods in theory. Current version support Wilcoxon rank-sum test by setting ” method=‘wilcoxon’ ” and likelihood-ratio test by setting ” method=‘lrt’ “. The default method was”wilcoxon” considering time efficiency.

[6]:
lrt_DE = tm.lrt.total_mRNA_aware_DE(adata_rc, groupby='danno_RNAonly', reference='3', groups=['2'], method='lrt')

LRT-based DE: 2 vs 3. This may take a long time. Please wait...
100%|██████████| 1518/1518 [1:55:04<00:00,  4.55s/it]






Time cost: 6907.629427909851 seconds.
[ ]: