In this tutorial, we will use trajectory wise analysis to expore regulatory mechanisms of hematopoiesis.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# import Scribe as sb
import sys
import os
# import scanpy as sc
import dynamo as dyn
import seaborn as sns
# filter warnings for cleaner tutorials
import warnings
warnings.filterwarnings('ignore')
dyn.dynamo_logger.main_silence()
<frozen importlib._bootstrap>:228: RuntimeWarning: scipy._lib.messagestream.MessageStream size changed, may indicate binary incompatibility. Expected 56 from C header, got 64 from PyObject
|-----> setting visualization default mode in dynamo. Your customized matplotlib settings might be overritten.
/Users/random/opt/anaconda3/envs/dynamo-dev/lib/python3.9/site-packages/nxviz/__init__.py:18: UserWarning: nxviz has a new API! Version 0.7.3 onwards, the old class-based API is being deprecated in favour of a new API focused on advancing a grammar of network graphics. If your plotting code depends on the old API, please consider pinning nxviz at version 0.7.3, as the new API will break your old code. To check out the new API, please head over to the docs at https://ericmjl.github.io/nxviz/ to learn more. We hope you enjoy using it! (This deprecation message will go away in version 1.0.) warnings.warn(
adata_labeling = dyn.sample_data.hematopoiesis()
take a glance at what is in adata
object. All observations, embedding layers and other data in adata
are computed within dynamo
. Please refer to other dynamo tutorials regarding how to obtain these values from metadata and raw new/total and (or) raw spliced/unspliced gene expression values.
adata_labeling
AnnData object with n_obs × n_vars = 1947 × 1956 obs: 'batch', 'time', 'cell_type', 'nGenes', 'nCounts', 'pMito', 'pass_basic_filter', 'new_Size_Factor', 'initial_new_cell_size', 'total_Size_Factor', 'initial_total_cell_size', 'spliced_Size_Factor', 'initial_spliced_cell_size', 'unspliced_Size_Factor', 'initial_unspliced_cell_size', 'Size_Factor', 'initial_cell_size', 'ntr', 'cell_cycle_phase', 'leiden', 'control_point_pca', 'inlier_prob_pca', 'obs_vf_angle_pca', 'pca_ddhodge_div', 'pca_ddhodge_potential', 'acceleration_pca', 'curvature_pca', 'n_counts', 'mt_frac', 'jacobian_det_pca', 'manual_selection', 'divergence_pca', 'curv_leiden', 'curv_louvain', 'SPI1->GATA1_jacobian', 'jacobian', 'umap_ori_leiden', 'umap_ori_louvain', 'umap_ddhodge_div', 'umap_ddhodge_potential', 'curl_umap', 'divergence_umap', 'acceleration_umap', 'control_point_umap_ori', 'inlier_prob_umap_ori', 'obs_vf_angle_umap_ori', 'curvature_umap_ori' var: 'gene_name', 'gene_id', 'nCells', 'nCounts', 'pass_basic_filter', 'use_for_pca', 'frac', 'ntr', 'time_3_alpha', 'time_3_beta', 'time_3_gamma', 'time_3_half_life', 'time_3_alpha_b', 'time_3_alpha_r2', 'time_3_gamma_b', 'time_3_gamma_r2', 'time_3_gamma_logLL', 'time_3_delta_b', 'time_3_delta_r2', 'time_3_bs', 'time_3_bf', 'time_3_uu0', 'time_3_ul0', 'time_3_su0', 'time_3_sl0', 'time_3_U0', 'time_3_S0', 'time_3_total0', 'time_3_beta_k', 'time_3_gamma_k', 'time_5_alpha', 'time_5_beta', 'time_5_gamma', 'time_5_half_life', 'time_5_alpha_b', 'time_5_alpha_r2', 'time_5_gamma_b', 'time_5_gamma_r2', 'time_5_gamma_logLL', 'time_5_bs', 'time_5_bf', 'time_5_uu0', 'time_5_ul0', 'time_5_su0', 'time_5_sl0', 'time_5_U0', 'time_5_S0', 'time_5_total0', 'time_5_beta_k', 'time_5_gamma_k', 'use_for_dynamics', 'gamma', 'gamma_r2', 'use_for_transition', 'gamma_k', 'gamma_b' uns: 'PCs', 'VecFld_pca', 'VecFld_umap', 'X_umap_neighbors', 'cell_phase_genes', 'cell_type_colors', 'dynamics', 'explained_variance_ratio_', 'feature_selection', 'grid_velocity_pca', 'grid_velocity_umap', 'grid_velocity_umap_ori_perturbation', 'grid_velocity_umap_test', 'jacobian_pca', 'leiden', 'neighbors', 'pca_mean', 'pp', 'response' obsm: 'X', 'X_pca', 'X_pca_SparseVFC', 'X_umap', 'X_umap_SparseVFC', 'X_umap_ori_perturbation', 'X_umap_test', 'acceleration_pca', 'acceleration_umap', 'cell_cycle_scores', 'curvature_pca', 'curvature_umap', 'j_delta_x_perturbation', 'velocity_pca', 'velocity_pca_SparseVFC', 'velocity_umap', 'velocity_umap_SparseVFC', 'velocity_umap_ori_perturbation', 'velocity_umap_test' layers: 'M_n', 'M_nn', 'M_t', 'M_tn', 'M_tt', 'X_new', 'X_total', 'velocity_alpha_minus_gamma_s' obsp: 'X_umap_connectivities', 'X_umap_distances', 'connectivities', 'cosine_transition_matrix', 'distances', 'fp_transition_rate', 'moments_con', 'pca_ddhodge', 'perturbation_transition_matrix', 'umap_ddhodge'
pca_dim = [0, 1]
dyn.pl.streamline_plot(
adata_labeling,
color="cell_type",
use_smoothed=False,
cmap="bwr",
basis="pca",
sym_c=True,
x=pca_dim[0],
y=pca_dim[1],
frontier=True,
sort="abs",
alpha=0.2,
pointsize=0.1,
despline=True,
despline_sides=["right", "top"],
deaxis=False,
save_show_or_return="return",
)
[<AxesSubplot:title={'center':'cell_type'}>]
HSC_cells = dyn.tl.select_cell(adata_labeling, "cell_type", "HSC")
Meg_cells = dyn.tl.select_cell(adata_labeling, "cell_type", "Meg")
Ery_cells = dyn.tl.select_cell(adata_labeling, "cell_type", "Ery")
Bas_cells = dyn.tl.select_cell(adata_labeling, "cell_type", "Bas")
Mon_cells = dyn.tl.select_cell(adata_labeling, "cell_type", "Mon")
Neu_cells = dyn.tl.select_cell(adata_labeling, "cell_type", "Neu")
# dyn.pd.fate(adata_labeling, init_cells=adata_labeling.obs_names[Mon_cells[0]], basis='pca', direction='backward', interpolation_num=500)
dyn.pd.fate(
adata_labeling,
init_cells=adata_labeling.obs_names[Meg_cells[0]],
basis="pca",
direction="backward",
interpolation_num=500,
)
integration with ivp solver: 100%|██████████| 1/1 [00:00<00:00, 13.42it/s] uniformly sampling points along a trajectory: 100%|██████████| 1/1 [00:00<00:00, 82.51it/s]
AnnData object with n_obs × n_vars = 1947 × 1956 obs: 'batch', 'time', 'cell_type', 'nGenes', 'nCounts', 'pMito', 'pass_basic_filter', 'new_Size_Factor', 'initial_new_cell_size', 'total_Size_Factor', 'initial_total_cell_size', 'spliced_Size_Factor', 'initial_spliced_cell_size', 'unspliced_Size_Factor', 'initial_unspliced_cell_size', 'Size_Factor', 'initial_cell_size', 'ntr', 'cell_cycle_phase', 'leiden', 'control_point_pca', 'inlier_prob_pca', 'obs_vf_angle_pca', 'pca_ddhodge_div', 'pca_ddhodge_potential', 'acceleration_pca', 'curvature_pca', 'n_counts', 'mt_frac', 'jacobian_det_pca', 'manual_selection', 'divergence_pca', 'curv_leiden', 'curv_louvain', 'SPI1->GATA1_jacobian', 'jacobian', 'umap_ori_leiden', 'umap_ori_louvain', 'umap_ddhodge_div', 'umap_ddhodge_potential', 'curl_umap', 'divergence_umap', 'acceleration_umap', 'control_point_umap_ori', 'inlier_prob_umap_ori', 'obs_vf_angle_umap_ori', 'curvature_umap_ori' var: 'gene_name', 'gene_id', 'nCells', 'nCounts', 'pass_basic_filter', 'use_for_pca', 'frac', 'ntr', 'time_3_alpha', 'time_3_beta', 'time_3_gamma', 'time_3_half_life', 'time_3_alpha_b', 'time_3_alpha_r2', 'time_3_gamma_b', 'time_3_gamma_r2', 'time_3_gamma_logLL', 'time_3_delta_b', 'time_3_delta_r2', 'time_3_bs', 'time_3_bf', 'time_3_uu0', 'time_3_ul0', 'time_3_su0', 'time_3_sl0', 'time_3_U0', 'time_3_S0', 'time_3_total0', 'time_3_beta_k', 'time_3_gamma_k', 'time_5_alpha', 'time_5_beta', 'time_5_gamma', 'time_5_half_life', 'time_5_alpha_b', 'time_5_alpha_r2', 'time_5_gamma_b', 'time_5_gamma_r2', 'time_5_gamma_logLL', 'time_5_bs', 'time_5_bf', 'time_5_uu0', 'time_5_ul0', 'time_5_su0', 'time_5_sl0', 'time_5_U0', 'time_5_S0', 'time_5_total0', 'time_5_beta_k', 'time_5_gamma_k', 'use_for_dynamics', 'gamma', 'gamma_r2', 'use_for_transition', 'gamma_k', 'gamma_b' uns: 'PCs', 'VecFld_pca', 'VecFld_umap', 'X_umap_neighbors', 'cell_phase_genes', 'cell_type_colors', 'dynamics', 'explained_variance_ratio_', 'feature_selection', 'grid_velocity_pca', 'grid_velocity_umap', 'grid_velocity_umap_ori_perturbation', 'grid_velocity_umap_test', 'jacobian_pca', 'leiden', 'neighbors', 'pca_mean', 'pp', 'response', 'fate_pca' obsm: 'X', 'X_pca', 'X_pca_SparseVFC', 'X_umap', 'X_umap_SparseVFC', 'X_umap_ori_perturbation', 'X_umap_test', 'acceleration_pca', 'acceleration_umap', 'cell_cycle_scores', 'curvature_pca', 'curvature_umap', 'j_delta_x_perturbation', 'velocity_pca', 'velocity_pca_SparseVFC', 'velocity_umap', 'velocity_umap_SparseVFC', 'velocity_umap_ori_perturbation', 'velocity_umap_test' layers: 'M_n', 'M_nn', 'M_t', 'M_tn', 'M_tt', 'X_new', 'X_total', 'velocity_alpha_minus_gamma_s' obsp: 'X_umap_connectivities', 'X_umap_distances', 'connectivities', 'cosine_transition_matrix', 'distances', 'fp_transition_rate', 'moments_con', 'pca_ddhodge', 'perturbation_transition_matrix', 'umap_ddhodge'
adata_labeling.uns["fate_pca"]
{'init_states': array([[ 5.2919745 , -1.6043311 , 0.19472672, -0.6521011 , -0.3910545 , -0.17425747, -0.7500424 , 1.9489013 , -0.62630427, 0.435594 , 0.8112104 , -0.31494737, -0.23104656, 0.1572339 , -0.6964127 , 0.8587724 , -0.38267198, 0.0734547 , -0.5838866 , -0.14543599, -0.44422174, 0.07856439, 0.46921268, 0.00724712, 0.8368773 , 0.03474469, -0.24431682, 0.23370868, -0.06652449, -0.06224704]], dtype=float32), 'init_cells': 'CCATCCTGTGGA-JL12_0', 'average': False, 't': [[-0.09209527369054389, -0.1840362526337344, -0.2759487227556464, -0.3678611928775584, -0.4597736629994704, -0.5516861331213825, -0.6435986032432945, -0.7355110733652065, -0.8274235434871184, -0.9193360136090304, -1.0112484837309423, -1.1031609538528542, -1.2038043729783503, -1.3291018572815356, -1.454399341584721, -1.5796968258879063, -1.7049943101910916, -1.830291794494277, -1.9555892787974622, -2.0808867631006476, -2.206184247403833, -2.3314817317070182, -2.4567792160102035, -2.582076700313389, -2.707374184616574, -2.832671668919759, -2.957969153222944, -3.083266637526129, -3.2085641218293137, -3.3338616061324986, -3.4591590904356835, -3.5844565747388684, -3.7097540590420532, -3.835051543345238, -3.960349027648423, -4.085646511951608, -4.210943996254793, -4.336241480557978, -4.4615389648611625, -4.586836449164347, -4.712133933467532, -4.837431417770717, -4.962728902073902, -5.088026386377087, -5.213323870680272, -5.338621354983457, -5.463918839286642, -5.5892163235898265, -5.714513807893011, -5.839811292196196, -5.965108776499381, -6.090406260802566, -6.215703745105751, -6.341001229408936, -6.466298713712121, -6.591596198015306, -6.716893682318492, -6.842191166621678, -6.967488650924864, -7.0927861352280495, -7.218083619531235, -7.343381103834421, -7.468678588137607, -7.5939760724407925, -7.719273556743978, -7.844571041047164, -7.96986852535035, -8.095166009653536, -8.220463493956721, -8.345760978259907, -8.471058462563093, -8.596355946866279, -8.721653431169464, -8.84695091547265, -8.972248399775836, -9.097545884079022, -9.222843368382208, -9.348140852685393, -9.473438336988579, -9.598735821291765, -9.72403330559495, -9.849330789898136, -9.974628274201322, -10.099925758504508, -10.225223242807695, -10.350520727110883, -10.47581821141407, -10.649685975321775, -10.933505320172948, -11.217324665024119, -11.50114400987529, -11.784963354726461, -12.068782699577632, -12.352602044428803, -12.636421389279976, -12.920240734131147, -13.204060078982318, -13.48787942383349, -13.771698768684661, -14.055518113535832, -14.339337458387003, -14.623156803238176, -14.906976148089349, -15.19079549294052, -15.474614837791691, -15.758434182642864, -16.042253527494037, -16.326072872345208, -16.60989221719638, -16.89371156204755, -17.17753090689872, -17.46135025174989, -17.745169596601063, -18.028988941452237, -18.312808286303408, -18.596627631154583, -18.880446976005754, -19.164266320856928, -19.4480856657081, -19.77673484871996, -20.21564232100262, -20.654549793285277, -21.093457265567935, -21.532364737850592, -21.97127221013325, -22.410179682415908, -22.849087154698566, -23.287994626981224, -23.72690209926388, -24.16580957154654, -24.604717043829197, -25.043624516111855, -25.482531988394513, -25.92143946067717, -26.36034693295983, -26.799254405242486, -27.238161877525144, -27.677069349807798, -28.115976822090456, -28.55488429437311, -28.993791766655768, -29.432699238938422, -29.87160671122108, -30.310514183503734, -30.749421655786392, -31.188329128069046, -31.63389280238568, -32.21055661438199, -32.787220426378305, -33.36388423837462, -33.94054805037093, -34.51721186236724, -35.09387567436355, -35.670539486359864, -36.247203298356176, -36.82386711035249, -37.4005309223488, -37.97719473434511, -38.553858546341424, -39.130522358337736, -39.70718617033405, -40.28384998233036, -40.86051379432667, -41.43717760632298, -42.013841418319295, -42.590505230315614, -43.167169042311926, -43.743832854308245, -44.32049666630456, -44.897160478300876, -45.47382429029719, -46.05048810229351, -46.62715191428982, -47.20381572628614, -47.78047953828245, -48.35714335027876, -48.93380716227508, -49.51047097427139, -50.08713478626771, -50.66379859826402, -51.457930494185554, -52.25386083609766, -53.04979117800976, -53.84572151992187, -54.64165186183397, -55.437582203746075, -56.23351254565818, -57.02944288757028, -57.82537322948239, -58.62130357139449, -59.417233913306596, -60.2131642552187, -61.009094597130805, -61.80502493904291, -62.60095528095501, -63.39688562286712, -64.19281596477921, -64.98874630669131, -65.78467664860341, -66.58060699051552, -67.37653733242762, -68.17246767433971, -68.96839801625183, -69.76432835816394, -70.56025870007603, -71.49758491372887, -72.5379775863371, -73.57837025894534, -74.61876293155358, -75.65915560416181, -76.69954827677005, -77.73994094937828, -78.78033362198651, -79.82072629459475, -80.86111896720298, -81.90151163981122, -82.94190431241945, -83.98229698502769, -85.02268965763592, -86.06308233024416, -87.10347500285239, -88.14386767546063, -89.18426034806886, -90.2246530206771, -91.26504569328533, -92.30543836589356, -93.3458310385018, -94.38622371111003, -95.42661638371827, -96.4670090563265, -97.50740172893474, -98.54779440154299, -99.58818707415122, -100.74716522042993, -101.91621931250631, -103.0852734045827, -104.25432749665907, -105.42338158873545, -106.59243568081183, -107.76148977288821, -108.93054386496459, -110.09959795704097, -111.26865204911735, -112.43770614119373, -113.60676023327011, -114.77581432534649, -115.94486841742287, -117.11392250949925, -118.28297660157563, -119.452030693652, -120.62108478572839, -121.79013887780476, -122.95919296988114, -124.12824706195751, -125.30963449810734, -126.54295593288845, -127.77627736766955, -129.00959880245065, -130.24292023723177, -131.4762416720129, -132.709563106794, -133.94288454157513, -135.17620597635624, -136.40952741113736, -137.64284884591848, -138.87617028069957, -140.10949171548066, -141.34281315026178, -142.57613458504287, -143.80945601982398, -145.04277745460507, -146.2760988893862, -147.50942032416728, -148.7427417589484, -149.9760631937295, -151.29777613227543, -152.642042041841, -153.98630795140656, -155.33057386097212, -156.6748397705377, -158.01910568010325, -159.36337158966882, -160.70763749923438, -162.05190340879994, -163.3961693183655, -164.74043522793107, -166.0847011374966, -167.42896704706217, -168.7732329566277, -170.11749886619327, -171.4617647757588, -172.80603068532434, -174.1502965948899, -175.49456250445544, -176.838828414021, -178.18309432358654, -179.5273602331521, -180.87162614271764, -182.2158920522832, -183.56015796184874, -184.9044238714143, -186.24868978097984, -187.5929556905454, -188.93722160011095, -190.40727658841698, -192.2646526359592, -194.12202868350144, -195.97940473104367, -197.8367807785859, -199.69415682612814, -201.55153287367037, -203.4089089212126, -205.26628496875483, -207.12366101629706, -208.9810370638393, -210.83841311138153, -212.69578915892376, -214.553165206466, -216.41054125400822, -218.26791730155045, -220.1252933490927, -221.98266939663492, -223.84004544417715, -225.69742149171938, -227.5547975392616, -229.41217358680385, -231.26954963434608, -233.1269256818883, -234.98430172943054, -236.84167777697277, -238.699053824515, -240.5564298720572, -242.4138059195994, -244.27118196714162, -246.12855801468385, -247.98593406222608, -249.8433101097683, -251.70068615731054, -253.55806220485275, -255.41543825239498, -257.2728142999372, -259.1301903474794, -260.98756639502164, -262.8449424425639, -264.7023184901061, -266.55969453764834, -268.4170705851905, -270.27444663273275, -272.1318226802749, -273.98919872781715, -275.84657477535933, -278.5345457154527, -282.10617663439945, -285.6778075533462, -289.249438472293, -292.82106939123975, -296.3927003101865, -299.9643312291333, -303.53596214808005, -307.1075930670268, -310.6792239859736, -314.25085490492035, -317.8224858238671, -321.3941167428139, -324.96574766176064, -328.5373785807074, -332.1090094996542, -335.68064041860094, -339.2522713375477, -342.8239022564945, -346.39553317544124, -349.967164094388, -353.5387950133348, -357.11042593228154, -360.6820568512283, -364.2536877701751, -367.82531868912184, -371.3969496080686, -374.9685805270153, -378.54021144596203, -382.11184236490874, -385.68347328385545, -389.25510420280216, -392.8267351217489, -396.39836604069563, -399.96999695964234, -403.54162787858905, -408.60793447564873, -415.9114261098118, -423.2149177439749, -430.518409378138, -437.8219010123011, -445.1253926464642, -452.4288842806273, -459.7323759147904, -467.0358675489535, -474.3393591831166, -481.6428508172797, -488.9463424514428, -496.24983408560587, -503.55332571976896, -510.85681735393206, -518.1603089880952, -525.4638006222582, -532.7672922564212, -540.0707838905844, -547.3742755247474, -554.6777671589106, -561.9812587930737, -569.2847504272369, -576.5882420614, -583.8917336955632, -591.1952253297263, -598.4987169638895, -610.0467438477655, -622.9459154100089, -635.8450869722523, -648.7442585344957, -661.643430096739, -674.5426016589824, -687.441773221226, -700.3409447834695, -713.240116345713, -726.1392879079564, -739.0384594701999, -751.9376310324433, -764.8368025946868, -777.7359741569303, -790.6351457191739, -807.6960930486356, -826.7710242456421, -845.8459554426486, -864.920886639655, -883.9958178366614, -903.070749033668, -922.1456802306744, -941.220611427681, -960.2955426246876, -979.3704738216944, -1001.5399329820336, -1027.1559175077457, -1052.771902033458, -1078.38788655917, -1104.0038710848821, -1129.6198556105944, -1155.2358401363065, -1180.8518246620185, -1212.4411808243267, -1244.8677221217338, -1277.294263419141, -1309.7208047165484, -1342.1473460139555, -1374.5738873113633, -1413.1556733621726, -1452.6051294837698, -1492.0545856053668, -1531.5040417269638, -1570.9534978485606, -1617.1977142627388, -1663.8444189713268, -1710.4911236799148, -1757.1378283885026, -1809.4599048423263, -1863.451154130346, -1917.4424034183655, -1972.6950640301018, -2034.1580077743172, -2095.620951518532, -2157.106826394695, -2226.1530654289854, -2295.199304463276, -2365.6662023598396, -2442.395000641772, -2519.123798923705, -2600.896364878347, -2685.3969776182435, -2772.6168812887886, -2864.9702932116556, -2959.221250644914, -3059.5015062081316, -3162.172466274014, -3270.447709007518, -3382.767641304213, -3499.100940450617, -3622.1657604369093, -3748.787974086649, -3881.4095138890502, -4020.5982580406894, -4164.892884642795, -4314.9420972840835, -4472.37478153537, -4637.133346149822, -4808.82932811392, -4987.966190000511, -5175.010593036597, -5370.396439120071, -5574.528335918543, -5787.7845848121, -6010.519771404202, -6243.067022831977]], 'prediction': [array([[ 5.25701785, 5.22204597, 5.18701856, ..., -9.9033362 , -9.93557093, -9.96776573], [-1.60646992, -1.60857623, -1.61065363, ..., -2.84942146, -2.84611685, -2.84281243], [ 0.19787256, 0.20107412, 0.20433522, ..., 3.06745094, 3.07789704, 3.08834668], ..., [ 0.23255756, 0.23140911, 0.23026214, ..., 0.68195221, 0.6822364 , 0.68251551], [-0.06629712, -0.06608548, -0.06588903, ..., -1.28902938, -1.29009673, -1.29116093], [-0.06162954, -0.06102728, -0.06043941, ..., -0.32718502, -0.32672794, -0.32626966]])], 'VecFld_true': None, 'genes': ['pca_0', 'pca_1', 'pca_2', 'pca_3', 'pca_4', 'pca_5', 'pca_6', 'pca_7', 'pca_8', 'pca_9', 'pca_10', 'pca_11', 'pca_12', 'pca_13', 'pca_14', 'pca_15', 'pca_16', 'pca_17', 'pca_18', 'pca_19', 'pca_20', 'pca_21', 'pca_22', 'pca_23', 'pca_24', 'pca_25', 'pca_26', 'pca_27', 'pca_28', 'pca_29']}
adata_labeling.uns["fate_pca"]["prediction"][0]
array([[ 5.25701785, 5.22204597, 5.18701856, ..., -9.9033362 , -9.93557093, -9.96776573], [-1.60646992, -1.60857623, -1.61065363, ..., -2.84942146, -2.84611685, -2.84281243], [ 0.19787256, 0.20107412, 0.20433522, ..., 3.06745094, 3.07789704, 3.08834668], ..., [ 0.23255756, 0.23140911, 0.23026214, ..., 0.68195221, 0.6822364 , 0.68251551], [-0.06629712, -0.06608548, -0.06588903, ..., -1.28902938, -1.29009673, -1.29116093], [-0.06162954, -0.06102728, -0.06043941, ..., -0.32718502, -0.32672794, -0.32626966]])
dyn.pd.fate(
adata_labeling,
# init_cells=adata_labeling.obs_names[Meg_cells[0]],
init_cells=adata_labeling.obs_names[Meg_cells[2]],
basis="pca",
direction="backward",
interpolation_num=500,
)
integration with ivp solver: 100%|██████████| 1/1 [00:00<00:00, 12.21it/s] uniformly sampling points along a trajectory: 100%|██████████| 1/1 [00:00<00:00, 78.83it/s]
AnnData object with n_obs × n_vars = 1947 × 1956 obs: 'batch', 'time', 'cell_type', 'nGenes', 'nCounts', 'pMito', 'pass_basic_filter', 'new_Size_Factor', 'initial_new_cell_size', 'total_Size_Factor', 'initial_total_cell_size', 'spliced_Size_Factor', 'initial_spliced_cell_size', 'unspliced_Size_Factor', 'initial_unspliced_cell_size', 'Size_Factor', 'initial_cell_size', 'ntr', 'cell_cycle_phase', 'leiden', 'control_point_pca', 'inlier_prob_pca', 'obs_vf_angle_pca', 'pca_ddhodge_div', 'pca_ddhodge_potential', 'acceleration_pca', 'curvature_pca', 'n_counts', 'mt_frac', 'jacobian_det_pca', 'manual_selection', 'divergence_pca', 'curv_leiden', 'curv_louvain', 'SPI1->GATA1_jacobian', 'jacobian', 'umap_ori_leiden', 'umap_ori_louvain', 'umap_ddhodge_div', 'umap_ddhodge_potential', 'curl_umap', 'divergence_umap', 'acceleration_umap', 'control_point_umap_ori', 'inlier_prob_umap_ori', 'obs_vf_angle_umap_ori', 'curvature_umap_ori' var: 'gene_name', 'gene_id', 'nCells', 'nCounts', 'pass_basic_filter', 'use_for_pca', 'frac', 'ntr', 'time_3_alpha', 'time_3_beta', 'time_3_gamma', 'time_3_half_life', 'time_3_alpha_b', 'time_3_alpha_r2', 'time_3_gamma_b', 'time_3_gamma_r2', 'time_3_gamma_logLL', 'time_3_delta_b', 'time_3_delta_r2', 'time_3_bs', 'time_3_bf', 'time_3_uu0', 'time_3_ul0', 'time_3_su0', 'time_3_sl0', 'time_3_U0', 'time_3_S0', 'time_3_total0', 'time_3_beta_k', 'time_3_gamma_k', 'time_5_alpha', 'time_5_beta', 'time_5_gamma', 'time_5_half_life', 'time_5_alpha_b', 'time_5_alpha_r2', 'time_5_gamma_b', 'time_5_gamma_r2', 'time_5_gamma_logLL', 'time_5_bs', 'time_5_bf', 'time_5_uu0', 'time_5_ul0', 'time_5_su0', 'time_5_sl0', 'time_5_U0', 'time_5_S0', 'time_5_total0', 'time_5_beta_k', 'time_5_gamma_k', 'use_for_dynamics', 'gamma', 'gamma_r2', 'use_for_transition', 'gamma_k', 'gamma_b' uns: 'PCs', 'VecFld_pca', 'VecFld_umap', 'X_umap_neighbors', 'cell_phase_genes', 'cell_type_colors', 'dynamics', 'explained_variance_ratio_', 'feature_selection', 'grid_velocity_pca', 'grid_velocity_umap', 'grid_velocity_umap_ori_perturbation', 'grid_velocity_umap_test', 'jacobian_pca', 'leiden', 'neighbors', 'pca_mean', 'pp', 'response', 'fate_pca' obsm: 'X', 'X_pca', 'X_pca_SparseVFC', 'X_umap', 'X_umap_SparseVFC', 'X_umap_ori_perturbation', 'X_umap_test', 'acceleration_pca', 'acceleration_umap', 'cell_cycle_scores', 'curvature_pca', 'curvature_umap', 'j_delta_x_perturbation', 'velocity_pca', 'velocity_pca_SparseVFC', 'velocity_umap', 'velocity_umap_SparseVFC', 'velocity_umap_ori_perturbation', 'velocity_umap_test' layers: 'M_n', 'M_nn', 'M_t', 'M_tn', 'M_tt', 'X_new', 'X_total', 'velocity_alpha_minus_gamma_s' obsp: 'X_umap_connectivities', 'X_umap_distances', 'connectivities', 'cosine_transition_matrix', 'distances', 'fp_transition_rate', 'moments_con', 'pca_ddhodge', 'perturbation_transition_matrix', 'umap_ddhodge'
adata_labeling.uns["fate_pca"].keys(), adata_labeling.uns["fate_pca"]
(dict_keys(['init_states', 'init_cells', 'average', 't', 'prediction', 'VecFld_true', 'genes']), {'init_states': array([[ 7.091581 , -0.7870671 , -0.10020483, -2.1666603 , -0.70837826, 0.9354968 , 1.155709 , -1.1218834 , -0.96981585, 0.7737026 , -0.3388199 , -0.05113704, -0.28078598, -1.1127218 , 0.44130117, -0.8993704 , 0.44900474, 0.01669051, 0.32672876, -0.5660211 , 0.6218931 , 0.2717921 , -1.010213 , 0.04973401, -0.72466844, -0.61323094, 0.22264181, -0.40271127, -0.11476172, -0.30153838]], dtype=float32), 'init_cells': 'CTCTTAAAAGAG-JL12_0', 'average': False, 't': [[-0.22232868729082816, -0.4376615382142769, -0.6529943891377259, -0.8683272400611748, -1.083660090984624, -1.2989929419080735, -1.5069058902713115, -1.6647802440177495, -1.8226545977641875, -1.9805289515106255, -2.1384033052570635, -2.2962776590035014, -2.4541520127499394, -2.6120263664963774, -2.7699007202428154, -2.9277750739892534, -3.0856494277356914, -3.2435237814821294, -3.4013981352285674, -3.5592724889750054, -3.7171468427214434, -3.8750211964678813, -4.032895550214319, -4.190769903960757, -4.348644257707195, -4.506518611453633, -4.664392965200071, -4.822267318946509, -4.980141672692947, -5.138016026439385, -5.295890380185823, -5.453764733932261, -5.611639087678699, -5.769513441425137, -5.927387795171576, -6.085262148918015, -6.243136502664454, -6.401010856410893, -6.558885210157332, -6.7167595639037705, -6.874633917650209, -7.032508271396648, -7.190382625143087, -7.348256978889526, -7.506131332635965, -7.664005686382404, -7.821880040128843, -7.9797543938752815, -8.13762874762172, -8.295503101368158, -8.453377455114598, -8.611251808861038, -8.769126162607478, -8.927000516353917, -9.084874870100357, -9.242749223846797, -9.400623577593237, -9.558497931339677, -9.716372285086118, -9.874478045164542, -10.032597371660941, -10.19071669815734, -10.348836024653739, -10.506955351150138, -10.665074677646537, -10.823194004142936, -10.981313330639335, -11.139432657135734, -11.297551983632133, -11.455671310128531, -11.61379063662493, -11.77190996312133, -11.930029289617728, -12.088148616114127, -12.246267942610526, -12.404387269106925, -12.562506595603324, -12.720625922099723, -12.878745248596122, -13.03686457509252, -13.19498390158892, -13.353103228085319, -13.511222554581718, -13.669341881078115, -13.827461207574514, -13.985580534070913, -14.14369986056731, -14.301819187063709, -14.459938513560108, -14.618057840056506, -14.776177166552905, -14.934296493049303, -15.092415819545701, -15.250535146042099, -15.408654472538498, -15.566773799034896, -15.724893125531295, -15.883012452027693, -16.04113177852409, -16.199251105020487, -16.357370431516884, -16.51548975801328, -16.67360908450968, -16.831728411006075, -16.989847737502473, -17.147967063998873, -17.306086390495274, -17.46420571699167, -17.622325043488072, -17.78044436998447, -17.93856369648087, -18.09668302297727, -18.254802349473668, -18.509793247380745, -18.849493230671442, -19.189193213962138, -19.528893197252835, -19.86859318054353, -20.208293163834227, -20.547993147124924, -20.88769313041562, -21.227393113706317, -21.567093096997013, -21.90679308028771, -22.246493063578406, -22.586193046869106, -22.925893030159802, -23.265593013450502, -23.605292996741202, -23.9449929800319, -24.2846929633226, -24.624392946613295, -24.964092929903995, -25.303792913194695, -25.64349289648539, -25.98319287977609, -26.322892863066787, -26.944107514518407, -27.65110112110693, -28.358094727695452, -29.065088334283974, -29.772081940872496, -30.47907554746102, -31.18606915404954, -31.893062760638067, -32.60005636722659, -33.30704997381512, -34.014043580403644, -34.72103718699217, -35.428030793580696, -36.13502440016922, -36.84201800675774, -37.549011613346266, -38.256005219934785, -39.461198958933785, -40.70496820108717, -41.94873744324055, -43.19250668539394, -44.43627592754732, -45.680045169700705, -46.92381441185409, -48.16758365400747, -49.41135289616086, -50.65512213831424, -51.89889138046762, -53.142660622621, -54.38642986477438, -55.63019910692776, -57.05651045655053, -58.730527402148674, -60.40454434774682, -62.07856129334497, -63.752578238943116, -65.42659518454127, -67.10061213013941, -68.77462907573755, -70.4486460213357, -72.12266296693386, -73.796679912532, -75.47069685813015, -77.1447138037283, -78.81873074932645, -80.49274769492459, -82.2194376441171, -84.0404445295912, -85.8614514150653, -87.68245830053941, -89.50346518601351, -91.32447207148762, -93.14547895696172, -94.96648584243583, -96.78749272790994, -98.60849961338405, -100.42950649885816, -102.25051338433228, -104.07152026980638, -105.8925271552805, -107.71353404075461, -109.53454092622873, -111.35554781170283, -113.17655469717695, -114.99756158265106, -116.84773122780112, -118.71653483070727, -120.58533843361343, -122.45414203651958, -124.32294563942574, -126.1917492423319, -128.06055284523805, -129.9293564481442, -131.79816005105036, -133.66696365395651, -135.53576725686267, -137.40457085976882, -139.27337446267498, -141.14217806558113, -143.0109816684873, -144.87978527139344, -146.7485888742996, -148.61739247720575, -150.4861960801119, -152.35499968301806, -154.22380328592422, -156.09260688883037, -157.96141049173656, -159.94241526414638, -161.955587607841, -163.96875995153565, -165.98193229523028, -167.99510463892491, -170.00827698261955, -172.02144932631418, -174.03462167000882, -176.04779401370345, -178.0609663573981, -180.07413870109272, -182.08731104478736, -184.100483388482, -186.11365573217662, -188.12682807587126, -190.1400004195659, -192.15317276326056, -194.1663451069552, -196.17951745064985, -198.1926897943445, -200.20586213803915, -202.2190344817338, -204.23220682542845, -206.24537916912308, -208.25855151281775, -210.27172385651238, -212.53284853747064, -214.85624749787732, -217.179646458284, -219.50304541869068, -221.82644437909735, -224.14984333950403, -226.4732422999107, -228.7966412603174, -231.12004022072406, -233.44343918113074, -235.76683814153742, -238.0902371019441, -240.41363606235078, -242.73703502275745, -245.06043398316413, -247.3838329435708, -249.7072319039775, -252.03063086438416, -254.35402982479084, -256.67742878519755, -259.0008277456042, -261.56761171736844, -264.38695658211, -267.2063014468515, -270.02564631159305, -272.8449911763346, -275.6643360410761, -278.48368090581766, -281.3030257705592, -284.12237063530074, -286.9417155000423, -289.7610603647838, -292.58040522952535, -295.3997500942669, -298.21909495900843, -301.03843982374997, -303.8577846884915, -306.67712955323304, -309.4964744179746, -312.3158192827161, -315.13516414745766, -317.9545090121992, -321.37665331967304, -324.83998551780945, -328.30331771594587, -331.7666499140823, -335.2299821122187, -338.6933143103551, -342.1566465084915, -345.61997870662793, -349.08331090476435, -352.54664310290076, -356.0099753010372, -359.4733074991736, -362.93663969731, -366.3999718954464, -369.8633040935828, -373.32663629171924, -376.7899684898556, -380.253300687992, -383.7166328861284, -387.1799650842648, -390.64329728240114, -394.1066294805375, -397.5699616786739, -401.03329387681026, -404.4966260749467, -407.95995827308303, -411.54202297735526, -415.19499317340103, -418.8479633694468, -422.5009335654926, -426.15390376153834, -429.8068739575841, -433.4598441536299, -437.1128143496757, -440.76578454572154, -444.4187547417673, -448.07172493781314, -451.7246951338589, -455.37766532990474, -459.0306355259505, -462.68360572199634, -466.3365759180421, -469.98954611408794, -473.6425163101337, -477.29548650617954, -480.94845670222537, -484.60142689827114, -488.25439709431697, -491.90736729036274, -495.56033748640857, -499.21330768245434, -502.86627787850017, -506.51924807454594, -510.2635940551034, -514.2576503381298, -518.2517066211562, -522.2457629041827, -526.2398191872092, -530.2338754702356, -534.227931753262, -538.2219880362885, -542.216044319315, -546.2101006023414, -550.2041568853679, -554.1982131683943, -558.1922694514208, -562.1863257344472, -566.1803820174736, -570.1744383005, -574.1684945835264, -578.1625508665528, -582.1566071495793, -586.1506634326056, -590.144719715632, -594.1387759986584, -598.1328322816848, -602.1268885647112, -606.1209448477376, -610.115001130764, -614.1090574137903, -618.1031136968166, -622.0971699798431, -626.0912262628694, -630.0852825458958, -634.0793388289221, -638.0733951119485, -642.0674513949749, -646.0615076780012, -650.0555639610277, -654.5579480113503, -660.8879739076879, -667.2179998040256, -673.5480257003632, -679.8780515967007, -686.2080774930383, -692.5381033893759, -698.8681292857136, -705.1981551820512, -711.5281810783888, -717.8582069747264, -724.188232871064, -730.5182587674017, -736.8482846637393, -743.1783105600769, -749.5083364564144, -755.8383623527521, -762.1683882490897, -768.4984141454273, -774.8284400417649, -781.1584659381025, -787.4884918344401, -793.8185177307777, -800.1485436271153, -806.478569523453, -812.8085954197905, -819.1386213161281, -825.4686472124657, -831.7986731088033, -838.1286990051409, -844.4587249014785, -853.119688521906, -864.3212508782801, -875.5228132346542, -886.7243755910283, -897.9259379474024, -909.1275003037765, -920.3290626601506, -931.5306250165247, -942.7321873728987, -953.9337497292727, -965.1353120856467, -976.3368744420206, -987.5384367983946, -998.7399991547686, -1009.9415615111426, -1021.1431238675166, -1032.3446862238904, -1044.2124271736204, -1061.5973839184694, -1078.9823406633184, -1096.3672974081674, -1113.7522541530163, -1131.1372108978653, -1148.522167642714, -1165.907124387563, -1183.292081132412, -1200.677037877261, -1218.06199462211, -1235.446951366959, -1259.1996708979348, -1283.5414086302546, -1307.8831463625745, -1332.2248840948944, -1356.5666218272142, -1380.9083595595343, -1405.2500972918544, -1429.5918350241745, -1460.8335650607323, -1492.6616571661089, -1524.4897492714854, -1556.317841376862, -1588.1459334822384, -1619.974025587615, -1658.1735332837309, -1697.8848447835437, -1737.5961562833565, -1777.3074677831694, -1817.0187792829822, -1864.176628125226, -1912.085586994496, -1959.994545863766, -2007.9035047330356, -2062.9743941873335, -2119.3396705297514, -2175.704946872169, -2235.495252705891, -2300.535519791879, -2365.5757868778664, -2434.1893634198263, -2508.093336603542, -2581.9973097872585, -2662.8562288214207, -2745.789427326518, -2832.6138481735284, -2924.7233510940514, -3019.7330855491773, -3121.1509949225024, -3226.273972338413, -3337.120007344748, -3454.0469044487386, -3574.635168130651, -3704.6565976029037, -3839.7840743964884, -3980.836242097904, -4130.405649612169, -4288.204775408248, -4453.768359652803, -4627.858204439565, -4811.172670452803, -5004.354523129428, -5207.997533306211, -5422.652068944349, -5648.829862973589, -5887.008103266667, -6139.144684992769, -6405.3524497454355, -6685.144218432179]], 'prediction': [array([[ 7.05848879, 7.02579654, 6.99245277, ..., -9.60369707, -9.64693102, -9.68996804], [-0.79435712, -0.80148748, -0.80868615, ..., -0.7043039 , -0.69896372, -0.6936487 ], [-0.10701722, -0.11364987, -0.12031288, ..., 2.8638002 , 2.87549099, 2.88715107], ..., [-0.40173914, -0.40083113, -0.39995766, ..., 1.30979715, 1.31123479, 1.31265822], [-0.11152245, -0.10836967, -0.10520306, ..., -1.98181184, -1.98339663, -1.98497423], [-0.29925253, -0.29701465, -0.29475371, ..., -0.19609498, -0.19518163, -0.19427015]])], 'VecFld_true': None, 'genes': ['pca_0', 'pca_1', 'pca_2', 'pca_3', 'pca_4', 'pca_5', 'pca_6', 'pca_7', 'pca_8', 'pca_9', 'pca_10', 'pca_11', 'pca_12', 'pca_13', 'pca_14', 'pca_15', 'pca_16', 'pca_17', 'pca_18', 'pca_19', 'pca_20', 'pca_21', 'pca_22', 'pca_23', 'pca_24', 'pca_25', 'pca_26', 'pca_27', 'pca_28', 'pca_29']})
adata_labeling.uns["fate_pca"]["prediction"][0].shape, len(
adata_labeling.uns["fate_pca"]["t"][0],
)
((30, 500), 500)
from anndata import AnnData
from scipy.sparse import csr_matrix
from dynamo.vectorfield.utils import vector_transformation
path_id = 0
dyn.tools.utils.nearest_neighbors(
adata_labeling.uns["fate_pca"]["prediction"][path_id].T[0, :], adata_labeling.obsm["X_pca"], 5
)[0][1]
dyn.tools.utils.nearest_neighbors(
adata_labeling.uns["fate_pca"]["prediction"][path_id].T[140, :], adata_labeling.obsm["X_pca"], 5
)
vec_dict, vecfld = dyn.vf.utils.vecfld_from_adata(adata_labeling, basis="pca")
vector_field_class = dyn.vf.SvcVectorField()
vector_field_class.from_adata(adata_labeling, basis="pca")
X_data = adata_labeling.uns["fate_pca"]["prediction"][path_id].T[:140, :]
vel_norm = vector_field_class.func(X_data)
acc_norm, acc_mat = vector_field_class.compute_acceleration(X=X_data)
curv_norm, curv_mat = vector_field_class.compute_curvature(X=X_data)
div = vector_field_class.compute_divergence(X=X_data)
Jac_func = vector_field_class.get_Jacobian()
Js = Jac_func(X_data)
X_data.shape, Js.shape, adata_labeling.uns["fate_pca"]["prediction"][path_id].T.shape
adata_labeling.uns["PCs"].shape, adata_labeling.uns["pca_mean"].shape
Jacobian = dyn.vf.utils.subset_jacobian_transformation(Js, adata_labeling.uns["PCs"], adata_labeling.uns["PCs"])
|-----> [Calculating acceleration] in progress: 100.0000% |-----> [Calculating acceleration] finished [0.0305s] |-----> [Calculating acceleration] in progress: 100.0000% |-----> [Calculating acceleration] finished [0.0330s] |-----> [Calculating curvature] in progress: 100.0000% |-----> [Calculating curvature] finished [0.0318s]
Calculating divergence: 100%|██████████| 1/1 [00:00<00:00, 32.00it/s] Transforming subset Jacobian: 100%|██████████| 140/140 [00:04<00:00, 34.28it/s]
# project the expression state back to higher dimension
exprs = dyn.prediction.utils.pca_to_expr(X_data, adata_labeling.uns["PCs"], mean=adata_labeling.uns["pca_mean"])
exprs.shape
(140, 1956)
trajectory_adata = AnnData(
X=exprs, layers={"M_t": csr_matrix(exprs)}, var=adata_labeling[:, adata_labeling.var.use_for_pca].var
)
trajectory_adata.layers["velocity"] = csr_matrix(vector_transformation(vel_norm, adata_labeling.uns["PCs"]))
trajectory_adata.layers["acceleration"] = vector_transformation(acc_mat, adata_labeling.uns["PCs"])
trajectory_adata.layers["curvature"] = vector_transformation(curv_mat, adata_labeling.uns["PCs"])
adata_labeling.uns["jacobian_pca"].keys(), X_data.shape[0]
trajectory_adata.uns["jacobian_pca"] = {
"cell_idx": np.arange(X_data.shape[0]),
"effectors": trajectory_adata.var_names,
"jacobian": Js,
"jacobian_gene": Jacobian,
"regulators": trajectory_adata.var_names,
}
trajectory_adata.obs["integral_time"] = adata_labeling.uns["fate_pca"]["t"][path_id][: X_data.shape[0]]
dyn.pp.recipe_monocle(trajectory_adata)
|-----> apply Monocole recipe to adata... |-----> <insert> pp to uns in AnnData Object. |-----------> <insert> has_splicing to uns['pp'] in AnnData Object. |-----------> <insert> has_labling to uns['pp'] in AnnData Object. |-----------> <insert> splicing_labeling to uns['pp'] in AnnData Object. |-----------> <insert> has_protein to uns['pp'] in AnnData Object. |-----> ensure all cell and variable names unique. |-----> ensure all data in different layers in csr sparse matrix format. |-----> ensure all labeling data properly collapased |-----------> <insert> tkey to uns['pp'] in AnnData Object. |-----------> <insert> experiment_type to uns['pp'] in AnnData Object. |-----> filtering cells... |-----> <insert> pass_basic_filter to obs in AnnData Object. |-----> 140 cells passed basic filters. |-----> filtering gene... |-----> <insert> pass_basic_filter to var in AnnData Object. |-----> 32 genes passed basic filters. |-----> calculating size factor... |-----? only 32 genes passed basic filtering, but you requested 2000 genes for feature selection. Try lowering the gene selection stringency: {'min_expr_cells': 0, 'min_expr_avg': 0, 'max_expr_avg': inf, 'svr_gamma': None, 'winsorize': False, 'winsor_perc': (1, 99.5), 'sort_inverse': False} |-----> selecting genes in layer: X, sort method: SVR... |-----> <insert> frac to var in AnnData Object. |-----> <insert> X_velocity to layers in AnnData Object. |-----> <insert> X_acceleration to layers in AnnData Object. |-----> <insert> X_M_t to layers in AnnData Object. |-----> <insert> X_curvature to layers in AnnData Object. |-----------> <insert> norm_method to uns['pp'] in AnnData Object. |-----> applying PCA ... |-----> <insert> pca_fit to uns in AnnData Object. |-----> cell cycle scoring... |-----> computing cell phase... |-----? Dynamo is not able to perform cell cycle staging for you automatically. Since dyn.pl.phase_diagram in dynamo by default colors cells by its cell-cycle stage, you need to set color argument accordingly if confronting errors related to this. |-----> [recipe_monocle preprocess] in progress: 100.0000% |-----> [recipe_monocle preprocess] finished [3.3377s]
trajectory_adata.var_names
Index(['FUCA2', 'HECW1', 'MAD1L1', 'CFLAR', 'SARM1', 'CAMKK1', 'ARHGAP33', 'SLC4A1', 'MPO', 'ITGA3', ... 'AC020651.2', 'AL355999.1', 'AC016168.4', 'AL353576.1', 'AP000926.2', 'AC108519.1', 'AC004470.2', 'DUS4L-BCAP29', 'AL592295.6', 'AL353671.1'], dtype='object', length=1956)
dyn.tl.reduceDimension(trajectory_adata)
dyn.pl.umap(trajectory_adata, color="SPI1")
|-----> retrive data for non-linear dimension reduction... |-----> perform umap...
OMP: Info #273: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
|-----> [dimension_reduction projection] in progress: 100.0000% |-----> [dimension_reduction projection] finished [5.9700s]
genes = ["SPI1", "GATA1"]
integral_time = trajectory_adata.obs.integral_time[::-1]
expression = trajectory_adata[:, genes].layers["M_t"].A[::-1, :]
velocity = trajectory_adata[:, genes].layers["velocity"].A[::-1, :]
acceleration = trajectory_adata[:, genes].layers["acceleration"].A[::-1, :]
fig1, f1_axes = plt.subplots(ncols=3, nrows=1, constrained_layout=True, figsize=(12, 4))
sns.scatterplot(integral_time, acceleration[:, 0], s=2, ax=f1_axes[0], ec=None, label="SPI1")
sns.scatterplot(integral_time, acceleration[:, 1], s=2, ax=f1_axes[0], ec=None, label="GATA1")
f1_axes[0].set_title("acceleration")
f1_axes[0].set_xlabel("integration time")
sns.scatterplot(integral_time, velocity[:, 0], s=2, ax=f1_axes[1], ec=None, label="SPI1")
sns.scatterplot(integral_time, velocity[:, 1], s=2, ax=f1_axes[1], ec=None, label="GATA1")
f1_axes[1].set_title("velocity")
f1_axes[1].set_xlabel("integration time")
sns.scatterplot(integral_time, expression[:, 0], s=2, ax=f1_axes[2], ec=None, label="SPI1")
sns.scatterplot(integral_time, expression[:, 1], s=2, ax=f1_axes[2], ec=None, label="GATA1")
f1_axes[2].set_title("expression")
f1_axes[2].set_xlabel("integration time")
Text(0.5, 0, 'integration time')
dyn.configuration.set_pub_style()
regulators, effectors = list(adata_labeling.uns["jacobian_pca"]["regulators"]), list(
adata_labeling.uns["jacobian_pca"]["effectors"]
)
spi1_ind, gata1_ind = regulators.index("SPI1"), effectors.index("GATA1")
fig1, f1_axes = plt.subplots(ncols=4, nrows=1, constrained_layout=True, figsize=(8, 2))
expression = trajectory_adata[:, ["SPI1", "GATA1"]].layers["M_t"].A[::-1, :]
sns.scatterplot(
expression[:, 0],
Jacobian[gata1_ind, spi1_ind, ::-1],
hue=integral_time * 3,
palette="viridis",
ax=f1_axes[0],
ec=None,
s=2,
)
f1_axes[0].set_title(r"$\partial f_{GATA1}/\partial x_{SPI1}$")
f1_axes[0].set_xlabel(r"SPI1 ($M_t$)")
sns.scatterplot(
expression[:, 1],
Jacobian[spi1_ind, gata1_ind, ::-1],
hue=integral_time * 3,
palette="viridis",
ax=f1_axes[1],
ec=None,
s=2,
)
f1_axes[1].set_title(r"$\partial f_{SPI1}/\partial x_{GATA1}$")
f1_axes[1].set_xlabel(r"GATA1 ($M_t$)")
sns.scatterplot(
expression[:, 0],
Jacobian[spi1_ind, spi1_ind, ::-1],
hue=integral_time * 3,
palette="viridis",
ax=f1_axes[2],
ec=None,
s=2,
)
f1_axes[2].set_title(r"$\partial f_{SPI1}/\partial x_{SPI1}$")
f1_axes[2].set_xlabel(r"SPI1 ($M_t$)")
sns.scatterplot(
expression[:, 1],
Jacobian[gata1_ind, gata1_ind, ::-1],
hue=integral_time * 3,
palette="viridis",
ax=f1_axes[3],
ec=None,
s=2,
)
f1_axes[3].set_title(r"$\partial f_{GATA1}/\partial x_{GATA1}$")
f1_axes[3].set_xlabel(r"GATA1 ($M_t$)")
Text(0.5, 0, 'GATA1 ($M_t$)')
dyn.configuration.set_pub_style(scaler=2)
dyn.pl.response(
adata_labeling,
np.array([["SPI1", "SPI1"], ["SPI1", "GATA1"], ["GATA1", "SPI1"], ["GATA1", "GATA1"]]),
ykey="alpha",
log=False,
drop_zero_cells=False,
grid_num=20,
)
--------------------------------------------------------------------------- Exception Traceback (most recent call last) /var/folders/m5/dc_kmwcs2_3fqkytr_j09wx00000gn/T/ipykernel_96142/2928818021.py in <module> 1 dyn.configuration.set_pub_style(scaler=2) ----> 2 dyn.pl.response( 3 adata_labeling, 4 np.array([["SPI1", "SPI1"], ["SPI1", "GATA1"], ["GATA1", "SPI1"], ["GATA1", "GATA1"]]), 5 ykey="alpha", ~/dynamo-release/dynamo/plot/heatmaps.py in response(adata, pairs_mat, xkey, ykey, log, drop_zero_cells, delay, grid_num, n_row, n_col, cmap, show_ridge, show_rug, zero_indicator, zero_line_style, zero_line_width, mean_style, fit_curve, fit_mode, curve_style, curve_lw, no_degradation, show_extent, ext_format, stacked_fraction, figsize, save_show_or_return, save_kwargs, return_data) 258 259 if not set([xkey, ykey]) <= set(adata.layers.keys()).union(set(["jacobian"])): --> 260 raise Exception( 261 f"adata.layers doesn't have {xkey, ykey} layers. Please specify the correct layers or " 262 "perform relevant preprocessing and vector field analyses first." Exception: adata.layers doesn't have ('M_t', 'alpha') layers. Please specify the correct layers or perform relevant preprocessing and vector field analyses first.