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-6yr9h7rc 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 44 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: 46 bits physical, 48 bits virtual CPU(s): 44 On-line CPU(s) list: 0-43 Thread(s) per core: 1 Core(s) per socket: 22 Socket(s): 2 NUMA node(s): 2 Vendor ID: GenuineIntel CPU family: 6 Model: 79 Model name: Intel(R) Xeon(R) CPU E5-2699A v4 @ 2.40GHz Stepping: 1 CPU MHz: 2400.000 CPU max MHz: 2400.0000 CPU min MHz: 1200.0000 BogoMIPS: 4794.35 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 56320K NUMA node0 CPU(s): 0-10,22-32 NUMA node1 CPU(s): 11-21,33-43 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 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single intel_ppin intel_pt ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts md_clear 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 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