Figure 3J - Supplementary Tables#
Import packages#
[1]:
import pandas as pd
import scdiffeq as sdq
import scipy.stats
Load results#
[2]:
Perturbed = sdq.io.read_pickle("./Spi1.perturb.z_scan.pkl")
Loop through the results, concat into table#
[3]:
list_of_dfs = []
for version, result in Perturbed.items():
for z, expt in result.items():
expt.stats['version'] = version
expt.stats['z'] = z
list_of_dfs.append(expt.stats)
df = pd.concat(list_of_dfs)
df
[3]:
| lfc | lfc_std | pval | version | z | |
|---|---|---|---|---|---|
| Baso | 0.012356 | 0.152108 | 0.847814 | version_0 | -10.0 |
| Ccr7_DC | -3.786314 | 8.466456 | 0.373901 | version_0 | -10.0 |
| Eos | -0.483007 | 0.360628 | 0.072644 | version_0 | -10.0 |
| Lymphoid | 3.986314 | 15.800427 | 0.607584 | version_0 | -10.0 |
| Mast | 0.031224 | 0.144437 | 0.621027 | version_0 | -10.0 |
| ... | ... | ... | ... | ... | ... |
| Mast | -0.029032 | 0.223107 | 0.682293 | version_4 | 10.0 |
| Meg | -0.336100 | 0.644422 | 0.206413 | version_4 | 10.0 |
| Monocyte | 0.170410 | 0.081715 | 0.002381 | version_4 | 10.0 |
| Neutrophil | 0.066611 | 0.074323 | 0.050309 | version_4 | 10.0 |
| Undifferentiated | -0.088646 | 0.051462 | 0.018303 | version_4 | 10.0 |
406 rows × 5 columns
Write to csv#
[4]:
df.to_csv("supplementary_table.accompanies_3J.csv")
Compute correlations#
Annotate the Figure 3J with the results
[5]:
grouped = df.reset_index().rename({"index": "fate"}, axis = 1).groupby("fate")
for fate in ['Neutrophil', 'Monocyte', 'Baso']:
fate_group = grouped.get_group(fate)
corr, pval = scipy.stats.pearsonr(fate_group['z'].values, fate_group['lfc'].values)
print("{:<10} | corr: {:<6} [pval: {:.3e}]".format(fate, round(corr, 3), pval))
Neutrophil | corr: 0.684 [pval: 2.280e-07]
Monocyte | corr: 0.883 [pval: 1.034e-15]
Baso | corr: -0.906 [pval: 1.182e-17]