import os
os.environ["PYTHONHASHSEED"] = "0"
import scanpy as sc
import numpy as np
import random
sc.set_figure_params(figsize=(8, 8))
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-sahbnz3t because the default path (/home/sturm/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
np.random.seed(0) # Numpy random
random.seed(0) # Python random
input_adata = "../data/adata_scvi.h5ad"
# Parameters
input_adata = "adata_scvi.h5ad"
sc.logging.print_versions()
WARNING: If you miss a compact list, please try `print_header`!
----- anndata 0.7.6 scanpy 1.7.2 sinfo 0.3.1 ----- PIL 8.3.2 anndata 0.7.6 backcall 0.2.0 beta_ufunc NA binom_ufunc NA cffi 1.14.6 colorama 0.4.4 concurrent NA cycler 0.10.0 cython_runtime NA dateutil 2.8.2 decorator 5.1.0 defusedxml 0.7.1 dunamai 1.6.0 encodings NA genericpath NA get_version 3.5.3 h5py 3.4.0 igraph 0.9.6 ipykernel 6.0.3 ipython_genutils 0.2.0 jedi 0.18.0 joblib 1.1.0 kiwisolver 1.3.2 legacy_api_wrap 0.0.0 leidenalg 0.8.7 llvmlite 0.37.0 matplotlib 3.4.3 matplotlib_inline NA mpl_toolkits NA natsort 7.1.1 nbinom_ufunc NA ntpath NA numba 0.54.1 numexpr 2.7.3 numpy 1.20.3 opcode NA packaging 21.0 pandas 1.3.3 parso 0.8.2 pexpect 4.8.0 pickleshare 0.7.5 pkg_resources NA posixpath NA prompt_toolkit 3.0.20 ptyprocess 0.7.0 pydoc_data NA pyexpat NA pygments 2.10.0 pyparsing 2.4.7 pytz 2021.3 scanpy 1.7.2 scipy 1.7.1 sinfo 0.3.1 six 1.16.0 sklearn 1.0 sphinxcontrib NA sre_compile NA sre_constants NA sre_parse NA storemagic NA tables 3.6.1 texttable 1.6.4 tornado 6.1 traitlets 5.1.0 typing_extensions NA wcwidth 0.2.5 yaml 5.4.1 zmq 22.3.0 ----- IPython 7.28.0 jupyter_client 6.1.12 jupyter_core 4.8.1 ----- Python 3.9.7 | packaged by conda-forge | (default, Sep 29 2021, 19:20:46) [GCC 9.4.0] Linux-3.10.0-1160.11.1.el7.x86_64-x86_64-with-glibc2.28 48 logical CPU cores ----- Session information updated at 2021-10-16 08:08
!lscpu
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 48 bits physical, 48 bits virtual CPU(s): 48 On-line CPU(s) list: 0-47 Thread(s) per core: 1 Core(s) per socket: 24 Socket(s): 2 NUMA node(s): 2 Vendor ID: AuthenticAMD CPU family: 23 Model: 49 Model name: AMD EPYC 7352 24-Core Processor Stepping: 0 CPU MHz: 2300.000 CPU max MHz: 2300.0000 CPU min MHz: 1500.0000 BogoMIPS: 4591.40 Virtualization: AMD-V L1d cache: 32K L1i cache: 32K L2 cache: 512K L3 cache: 16384K NUMA node0 CPU(s): 0-23 NUMA node1 CPU(s): 24-47 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc art rep_good nopl nonstop_tsc extd_apicid aperfmperf eagerfpu pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_l2 cpb cat_l3 cdp_l3 hw_pstate retpoline_amd ssbd ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif umip overflow_recov succor smca
adata = sc.read_h5ad(input_adata)
sc.pp.neighbors(adata, use_rep="X_scVI")
sc.tl.umap(adata)
sc.tl.leiden(adata)
Check (superficially) if connectivities are the same
(
adata.obsp["connectivities"].sum(),
adata.obsp["connectivities"][
np.random.choice(adata.shape[0], 1000, replace=False), :
].sum(),
)
(170527.84, 6511.5127)
sc.pl.umap(adata, color="leiden", legend_loc="on data")
adata.obs["leiden"].value_counts()
0 4268 1 2132 2 1691 3 1662 4 1659 5 1563 6 1443 7 1210 8 1043 9 1022 10 952 11 837 12 809 13 804 14 733 15 703 16 570 17 506 18 503 19 438 20 433 21 346 22 273 23 182 24 144 25 141 26 137 27 82 28 76 29 57 30 55 31 40 Name: leiden, dtype: int64