Kidney organoid gene and TF stream tree feature plots
[1]:
import phlower
import pickle
import scanpy as sc
[2]:
!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
WARNING: The certificate of 'costalab.ukaachen.de' is not trusted.
WARNING: The certificate of 'costalab.ukaachen.de' hasn't got a known issuer.
2025-11-12 14:33:21 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.
2025-11-12 14:33:22 URL:https://costalab.ukaachen.de/open_data/PHLOWER/multiome_chromvar.h5 [73101100/73101100] -> "save/multiome_chromvar.h5" [1]
Load kidney organoid phlower tree adata with scRNA-seq counts and tf activity data
[3]:
## load adata with scRNA-seq counts
f = "save/multiome_phlower.pickle"
adata = pickle.load(open(f, "rb"))
## load tf activity anndata
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))
## obtain all phlower tree information from adata
import copy
tfbdata.obs = copy.deepcopy(adata.obs)
tfbdata.obsm = copy.deepcopy(adata.obsm)
tfbdata.uns = copy.deepcopy(adata.uns)
Plot PAX3 and GRHL2 TF activities
[4]:
greengrey2red = phlower.custom_cmap(['green', 'grey', 'red', 'red'])
anno_dic = {
9: "Podocytes",
1: "Tubular",
6: "Muscle",
13: "Neuron-1",
0: "Neuron-2",
7: "Stromal-1",
8: "Stromal-2",
5: "Stromal-3",
11: "Stromal-4",
}
preference_order = {"original": list(anno_dic.values())} ## order of tree branches
phlower.ext.plot_stream_sc(tfbdata, color=['PAX3', 'GRHL2'],
return_fig=False, ## Return figure list if True
show_text=True,
text_attr='original',
show_graph=True,
show_legend=True,
preference=preference_order,
fig_size=(9,7),
s=(2, 20), ## points size according tf activity
alpha=0.8,
dist_scale=.4,
cmap_continous=greengrey2red)
preprocess of scRNA-seq data and imputation with magic (https://www.cell.com/cell/fulltext/S0092-8674(18)30724-4)
[5]:
sc.pp.normalize_total(adata, target_sum=1e4)
sc.pp.log1p(adata)
phlower.tl.magic_adata(adata)
Calculating MAGIC...
Running MAGIC on 13751 cells and 36601 genes.
Calculating graph and diffusion operator...
/home/sz753404/miniconda3/envs/R422/lib/python3.10/site-packages/magic/magic.py:425: UserWarning: Input matrix contains unexpressed genes. Please remove them prior to running MAGIC.
warnings.warn(
Calculating PCA...
Calculated PCA in 27.65 seconds.
Calculating KNN search...
Calculated KNN search in 19.87 seconds.
Calculating affinities...
Calculated affinities in 20.63 seconds.
Calculated graph and diffusion operator in 68.52 seconds.
Running MAGIC with `solver='exact'` on 36601-dimensional data may take a long time. Consider denoising specific genes with `genes=<list-like>` or using `solver='approximate'`.
Calculating imputation...
Calculated imputation in 241.02 seconds.
Calculated MAGIC in 348.50 seconds.
Plot PAX3 and GRHL2 gene expression
[6]:
grey2red = phlower.custom_cmap(['grey', 'red'])
phlower.ext.plot_stream_sc(adata, color=['PAX3', "GRHL2"],
return_fig=False,
show_text=True,
text_attr='original',
show_graph=True,
show_legend=True,
preference=preference_order,
fig_size=(9,7),
s=(2,20),
alpha=0.8,
dist_scale=.4,
cmap_continous=grey2red)
[7]:
import session_info
session_info.show()
[7]:
Click to view session information
----- anndata 0.9.2 matplotlib 3.9.1.post1 phlower 0.1.4 scanpy 1.9.3 session_info 1.0.0 -----
Click to view modules imported as dependencies
PIL 9.4.0 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 colorir 2.0.0 colormath 3.0.0 comm 0.2.2 cycler 0.12.1 cython_runtime NA dask 2024.6.2 dateutil 2.8.2 debugpy 1.6.6 decorator 5.1.1 defusedxml 0.7.1 deprecated 1.2.13 dill 0.3.6 dot_parser NA exceptiongroup 1.1.3 executing 1.2.0 fastjsonschema NA fqdn NA future 0.18.3 graphtools 1.5.3 gudhi 3.10.1 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 magic 3.0.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 24.2 pandas 2.2.3 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 pygsp 0.5.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.11.4 scprep 1.1.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 tasklogger 1.2.0 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 wrapt 1.15.0 xxhash NA 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.51.1.el8_10.x86_64-x86_64-with-glibc2.28 ----- Session information updated at 2025-11-12 14:39