scRNA-Seq generation from Boolean dynamics

scRNA-Seq generation from Boolean dynamics#

The tool scBoolSeq can be used to generated synthetic scRNA-Seq datasets from Boolean traces obtained by the simulation of Boolean networks.

The synthetic scRNA-Seq are sampled from pseudocount distributions learnt by scBoolSeq from a reference scRNA-Seq dataset.

In this notebook, we demonstrate how to generate such a synthetic dataset from a simple artificial Boolean networks.

from scboolseq import scBoolSeq
import pandas as pd
from colomoto import minibn

import warnings  # silence some warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
# fix seeds
import random
import numpy as np
_rng_seed = 19834650
_rng = np.random.default_rng(_rng_seed)
random.seed(_rng_seed)

1. Learning of reference pseudocount distributions

scBoolSeq learns pseudocount distributions from highly-variables genes of a reference scRNA-Seq dataset.

!test -f GSE81682_Hematopoiesis.csv || curl -fOL \
    https://github.com/bnediction/scBoolSeq-supplementary/raw/main/data_filtered_vargenes/GSE81682_Hematopoiesis.csv
ref_data = pd.read_csv("GSE81682_Hematopoiesis.csv", index_col=0)
# for the sake of the demo, we shrink the number of genes
ref_data = ref_data.iloc[:,:256]
ref_data
8430408G22Rik Plp1 Zfp947 Bhlhb9 Vps35 Slc18a1 Fam107b Gm14230 Plekhn1 Ankrd6 9030619P08Rik Prtn3 Lrrn4 Mrgpre Gm25926 Plppr3 Memo1 Cdkn1c Gm2a Phxr4 B2m Tbxas1 Glipr2 Tcf15 Trim58 D930028M14Rik 1700010I14Rik Gm10384 Sla2 Trp53i13 Gm17586 Gypc Clic5 Tubb4b AC149090.1 Gm26580 Clec1a Ccl9 Gimap3 Zscan18 Spi1 Ccl6 2900041M22Rik Klk8 Gm37637 Gp9 Idh3a Akr1c13 2810408A11Rik Npr2 Ephx1 Pik3ip1 ENSMUSG00000043858 Gm26789 Grina Txnip Gm26541 Dnajb3 Msn Gm37124 Srd5a1 Bhlhe40 Pomgnt2 Fcer1g Gm37298 Lmo1 Rab20 Cd69 Gm2788 Gm14276 Napa Cd24a Nsun2 Marveld2 Ms4a4b Gm17590 Cdk6 Tada2b Gm5113 Mki67 Btg2 Gnat2 Tcaf1 Slc35e4 Reep2 8430419K02Rik Pdgfd H2-K1 Sesn1 Bcap29 Gm21814 Eif5a Stk25 Maged1 Zfp449 9130604C24Rik 6430590A07Rik Tcirg1 Il4 Slc35a4 Cysltr2 Ap3m2 Dsel Cmtm7 Arl8b Gbx2 Smim10l2a Cyth4 S1pr4 Gdi1 Hdhd3 Vill Slc38a6 Calu Gm16565 Smim3 Sar1a 4833407H14Rik B230217O12Rik Ccdc39 Spata2l Arxes2 Dut Ifngr1 Rasa3 Fbxl2 Pde4b Ptp4a3 Cdt1 Fxyd1 Arl11 Shisa8 Dleu7 Tmem173 Atxn10 Rpn2 Ccl3 Nudt16 Kif3c Hars Ccl4 Myo1g Cpq Cox6a2 Sdc3 Dok2 Fcgrt Elmo1 Cyc1 Calr Gpr18 Tbxa2r Gpr183 Naaa Gm11110 Alad Taz Echdc3 Cd300a Slc39a4 Zfp128 Gm26819 Ispd Itm2b Zfp647 Gm16861 Nek3 Gata2 Prss16 Lppos Lhcgr Fundc1 Lat Tnfrsf26 Prr36 Vldlr Mfge8 Enkur Rcor2 Ndn Btla Zyx Cd33 Dkc1 Rab37 Cdcp1 Hoxa9 Oat Vegfc Gas6 Oasl2 Tacc1 Colgalt1 Xdh Rab32 Dusp2 Tmem176a Gnai3 Rnf13 Elane Cd48 Mthfd1 Igkc Fnta Bok Ripply3 Ptger2 P2rx7 Wdfy2 Eif1a Gstm7 Tmem14c 2900018N21Rik Mpl Sash3 Tgm2 Gm19569 Ehd3 Cish Calml4 Mesdc2 Nfil3 Tcn2 Saraf Meis1 Serpina3g Pcx Gpr171 Cks1b Coa5 Arhgap27os3 Farsa Ctsl Iigp1 P2ry14 Cd82 Slc18a2 Cd302 Parp12 Isyna1 S100a8 B130034C11Rik Arhgap27 Klf1 Gm26740 Cd84 Bag2 Tmem123 Emilin1 4930568A12Rik Clec11a Mat2a Tespa1 Wfdc17 Tspan13 Dyrk2
HSPC_025 0.0 0.000000 0.000000 5.392129 8.852337 0.000000 2.614548 0.000000 0.000000 0.0 6.711045 7.977803 8.117451 0.000000 0.000000 8.195180 7.977803 0.000000 9.173640 0.0 12.912375 8.427644 7.839405 0.0 1.189716 0.0 0.000000 0.000000 0.000000 5.935712 0.000000 8.021134 0.000000 7.309000 10.293674 0.000000 0.000000 2.275971 0.000000 0.0 9.014787 0.000000 0.000000 0.000000 0.000000 1.832751 8.774285 1.189716 1.189716 1.832751 0.0 3.118770 7.285499 0.000000 7.135838 8.744431 0.000000 0.0 8.852337 0.0 0.000000 0.0 1.832751 1.189716 0.000000 0.000000 0.000000 1.189716 0.000000 0.000000 7.225016 8.876132 7.940672 6.184685 1.189716 0.000000 8.691769 1.189716 0.000000 3.491677 7.161885 0.000000 0.00000 0.000000 1.832751 6.779938 8.490658 11.925211 7.410259 3.317239 0.000000 10.416407 4.242991 2.275971 1.832751 1.189716 0.000000 7.894815 0.000000 9.681046 1.189716 0.000000 0.0 9.723202 4.141925 0.000000 0.000000 7.574401 7.174734 2.275971 0.000000 2.614548 0.000000 2.888576 0.000000 7.806760 8.268934 3.491677 0.000000 0.000000 0.000000 0.000000 8.585122 2.888576 2.614548 0.000000 8.344797 6.461289 7.285499 0.000000 7.593666 6.657127 0.0 2.275971 8.655561 9.077708 0.000000 1.832751 1.189716 7.695253 10.437884 1.832751 7.814991 0.000000 0.0000 1.189716 5.935712 4.588530 2.275971 9.025466 0.000000 1.189716 0.000000 0.000000 0.000000 3.118771 1.189716 1.189716 7.161885 0.0 0.000000 0.000000 0.000000 10.103505 0.000000 0.000000 0.000000 2.888576 0.000000 0.00000 0.000000 7.977803 6.675324 0.000000 0.000000 7.054751 0.000000 0.000000 0.0 0.000000 0.000000 9.101455 7.040782 9.449536 0.000000 0.000000 8.310278 8.495788 0.000000 0.000000 2.888576 8.687292 7.940672 0.000000 1.189716 11.307754 7.781782 7.894815 8.361752 0.000000 2.888576 9.067410 4.509590 8.310278 0.0 0.000000 0.000000 0.000000 0.000000 7.343549 0.000000 5.671352 7.564672 10.551846 6.763021 0.000000 1.189716 0.000000 0.000000 1.189716 9.272583 0.000000 1.189716 8.021134 8.150349 2.275971 0.000000 7.747791 8.130700 3.647281 0.000000 7.593666 1.832751 1.189716 7.790156 7.421084 0.000000 0.000000 6.779938 2.275971 6.079295 0.000000 2.275971 2.888576 0.000000 9.014787 1.189716 8.182512 7.977803 4.141925 1.189716 9.826553 0.000000 9.822478 8.594715 0.000000
HSPC_031 0.0 0.000000 0.000000 0.686872 7.637939 0.000000 6.838205 0.000000 0.000000 0.0 8.951078 8.584765 0.000000 0.000000 0.000000 6.956259 7.579348 0.000000 4.175851 0.0 13.622584 7.800662 0.000000 0.0 0.686872 0.0 0.000000 0.686872 0.000000 0.000000 0.000000 7.018651 1.150286 3.253543 7.387780 0.686872 0.000000 0.000000 0.000000 0.0 6.348589 0.000000 0.686872 0.686872 0.000000 0.000000 2.827390 8.409573 0.686872 1.782055 0.0 8.765434 8.059983 0.000000 8.638735 9.676164 0.686872 0.0 1.782055 0.0 0.000000 0.0 1.150286 1.150286 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 9.235683 10.222019 2.946297 0.000000 0.000000 0.000000 9.531507 0.000000 0.000000 1.500480 0.686872 0.000000 0.00000 0.000000 0.000000 0.000000 0.000000 11.665664 9.216587 5.672502 0.000000 9.484386 0.000000 1.150286 0.000000 0.000000 0.000000 0.000000 0.000000 6.991254 0.000000 0.000000 0.0 9.159273 3.158217 7.403453 0.000000 8.372889 8.587055 1.500480 0.000000 8.401790 0.686872 2.017546 0.686872 0.686872 1.500480 7.574740 0.000000 0.000000 0.000000 0.000000 7.527841 3.342958 0.000000 1.150286 8.598449 1.782055 1.782055 0.000000 0.686872 1.150286 0.0 2.219938 2.219938 9.404856 0.686872 1.150286 0.686872 2.017546 0.000000 0.686872 0.000000 0.000000 0.0000 7.824144 7.148337 2.827390 2.397399 9.564413 0.000000 6.623022 0.000000 0.000000 0.000000 2.397399 7.032157 0.000000 0.000000 0.0 0.000000 0.000000 0.000000 11.892010 0.000000 0.000000 0.000000 1.782055 0.000000 0.00000 1.150286 0.000000 7.828021 1.150286 5.925034 0.000000 0.686872 0.000000 0.0 0.000000 0.686872 8.915083 0.000000 9.006865 8.155637 0.000000 9.640235 2.397399 0.000000 0.000000 2.017546 9.543345 0.686872 0.000000 0.000000 9.419062 9.750561 1.150286 0.686872 0.686872 6.549791 8.233698 3.653748 1.500480 0.0 0.000000 0.000000 0.000000 0.000000 8.662811 0.000000 3.253543 0.000000 2.219938 9.646834 0.000000 0.000000 0.000000 0.000000 0.000000 9.962022 0.686872 8.785511 9.802712 8.826781 0.686872 0.000000 8.545278 2.697797 9.449579 0.000000 8.201186 0.000000 0.000000 8.900430 2.397399 1.500480 0.000000 0.686872 3.582099 0.000000 0.000000 3.506705 2.219938 0.000000 10.152610 1.150286 6.348589 0.000000 0.000000 0.000000 7.780798 1.150286 1.150286 8.951078 0.000000
HSPC_037 0.0 0.000000 0.000000 1.869808 7.938080 0.000000 9.405107 0.000000 0.000000 0.0 7.199831 9.495433 0.000000 0.000000 0.000000 7.394504 3.164226 0.000000 8.086368 0.0 13.104234 9.083711 8.014129 0.0 0.000000 0.0 0.000000 0.000000 8.418471 0.000000 0.000000 2.657566 0.000000 8.337902 10.692584 0.000000 1.218731 8.500077 0.000000 0.0 8.308001 0.000000 0.000000 7.275944 0.000000 0.000000 8.862937 0.000000 0.000000 1.218731 0.0 8.954567 2.316800 0.000000 2.316800 11.106246 0.000000 0.0 8.510617 0.0 0.000000 0.0 1.869808 5.397461 0.000000 0.000000 0.000000 2.316800 0.000000 0.000000 8.006701 9.250198 6.744074 1.869808 0.000000 0.000000 10.085909 0.000000 0.000000 1.218731 6.928313 0.000000 0.00000 0.000000 0.000000 0.000000 1.218731 12.131326 5.568630 8.093396 1.218731 10.313640 2.657566 1.869808 1.218731 0.000000 7.682451 1.869808 1.218731 2.933024 0.000000 0.000000 0.0 9.998750 7.772788 0.000000 0.000000 1.218731 1.218731 8.148427 0.000000 1.218731 0.000000 2.657566 1.218731 8.621744 7.815920 0.000000 0.000000 0.000000 0.000000 0.000000 4.637700 8.546913 2.316800 0.000000 3.538458 8.592276 1.218731 0.000000 0.000000 1.218731 0.0 7.615671 1.218731 7.514567 8.833854 2.316800 1.218731 2.657566 4.475001 6.943951 3.694521 0.000000 0.0000 1.218731 0.000000 8.664848 6.490844 7.482801 0.000000 5.647156 1.218731 0.000000 0.000000 2.316800 1.218731 0.000000 0.000000 0.0 0.000000 0.000000 0.000000 10.392692 0.000000 0.000000 0.000000 7.160213 0.000000 0.00000 0.000000 2.316800 1.218731 8.355550 0.000000 2.933024 0.000000 1.218731 0.0 0.000000 0.000000 8.669560 9.162687 9.873687 7.755167 1.218731 7.615671 1.218731 0.000000 0.000000 8.626598 9.247050 2.316800 0.000000 7.371559 6.779369 7.133183 1.869807 8.246273 0.000000 6.183499 7.348242 3.963623 8.808450 0.0 1.218731 1.218731 1.218731 1.218731 7.914462 4.190334 7.133183 0.000000 1.869807 6.813823 0.000000 0.000000 0.000000 1.218731 0.000000 9.162687 0.000000 6.689457 9.741228 7.605873 2.316800 1.218731 8.760682 3.363442 2.933024 0.000000 8.636256 7.160213 1.869807 10.783395 8.057904 0.000000 0.000000 6.235258 3.164226 0.000000 0.000000 8.429623 3.694520 0.000000 1.869807 0.000000 7.710151 1.218731 0.000000 0.000000 9.498083 0.000000 10.651504 10.660998 0.000000
LT-HSC_001 0.0 0.000000 0.000000 7.965715 5.885018 0.000000 8.962827 0.000000 0.000000 0.0 2.364517 8.080749 0.000000 0.000000 4.137438 3.749470 2.364517 0.000000 7.347331 0.0 13.944537 8.516418 3.749470 0.0 0.000000 0.0 0.000000 0.000000 0.000000 0.000000 0.000000 7.552600 0.000000 3.749470 9.893764 6.820748 2.364517 0.000000 0.000000 0.0 6.872760 0.000000 0.000000 7.520353 0.000000 0.000000 2.364517 0.000000 0.000000 3.217169 0.0 7.232592 7.107933 0.000000 8.564652 11.130502 0.000000 0.0 9.931038 0.0 0.000000 0.0 0.000000 7.584142 0.000000 0.000000 0.000000 8.397178 0.000000 5.095857 8.414827 9.184807 3.217169 0.000000 2.364517 0.000000 4.442877 0.000000 0.000000 2.364517 0.000000 0.000000 0.00000 0.000000 0.000000 0.000000 0.000000 13.092126 4.137438 3.217169 0.000000 9.639814 3.217169 8.187283 0.000000 0.000000 0.000000 3.749470 6.074609 2.364517 2.364517 0.000000 0.0 8.742914 8.888979 0.000000 0.000000 0.000000 8.227787 3.217169 0.000000 2.364517 0.000000 8.685906 0.000000 7.271861 9.312700 8.914017 0.000000 0.000000 0.000000 0.000000 7.487369 4.909226 0.000000 0.000000 7.271861 2.364517 3.217169 5.982925 0.000000 8.548753 0.0 4.137438 2.364517 3.749470 0.000000 2.364517 0.000000 3.749470 7.645229 2.364517 3.749470 0.000000 0.0000 3.217169 7.917005 7.989468 7.674830 8.397178 0.000000 2.364517 0.000000 0.000000 0.000000 8.207678 7.866592 0.000000 0.000000 0.0 0.000000 0.000000 0.000000 10.297362 0.000000 0.000000 0.000000 7.584142 0.000000 5.77998 0.000000 8.267186 4.137438 2.364517 0.000000 2.364517 2.364517 0.000000 0.0 0.000000 0.000000 7.645229 3.217169 8.058464 7.107933 0.000000 7.232592 7.760152 0.000000 8.267186 4.137438 9.967373 0.000000 0.000000 8.187283 6.971475 8.926375 9.143059 7.063866 0.000000 3.749470 3.217169 12.461628 5.543737 0.0 0.000000 0.000000 0.000000 0.000000 9.110936 0.000000 3.217169 0.000000 10.136473 8.483344 0.000000 0.000000 2.364517 9.033078 0.000000 8.397178 0.000000 8.305537 8.466517 7.760152 9.522611 0.000000 7.760152 2.364517 2.364517 0.000000 4.137438 8.058464 4.909226 3.749470 3.749470 0.000000 2.364517 8.700371 0.000000 0.000000 2.364517 8.080749 0.000000 0.000000 8.532677 8.580378 7.674830 8.305537 0.000000 0.000000 4.137438 0.000000 7.645229 8.685906 0.000000
HSPC_001 0.0 0.000000 0.000000 8.395500 0.000000 0.377367 0.676211 0.000000 0.676211 0.0 0.000000 8.923709 0.377367 0.000000 0.000000 8.851780 9.012407 7.123321 7.640356 0.0 12.746870 9.232729 9.914646 0.0 0.000000 0.0 0.000000 5.069857 0.000000 0.000000 0.000000 1.628905 0.000000 9.412471 11.118833 0.000000 0.000000 0.676211 0.377367 0.0 6.802432 0.000000 0.000000 4.414804 0.377367 7.107768 8.010188 5.867946 0.000000 9.303379 0.0 8.824449 1.134796 0.000000 1.482235 8.987981 0.000000 0.0 1.318950 0.0 0.000000 0.0 0.377367 0.000000 0.000000 0.000000 0.000000 0.377367 0.000000 0.000000 1.482235 7.239191 8.617097 0.000000 0.000000 0.000000 2.921687 0.000000 0.000000 1.762030 0.000000 0.000000 0.00000 0.000000 0.000000 0.000000 0.000000 12.396286 0.000000 0.676211 0.000000 11.169149 0.377367 9.699115 0.000000 0.000000 0.377367 0.000000 0.000000 8.285068 0.000000 0.000000 0.0 11.201561 0.923649 0.377367 0.000000 0.676211 5.216270 9.912410 0.000000 8.639983 0.000000 2.374501 7.993360 0.000000 7.224846 0.676211 0.000000 0.000000 0.000000 0.000000 7.224846 9.392715 0.000000 0.000000 9.060862 1.628905 0.923649 0.000000 0.000000 4.434885 0.0 8.771148 1.628905 10.008081 8.286449 8.276747 8.061140 1.762030 0.000000 8.663575 4.586200 0.000000 0.0000 8.923709 0.000000 7.925790 1.482235 9.740544 0.000000 8.240127 0.000000 0.000000 0.000000 1.883902 8.577000 0.000000 0.000000 0.0 0.000000 0.000000 7.520972 9.818564 0.000000 0.000000 0.000000 0.000000 0.377367 0.00000 0.000000 0.377367 9.422563 0.377367 0.000000 8.668884 0.377367 0.000000 0.0 5.918739 0.000000 4.265819 0.000000 9.042166 0.923649 0.000000 3.519027 8.720921 0.000000 0.000000 8.950983 8.410789 0.676211 0.000000 0.000000 0.676211 8.584884 6.136699 7.233470 1.628905 0.377367 1.996276 2.288830 9.442536 0.0 0.000000 0.000000 0.000000 0.000000 6.111968 0.000000 2.604657 0.000000 10.683373 8.965724 3.853357 0.000000 0.377367 0.000000 0.000000 1.482235 0.000000 0.000000 9.960822 7.587515 1.318950 0.000000 9.564895 7.530335 1.628905 0.000000 8.609387 8.121239 0.676211 8.514683 1.762030 0.377367 0.000000 0.000000 1.628905 0.377367 0.000000 0.000000 2.288830 0.000000 1.628905 1.134796 1.134796 0.000000 0.000000 0.377367 10.135483 0.676211 1.318950 8.785881 0.000000
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Prog_834 0.0 0.000000 0.853256 4.908651 8.404946 0.000000 8.726710 0.488810 0.000000 0.0 7.360462 9.753596 0.000000 0.488810 0.488810 6.329975 7.409196 0.000000 8.978144 0.0 12.290195 7.716345 6.581538 0.0 0.000000 0.0 0.488810 0.853256 0.000000 0.488810 0.488810 6.968233 0.853256 8.723961 9.810427 0.000000 0.000000 9.838023 0.000000 0.0 8.507628 0.488810 5.354924 5.205256 5.661187 6.153235 7.324615 5.824095 0.000000 0.488810 0.0 5.464396 7.627927 0.000000 7.416027 8.622800 0.000000 0.0 7.633798 0.0 0.000000 0.0 4.829012 8.387678 0.000000 0.853256 0.000000 5.369071 0.000000 4.132145 7.997032 7.651268 7.994753 0.000000 0.000000 0.853256 10.953581 0.000000 5.649643 2.331380 3.416688 0.000000 0.48881 0.000000 0.000000 0.000000 0.000000 12.011451 6.441285 4.700649 0.000000 10.204335 2.442586 6.831881 0.000000 0.000000 0.000000 6.958909 0.000000 7.830655 0.488810 0.000000 0.0 10.247571 6.831881 0.000000 0.000000 6.421058 6.224995 8.241547 0.000000 8.628692 0.000000 7.062654 0.000000 8.334599 5.369071 4.289184 0.000000 0.000000 0.488810 0.488810 7.130662 3.619651 7.276641 0.000000 6.774578 0.853256 6.977496 4.228404 5.626276 0.000000 0.0 7.466244 7.426210 8.432153 0.488810 3.917912 6.921001 1.385788 0.000000 0.000000 6.051642 0.000000 0.0000 0.000000 0.000000 8.061609 6.474379 10.446633 0.000000 0.853256 0.000000 0.000000 0.000000 1.385788 6.954225 0.000000 6.386704 0.0 0.000000 0.000000 6.285915 10.786092 0.000000 0.488810 0.000000 8.323744 0.000000 0.00000 0.000000 6.270925 7.250132 0.488810 0.488810 5.750353 7.868492 0.000000 0.0 0.000000 0.000000 8.865401 0.000000 7.147175 7.820396 0.000000 3.521736 6.593637 0.853256 0.000000 7.710801 6.944809 7.367526 0.488810 5.369071 7.840842 8.385941 5.813788 7.000397 6.308114 9.447667 2.545830 0.000000 1.773878 0.0 5.979709 0.000000 0.000000 0.000000 8.559440 6.968233 6.972872 0.000000 1.143955 8.512416 0.488810 0.000000 0.488810 0.853256 0.000000 8.065959 0.000000 8.202578 8.761983 7.685587 9.071939 0.488810 7.075652 6.351510 8.314636 0.000000 8.341789 7.791800 6.454615 6.605636 6.581538 7.992470 2.642176 5.020429 6.042844 0.000000 4.965622 5.369071 1.773878 0.000000 7.679924 0.488810 8.172645 8.035237 0.000000 5.090409 10.305727 6.569336 4.318640 9.172161 0.000000
Prog_840 0.0 0.000000 0.000000 2.279348 7.726871 0.000000 9.036788 0.000000 0.470364 0.0 7.361369 11.059691 0.000000 0.470364 0.000000 8.488206 7.169977 0.000000 9.540224 0.0 11.822417 2.988822 5.620069 0.0 0.000000 0.0 0.000000 0.000000 0.000000 4.521751 0.000000 6.807511 0.824497 8.245957 9.201694 0.000000 0.000000 9.697179 0.000000 0.0 7.956896 0.000000 0.000000 5.009981 5.770268 0.470364 7.716333 5.780421 0.000000 0.470364 0.0 5.790503 6.322271 0.000000 8.535433 8.191833 0.000000 0.0 8.390505 0.0 4.313788 0.0 4.285552 7.783496 4.135430 4.806433 0.000000 5.333309 0.470364 3.967854 7.295639 7.490673 7.662454 0.470364 0.000000 1.345870 10.968832 0.470364 5.490002 5.305455 0.000000 0.470364 0.00000 5.550580 0.000000 0.000000 0.000000 11.554941 5.319449 5.718402 0.000000 10.483249 6.989196 4.447233 0.000000 0.000000 0.000000 7.481367 0.000000 7.913732 0.000000 0.470364 0.0 10.330969 8.135599 4.786421 0.000000 6.416425 5.597275 7.788535 0.000000 8.193733 0.000000 7.963595 0.000000 7.888139 7.563035 0.000000 0.000000 0.000000 0.470364 0.470364 8.649226 7.876354 7.968043 0.000000 6.504809 6.435826 7.565973 3.778223 5.305455 0.000000 0.0 7.391489 8.566567 8.402059 0.000000 1.108609 6.889533 7.166110 0.000000 0.000000 7.154447 0.470364 0.0000 0.470364 0.000000 7.934339 7.061752 10.882800 0.824497 0.824497 0.000000 0.000000 0.000000 6.390145 6.944746 4.786421 7.023795 0.0 0.000000 0.470364 0.470364 10.671634 5.502323 1.108609 0.000000 7.676114 0.000000 0.00000 0.000000 7.530319 5.465040 0.824497 0.000000 5.820334 7.890484 0.000000 0.0 0.000000 0.000000 7.662454 0.000000 8.064675 3.818196 0.000000 6.880122 3.462305 0.000000 0.000000 7.192963 7.974690 8.378859 0.000000 7.496844 7.208086 8.416779 6.699294 3.778223 11.351206 8.940471 6.251046 0.000000 7.302700 0.0 5.770268 0.000000 0.000000 0.000000 7.586371 5.820334 7.840410 0.000000 5.653596 8.780218 0.000000 0.000000 1.108609 1.108609 0.470364 7.330607 0.000000 8.247787 7.927502 7.793557 7.869236 6.622361 7.763162 7.637537 6.736276 0.824497 8.591290 6.429388 6.605327 6.486320 6.152863 6.390145 1.345870 0.470364 7.106828 0.000000 0.000000 1.108609 1.886828 0.470364 7.295638 6.666823 9.033608 8.624076 0.000000 0.824497 9.905184 7.049211 4.070716 8.388847 5.233373
Prog_846 0.0 0.601281 4.438460 0.601281 6.984660 0.000000 9.429883 0.601281 3.503508 0.0 1.351169 11.559900 1.351169 0.000000 0.000000 8.713630 7.257543 0.000000 9.726954 0.0 11.339274 2.848949 6.135173 0.0 0.000000 0.0 0.601281 0.000000 0.000000 4.661176 4.505677 7.296025 0.000000 7.598904 8.675824 0.000000 0.000000 9.948473 0.000000 0.0 8.296182 0.000000 1.024409 1.024409 0.601281 0.601281 7.614214 5.350986 0.000000 0.000000 0.0 4.133070 6.625341 0.000000 8.187794 5.761750 2.499160 0.0 7.673879 0.0 4.631389 0.0 4.367957 7.782897 4.600973 4.904749 0.000000 4.690361 0.000000 0.000000 6.899748 8.277071 6.713278 0.000000 0.601281 0.000000 10.816568 0.000000 0.000000 5.841969 1.024409 0.000000 0.00000 5.586545 0.000000 0.000000 0.000000 10.558648 5.586545 6.948879 0.000000 10.539228 7.799734 1.617416 0.000000 5.256577 0.000000 8.250373 0.000000 7.978953 0.000000 0.601281 0.0 9.899327 8.765974 5.275959 0.000000 6.924523 1.351169 6.930650 0.000000 7.410065 0.000000 7.602747 0.000000 3.745184 7.587314 0.601281 0.000000 1.617416 0.601281 0.000000 9.160765 8.447014 7.527925 0.000000 2.036460 6.802858 8.264997 0.601281 1.617416 0.601281 0.0 8.036908 8.860482 8.361144 0.000000 0.601281 1.351169 7.547994 0.000000 1.842099 7.135524 0.000000 0.0000 1.024409 0.601281 7.990732 6.861769 11.331770 0.000000 0.000000 0.000000 0.000000 0.000000 6.547731 6.266941 5.069313 6.422877 0.0 0.000000 0.000000 0.601281 10.486649 6.058900 0.601281 1.351169 7.884253 0.000000 0.00000 0.000000 7.670221 1.024409 1.617416 4.631389 0.601281 6.948880 0.000000 0.0 0.000000 0.000000 6.829338 0.601281 8.813173 2.207717 0.000000 7.673879 3.903105 0.000000 0.000000 1.617416 8.729533 8.507708 3.999533 8.250373 5.113079 6.555683 7.365525 5.867747 12.413220 8.298552 6.698989 0.000000 8.143634 0.0 0.000000 0.000000 0.000000 4.293831 7.839359 1.351169 7.724135 0.000000 5.917962 8.143634 0.000000 0.000000 0.000000 1.024409 0.000000 6.482489 0.000000 8.338278 7.776107 5.705679 7.342729 6.789433 6.880884 7.571714 1.617416 0.000000 9.039839 6.809524 0.601281 4.215689 3.042448 2.499161 0.000000 0.601281 7.156591 4.293831 0.000000 1.842099 2.499161 1.024409 7.440445 6.727426 8.657468 8.554091 0.000000 0.601281 10.016310 6.266941 1.617416 6.387673 5.586545
Prog_852 0.0 0.000000 5.144567 4.963769 6.550013 0.000000 7.687866 0.000000 4.864096 0.0 1.029700 10.754864 0.000000 0.000000 0.000000 5.964730 6.928672 1.029700 5.642562 0.0 12.087729 1.029700 5.988593 0.0 0.000000 0.0 0.000000 0.000000 0.000000 0.000000 5.701503 7.658416 0.000000 9.280291 7.665835 0.000000 1.029700 4.225521 0.000000 0.0 7.433492 0.000000 0.000000 0.000000 0.000000 0.000000 7.665835 6.581736 1.624428 0.000000 0.0 2.857900 7.024124 0.000000 2.857900 5.342724 3.754801 0.0 7.846442 0.0 4.303692 0.0 1.624428 5.342724 0.000000 0.000000 0.000000 5.785633 1.029700 4.377844 7.786449 8.813554 8.582206 0.000000 0.000000 0.000000 10.699009 3.374955 0.000000 6.227925 0.000000 0.000000 0.00000 0.000000 1.029700 0.000000 0.000000 10.307866 0.000000 7.793239 0.000000 11.280967 7.484730 1.029700 0.000000 6.035165 0.000000 8.316000 0.000000 7.897752 0.000000 0.000000 0.0 8.901025 7.433492 0.000000 0.000000 4.757022 5.988593 7.177327 5.549372 3.051580 2.044323 6.035165 0.000000 5.549372 6.839636 0.000000 0.000000 2.369158 1.029700 0.000000 9.122087 9.760903 1.624428 0.000000 3.051580 5.915787 8.662278 0.000000 0.000000 0.000000 0.0 6.702080 7.258081 8.947422 1.624428 1.624428 0.000000 7.069581 0.000000 2.634127 6.702080 0.000000 1.0297 1.029700 1.029700 4.303692 8.916657 10.381810 0.000000 0.000000 0.000000 0.000000 0.000000 8.080946 6.207736 0.000000 0.000000 0.0 0.000000 0.000000 0.000000 9.442418 6.166490 0.000000 0.000000 7.113649 0.000000 0.00000 0.000000 7.218268 6.012067 1.029699 4.963769 2.044323 1.029699 0.000000 0.0 0.000000 0.000000 4.225521 0.000000 8.925956 2.044323 0.000000 5.940466 8.530314 0.000000 0.000000 1.624428 8.233526 7.069581 5.227124 7.910300 6.207736 3.051580 6.484395 7.102758 12.083580 5.342724 8.904165 0.000000 8.058575 0.0 0.000000 1.029699 0.000000 5.056998 6.324838 0.000000 8.919764 0.000000 1.624428 6.057900 0.000000 0.000000 0.000000 0.000000 3.862034 8.024354 0.000000 2.369158 6.940955 2.044323 3.051580 3.961844 1.029699 7.047031 7.597649 0.000000 7.779626 2.369158 0.000000 4.448371 5.227124 1.029699 0.000000 2.044323 7.334552 4.963769 0.000000 1.029699 8.156622 1.029699 4.757022 7.238312 4.377844 6.865640 0.000000 0.000000 9.622873 1.029699 1.624428 7.353054 0.000000
Prog_810 0.0 0.329207 4.905182 5.418886 7.896968 0.000000 8.456943 0.000000 5.855583 0.0 1.190055 10.040571 0.000000 0.000000 0.000000 7.535684 6.353001 0.000000 8.873585 0.0 12.657222 1.190055 6.790592 0.0 0.000000 0.0 0.000000 0.000000 0.329207 5.486432 0.000000 7.175333 0.000000 9.848974 7.799083 0.000000 0.000000 9.650239 0.000000 0.0 7.323519 5.254247 0.329207 7.215698 0.597074 0.000000 7.464188 6.855898 0.000000 0.000000 0.0 7.404325 4.867675 0.597074 0.822908 1.725482 0.000000 0.0 8.157440 0.0 0.000000 0.0 0.822908 8.095245 0.000000 5.338913 0.329207 7.898519 0.000000 0.000000 7.553509 6.948628 7.741496 0.000000 0.000000 0.000000 10.441681 0.000000 0.329207 9.414275 0.822908 0.000000 0.00000 0.000000 0.329207 0.000000 0.000000 11.098739 7.436703 8.508625 0.000000 10.712852 7.328129 0.329207 0.000000 0.000000 0.597074 1.343656 0.000000 8.451672 0.000000 0.000000 0.0 10.522342 7.810659 0.000000 6.708111 4.604391 8.095245 4.203981 0.000000 7.302589 0.000000 6.635580 0.000000 6.195408 8.459046 0.329207 0.329207 0.000000 6.144043 0.000000 7.624564 7.884503 5.918074 0.000000 6.264379 7.918526 5.057306 0.000000 6.149262 0.329207 0.0 8.474724 8.127339 9.339759 6.708111 7.553509 0.822908 6.567031 4.816099 4.880286 1.343656 7.177889 0.0000 0.000000 0.000000 8.153549 7.146912 9.414818 0.000000 0.597074 0.000000 0.329207 5.749602 0.597074 6.012749 0.597074 6.679534 0.0 0.329207 0.000000 0.000000 10.873446 0.000000 0.000000 0.000000 0.822909 0.000000 0.00000 0.000000 0.822909 0.822909 6.316347 4.989082 1.018130 6.650381 0.000000 0.0 0.000000 0.000000 7.704744 0.597074 8.338560 6.164809 0.597074 5.861956 8.188194 0.000000 0.597074 1.609085 6.122973 6.969433 0.329207 5.012184 1.018130 7.912400 7.445215 6.401925 3.458985 8.250234 8.179292 0.000000 7.281352 0.0 0.329207 0.000000 6.406292 3.647836 6.436492 4.099997 7.601901 0.000000 0.000000 8.137880 0.597074 0.329207 0.000000 6.987031 0.000000 6.297666 0.000000 1.018130 7.950272 6.190352 2.115099 0.329207 7.228084 9.433656 3.705666 0.329207 6.085345 1.190055 0.000000 3.556499 4.748924 1.190055 0.000000 0.329207 1.725482 2.838296 4.374125 0.597074 0.822909 6.302358 6.357517 0.822909 8.624657 1.609085 4.262954 0.000000 7.822143 7.668850 8.067944 8.904780 0.000000

1656 rows × 256 columns

%time scbool = scBoolSeq().fit(ref_data)
Computing bimodality index for 110/256 genes
Computing bimodality index for 178/256 genes
CPU times: user 7.48 s, sys: 566 ms, total: 8.05 s
Wall time: 2.37 s

2. Generate Boolean dynamics

We use minibn to define a simple Boolean network and generate a trajectory from it: it consists of a transcription factor which progressively activates its target genes.

bn = minibn.BooleanNetwork({
    "tf": 1,
    "gene1": "tf",
    "gene2": "tf",
    "gene3": "tf",
    "gene4": "tf",
    "gene5": "tf",
    "gene6": "tf",
    "gene7": "tf",
    "gene8": "tf",
    "gene9": "tf"})
bn.influence_graph()
# computing graph layout...
../../_images/dcff95854c45500380d17e7b7387701057421d06e6be0f0c9432d7200c489c44.svg
dynamics = minibn.FullyAsynchronousDynamics(bn)
## initial state: all inactive but tf
x0 = bn.zero()
x0["tf"] = 1
boolean_trace = pd.DataFrame(dynamics.random_walk(x0, steps=10))
boolean_trace
tf gene1 gene2 gene3 gene4 gene5 gene6 gene7 gene8 gene9
0 1 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 1 0
2 1 1 0 0 0 0 0 0 1 0
3 1 1 1 0 0 0 0 0 1 0
4 1 1 1 0 0 0 1 0 1 0
5 1 1 1 0 0 0 1 0 1 1
6 1 1 1 0 1 0 1 0 1 1
7 1 1 1 1 1 0 1 0 1 1
8 1 1 1 1 1 0 1 1 1 1
9 1 1 1 1 1 1 1 1 1 1

3. Synthetic scRNA-Seq generation

# we generate 100 samples per state
counts = scbool.sample_counts(boolean_trace, n_samples_per_state=100, random_state=_rng_seed)
counts
/opt/conda/lib/python3.11/site-packages/scboolseq/simulation.py:860: RuntimeWarning: Precision loss occurred in moment calculation due to catastrophic cancellation. This occurs when the data are nearly identical. Results may be unreliable.
  "Skewness": ss.skew(trajectory),
/opt/conda/lib/python3.11/site-packages/scboolseq/simulation.py:861: RuntimeWarning: Precision loss occurred in moment calculation due to catastrophic cancellation. This occurs when the data are nearly identical. Results may be unreliable.
  "Kurtosis": ss.kurtosis(trajectory),
tf gene1 gene2 gene3 gene4 gene5 gene6 gene7 gene8 gene9
0 11.807442 7.296882 6.235518 0.000000 3.728489 0.896689 0.000000 6.250985 6.451066 1.153216
1 11.270470 4.335632 2.941213 0.653300 4.193471 0.000000 2.051246 1.048464 12.188739 6.098412
2 11.383729 7.862695 4.459277 2.425311 1.572160 2.859352 2.684933 2.776694 9.660892 1.364609
3 11.686200 10.243716 9.310534 1.695683 1.370511 0.000000 2.500247 0.000000 10.594029 4.670935
4 10.611847 11.699445 8.944868 0.980907 3.065523 0.000000 6.912807 2.933879 9.442035 2.975051
... ... ... ... ... ... ... ... ... ... ...
5 10.876741 9.272842 8.043451 4.620983 2.135445 2.915461 8.686909 0.000000 10.339349 9.306314
6 11.564131 9.671571 9.264861 2.757219 9.044113 0.000000 8.765493 0.000000 9.170733 10.002612
7 11.148507 9.768933 10.220935 7.695293 8.396265 0.000000 8.400632 0.860203 9.423705 9.375922
8 11.523779 8.637396 6.470778 6.676360 9.036786 2.761117 7.102186 0.000000 12.792020 10.234925
9 11.027899 8.077975 9.090409 7.902888 7.696980 7.253324 8.602953 7.014761 9.252199 8.096201

1000 rows × 10 columns

Export to CSV with custom cell ID for each row:

cells = [f"step{x}_{y}"  for y in range(100) for x in boolean_trace.index]
export = counts.set_index(pd.Index(cells, name="CellId"))
export.to_csv("synthetic_scrnaseq.csv")

4. Visualization

We use scikit-learn to project the generated scRNA-Seq dataset and visualize the proximity of cells depending on the number of active genes.

import sklearn
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from sklearn.pipeline import Pipeline, FunctionTransformer
from sklearn.manifold import LocallyLinearEmbedding, SpectralEmbedding

Perform projection:

vis_pipeline = Pipeline([
    ('pca', PCA()),
    ('subset_pca', FunctionTransformer(lambda x: x.iloc[:, :4])),
    ('lle', LocallyLinearEmbedding(n_neighbors=40, n_components=2, random_state=_rng_seed)),
])
with sklearn.config_context(transform_output="pandas"):
    _pre_vis = vis_pipeline.fit_transform(counts)

Attach labels to cells from ground-truth Boolean states, and plot the cells in projected 2D space:

labels = boolean_trace.sum(axis=1)
labels.name = "n_active_genes"
vis_frame = _pre_vis.join(labels).reset_index(drop=True)
vis_frame.columns = ["dim0", "dim1", "n_active_genes"]
vis_frame.plot.scatter(x="dim0", y="dim1", c="n_active_genes", colormap="viridis");
../../_images/6ffa49de3d272585bd2089c96c9ee101651ff5cf44915f4367e520ba5084ff48.png