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-39wmq12k 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 40 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: 44 bits physical, 48 bits virtual CPU(s): 40 On-line CPU(s) list: 0-39 Thread(s) per core: 1 Core(s) per socket: 10 Socket(s): 4 NUMA node(s): 4 Vendor ID: GenuineIntel CPU family: 6 Model: 47 Model name: Intel(R) Xeon(R) CPU E7- 4870 @ 2.40GHz Stepping: 2 CPU MHz: 2400.000 CPU max MHz: 2400.0000 CPU min MHz: 1064.0000 BogoMIPS: 4794.57 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 30720K NUMA node0 CPU(s): 0-9 NUMA node1 CPU(s): 10-19 NUMA node2 CPU(s): 20-29 NUMA node3 CPU(s): 30-39 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt aes lahf_lm epb ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid dtherm ida arat spec_ctrl intel_stibp flush_l1d
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 3856 1 2168 2 2029 3 1659 4 1636 5 1536 6 1353 7 1178 8 1049 9 1022 10 1015 11 959 12 832 13 804 14 761 15 705 16 578 17 506 18 459 19 432 20 346 21 322 22 288 23 265 24 159 25 144 26 141 27 82 28 76 29 57 30 56 31 41 Name: leiden, dtype: int64