Main branches regulator detection

[1]:
import matplotlib.pyplot as plt
import scanpy as sc
[2]:
import phlower
phlower.__version__
[2]:
'0.1.3'
[3]:
!mkdir save
!wget --no-check-certificate --no-verbose  https://costalab.ukaachen.de/open_data/PHLOWER/multiome_phlower.pickle -O save/multiome_phlower.pickle
!wget --no-check-certificate --no-verbose  https://costalab.ukaachen.de/open_data/PHLOWER/multiome_chromvar.h5 -O save/multiome_chromvar.h5
mkdir: cannot create directory ‘save’: File exists
WARNING: The certificate of ‘costalab.ukaachen.de’ is not trusted.
WARNING: The certificate of ‘costalab.ukaachen.de’ hasn't got a known issuer.
2024-10-16 15:57:35 URL:https://costalab.ukaachen.de/open_data/PHLOWER/multiome_phlower.pickle [4365968492/4365968492] -> "save/multiome_phlower.pickle" [1]
WARNING: The certificate of ‘costalab.ukaachen.de’ is not trusted.
WARNING: The certificate of ‘costalab.ukaachen.de’ hasn't got a known issuer.
2024-10-16 15:57:36 URL:https://costalab.ukaachen.de/open_data/PHLOWER/multiome_chromvar.h5 [73101100/73101100] -> "save/multiome_chromvar.h5" [1]
[4]:
import pickle as pkl
adata = pkl.load(open("save/multiome_phlower.pickle", 'rb'))


tfbdata = sc.read_10x_h5("save/multiome_chromvar.h5")
tfbdata.var_names = [i.upper() for i in tfbdata.var_names]

assert(all(tfbdata.obs_names == adata.obs_names))

import copy
tfbdata.obs = copy.deepcopy(adata.obs)
tfbdata.obsm = copy.deepcopy(adata.obsm)
tfbdata.uns = copy.deepcopy(adata.uns)

[5]:
branch_order_preference={"original": ["Podocytes", "Muscle", "Neuron-1", "Stromal-1", "Stromal-2", "Stromal-3"]}
phlower.ext.plot_stream_sc(adata, color=['group_str'], show_legend=False, s=20,  dist_scale=.4, preference=branch_order_preference)
../_images/notebooks_kidney_single_main_branch_regulators_5_0.png

List main branches

[6]:
main_stromal = ("Stromal-1", "Stromal-2", "Stromal-3", "Stromal-4")
main_pt_podo = ("Podocytes", "Tubular")
main_neuronMuscle = ("Muscle", "Neuron-1", "Neuron-2")

Stromal main branch regulators

[7]:
phlower.tl.mbranch_regulator_detect(adata, tfbdata, branch=main_stromal, log2fc=0.3, correlation=0.7, name="stromal")
against branches [('Muscle', 'Neuron-2', 'Neuron-1'), ('Podocytes', 'Tubular')]
WARNING: Default of the method has been changed to 't-test' from 't-test_overestim_var'
vs_name:  markers_stromalvs
/home/sz753404/miniconda3/envs/R422/lib/python3.10/site-packages/phlower/tools/tree_feature_markers.py:1134: ConstantInputWarning: An input array is constant; the correlation coefficient is not defined.
  corr = pearsonr(expression, TF)[0]

TF markers volcano

[8]:
df = phlower.tl.get_markers_df(tfbdata, 'markers_stromalvs')
fig, ax = plt.subplots(1,1, figsize=(6, 4))
phlower.pl.volcano(df, log2fc_column='logfoldchanges', pval_column='pvals_adj',log2fc_threshold=[-.3, .3],  pval_threshold=0.05, is_adjust_text=True, text_size=10, text_up_down='up', ax=ax, show_legend=False)
../_images/notebooks_kidney_single_main_branch_regulators_11_0.png

TF gene correlations

[9]:
_, ax = plt.subplots(1,1,figsize=(5,6))
phlower.pl.regulator_dot_correlation(tfbdata, 'stromal', ax=ax)
../_images/notebooks_kidney_single_main_branch_regulators_13_0.png

Heatmap along main trajectory

[10]:
_,axes = phlower.pl.regulator_heatmap(adata, tfbdata, 'stromal', figsize=(10, 7))
../_images/notebooks_kidney_single_main_branch_regulators_15_0.png

Podocytes & Tubular main branch regulators

[11]:
phlower.tl.mbranch_regulator_detect(adata, tfbdata, branch=main_pt_podo, log2fc=0.5, correlation=0.7, name="epi")
against branches [('Stromal-2', 'Stromal-4', 'Stromal-1', 'Stromal-3'), ('Muscle', 'Neuron-2', 'Neuron-1')]
WARNING: Default of the method has been changed to 't-test' from 't-test_overestim_var'
vs_name:  markers_epivs
/home/sz753404/miniconda3/envs/R422/lib/python3.10/site-packages/phlower/tools/tree_feature_markers.py:1134: ConstantInputWarning: An input array is constant; the correlation coefficient is not defined.
  corr = pearsonr(expression, TF)[0]
[12]:
df = phlower.tl.get_markers_df(tfbdata, 'markers_epivs')
fig, ax = plt.subplots(1,1, figsize=(6, 4))
phlower.pl.volcano(df, log2fc_column='logfoldchanges', pval_column='pvals_adj',log2fc_threshold=[-.3, .3],  pval_threshold=0.05, is_adjust_text=True, text_size=10, text_up_down='up', ax=ax, show_legend=False)
../_images/notebooks_kidney_single_main_branch_regulators_18_0.png
[13]:
_, ax = plt.subplots(1,1,figsize=(5,6))
phlower.pl.regulator_dot_correlation(tfbdata, 'epi', ax=ax)
../_images/notebooks_kidney_single_main_branch_regulators_19_0.png
[14]:
_,axes = phlower.pl.regulator_heatmap(adata, tfbdata, 'epi', figsize=(10, 7))
../_images/notebooks_kidney_single_main_branch_regulators_20_0.png

Neuron & Muscle main branch regulators

[15]:
phlower.tl.mbranch_regulator_detect(adata, tfbdata, branch=main_neuronMuscle, log2fc=0.2, correlation=0.7, name="neuMsl")
against branches [('Stromal-2', 'Stromal-4', 'Stromal-1', 'Stromal-3'), ('Podocytes', 'Tubular')]
WARNING: Default of the method has been changed to 't-test' from 't-test_overestim_var'
vs_name:  markers_neuMslvs
/home/sz753404/miniconda3/envs/R422/lib/python3.10/site-packages/phlower/tools/tree_feature_markers.py:1134: ConstantInputWarning: An input array is constant; the correlation coefficient is not defined.
  corr = pearsonr(expression, TF)[0]
[16]:
df = phlower.tl.get_markers_df(tfbdata, 'markers_neuMslvs')
fig, ax = plt.subplots(1,1, figsize=(6, 4))
phlower.pl.volcano(df, log2fc_column='logfoldchanges', pval_column='pvals_adj',log2fc_threshold=[-.2, .2],  pval_threshold=0.05, is_adjust_text=True, text_size=10, text_up_down='up', ax=ax, show_legend=False)
../_images/notebooks_kidney_single_main_branch_regulators_23_0.png
[17]:
_, ax = plt.subplots(1,1,figsize=(5,6))
phlower.pl.regulator_dot_correlation(tfbdata, 'neuMsl', ax=ax)
../_images/notebooks_kidney_single_main_branch_regulators_24_0.png
[18]:
_,axes = phlower.pl.regulator_heatmap(adata, tfbdata, 'neuMsl', figsize=(10, 7))
../_images/notebooks_kidney_single_main_branch_regulators_25_0.png
[19]:
import session_info
session_info.show()
[19]:
Click to view session information
-----
anndata             0.9.2
matplotlib          3.9.1.post1
pandas              2.2.3
phlower             0.1.3
scanpy              1.9.3
session_info        1.0.0
-----
Click to view modules imported as dependencies
Cython                      0.29.33
PIL                         9.4.0
adjustText                  0.8
anyio                       NA
argcomplete                 NA
arrow                       1.2.3
asciitree                   NA
asttokens                   NA
attr                        22.2.0
attrs                       22.2.0
babel                       2.12.1
backcall                    0.2.0
brotli                      NA
certifi                     2024.08.30
cffi                        1.15.1
charset_normalizer          3.1.0
cloudpickle                 2.2.1
colorama                    0.4.6
colorcet                    3.0.1
comm                        0.2.2
cycler                      0.12.1
cython                      0.29.33
cython_runtime              NA
dask                        2024.6.2
dateutil                    2.8.2
debugpy                     1.6.6
decorator                   5.1.1
defusedxml                  0.7.1
dill                        0.3.6
dot_parser                  NA
exceptiongroup              1.1.3
executing                   1.2.0
fastjsonschema              NA
fqdn                        NA
h5py                        3.10.0
idna                        3.4
igraph                      0.10.5
importlib_metadata          NA
ipykernel                   6.21.3
ipython_genutils            0.2.0
ipywidgets                  8.1.3
isoduration                 NA
jedi                        0.19.0
jinja2                      3.1.2
joblib                      1.3.2
json5                       NA
jsonpointer                 2.3
jsonschema                  4.17.3
jsonschema_specifications   NA
jupyter_events              0.6.3
jupyter_server              2.4.0
jupyterlab_server           2.20.0
kiwisolver                  1.4.5
leidenalg                   0.9.1
llvmlite                    0.39.1
louvain                     0.8.0
markupsafe                  2.1.3
matplotlib_inline           0.1.6
mpl_toolkits                NA
mpmath                      1.3.0
msgpack                     1.0.5
natsort                     8.4.0
nbformat                    5.9.2
networkx                    2.8.8
numba                       0.56.4
numcodecs                   0.12.1
numexpr                     2.8.4
numpy                       1.23.5
nvfuser                     NA
opt_einsum                  v3.3.0
packaging                   23.1
parso                       0.8.3
patsy                       0.5.3
pexpect                     4.8.0
pickleshare                 0.7.5
pkg_resources               NA
platformdirs                3.8.1
plotly                      5.23.0
prometheus_client           NA
prompt_toolkit              3.0.39
psutil                      5.9.4
ptyprocess                  0.7.0
pure_eval                   0.2.2
pyarrow                     16.1.0
pycparser                   2.21
pydev_ipython               NA
pydevconsole                NA
pydevd                      2.9.5
pydevd_file_utils           NA
pydevd_plugins              NA
pydevd_tracing              NA
pydot                       1.4.2
pygments                    2.15.1
pynndescent                 0.5.11
pyparsing                   3.1.2
pythonjsonlogger            NA
pytz                        2023.3
referencing                 NA
requests                    2.29.0
rfc3339_validator           0.1.4
rfc3986_validator           0.1.1
rpds                        NA
scipy                       1.14.0
seaborn                     0.13.2
send2trash                  NA
setuptools_scm              NA
six                         1.16.0
sklearn                     1.5.1
sksparse                    0.4.8
sniffio                     1.3.0
socks                       1.7.1
sparse                      0.14.0
sphinxcontrib               NA
stack_data                  0.6.2
statsmodels                 0.14.0
sympy                       1.11.1
tblib                       3.0.0
texttable                   1.6.7
threadpoolctl               3.4.0
tlz                         0.12.0
toolz                       0.12.0
torch                       2.0.1+cu117
tornado                     6.3
tqdm                        4.65.0
traitlets                   5.9.0
typing_extensions           NA
umap                        0.5.5
uri_template                NA
urllib3                     1.26.15
wcwidth                     0.2.6
webcolors                   1.11.1
websocket                   1.5.1
yaml                        6.0
zarr                        2.18.2
zipp                        NA
zmq                         25.0.2
-----
IPython             8.15.0
jupyter_client      8.2.0
jupyter_core        5.3.0
jupyterlab          3.6.1
notebook            6.5.3
-----
Python 3.10.8 | packaged by conda-forge | (main, Nov 22 2022, 08:23:14) [GCC 10.4.0]
Linux-4.18.0-553.5.1.el8_10.x86_64-x86_64-with-glibc2.28
-----
Session information updated at 2024-10-16 15:58