%load_ext autoreload
%autoreload 2
import warnings
from pathlib import Path
from time import time
import arviz as az
import janitor # noqa: F401
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotnine as gg
import pymc3 as pm
import seaborn as sns
import speclet.io
from speclet.bayesian_models.hierarchical_nb import HierarchcalNegativeBinomialModel
from speclet.managers.cache_manager import PosteriorManager
from speclet.managers.data_managers import CrisprScreenDataManager
from speclet.plot.plotnine_helpers import set_gg_theme
from speclet.project_configuration import read_project_configuration
from speclet.project_enums import ModelFitMethod
# Notebook execution timer.
notebook_tic = time()
# Plotting setup.
set_gg_theme()
%config InlineBackend.figure_format = "retina"
# Constants
RANDOM_SEED = 847
np.random.seed(RANDOM_SEED)
HDI_PROB = read_project_configuration().modeling.highest_density_interval
HDI_LBL = f"{int(100*HDI_PROB)}%"
speclet_hnb = HierarchcalNegativeBinomialModel()
pm = PosteriorManager(
id="hierarchical-nb_PYMC3_MCMC", cache_dir=speclet.io.models_dir()
)
assert pm.posterior_cache_exists, "Posterior cache does not exist."
hnb_trace = pm.get(from_file=True)
hnb_trace
<div>
<div class='xr-header'>
<div class="xr-obj-type">arviz.InferenceData</div>
</div>
<ul class="xr-sections group-sections">
<li class = "xr-section-item">
<input id="idata_posteriorc4e61741-d198-4c23-bf0d-4bf191e3cef8" class="xr-section-summary-in" type="checkbox">
<label for="idata_posteriorc4e61741-d198-4c23-bf0d-4bf191e3cef8" class = "xr-section-summary">posterior</label>
<div class="xr-section-inline-details"></div>
<div class="xr-section-details">
<ul id="xr-dataset-coord-list" class="xr-var-list">
<div style="padding-left:2rem;"><div><svg style="position: absolute; width: 0; height: 0; overflow: hidden">
:root { --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54)); --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38)); --xr-border-color: var(--jp-border-color2, #e0e0e0); --xr-disabled-color: var(--jp-layout-color3, #bdbdbd); --xr-background-color: var(--jp-layout-color0, white); --xr-background-color-row-even: var(--jp-layout-color1, white); --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); }
html[theme=dark], body.vscode-dark { --xr-font-color0: rgba(255, 255, 255, 1); --xr-font-color2: rgba(255, 255, 255, 0.54); --xr-font-color3: rgba(255, 255, 255, 0.38); --xr-border-color: #1F1F1F; --xr-disabled-color: #515151; --xr-background-color: #111111; --xr-background-color-row-even: #111111; --xr-background-color-row-odd: #313131; }
.xr-wrap { display: block !important; min-width: 300px; max-width: 700px; }
.xr-text-repr-fallback { /* fallback to plain text repr when CSS is not injected (untrusted notebook) */ display: none; }
.xr-header { padding-top: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: solid 1px var(--xr-border-color); }
.xr-header > div, .xr-header > ul { display: inline; margin-top: 0; margin-bottom: 0; }
.xr-obj-type, .xr-array-name { margin-left: 2px; margin-right: 10px; }
.xr-obj-type { color: var(--xr-font-color2); }
.xr-sections { padding-left: 0 !important; display: grid; grid-template-columns: 150px auto auto 1fr 20px 20px; }
.xr-section-item { display: contents; }
.xr-section-item input { display: none; }
.xr-section-item input + label { color: var(--xr-disabled-color); }
.xr-section-item input:enabled + label { cursor: pointer; color: var(--xr-font-color2); }
.xr-section-item input:enabled + label:hover { color: var(--xr-font-color0); }
.xr-section-summary { grid-column: 1; color: var(--xr-font-color2); font-weight: 500; }
.xr-section-summary > span { display: inline-block; padding-left: 0.5em; }
.xr-section-summary-in:disabled + label { color: var(--xr-font-color2); }
.xr-section-summary-in + label:before { display: inline-block; content: '►'; font-size: 11px; width: 15px; text-align: center; }
.xr-section-summary-in:disabled + label:before { color: var(--xr-disabled-color); }
.xr-section-summary-in:checked + label:before { content: '▼'; }
.xr-section-summary-in:checked + label > span { display: none; }
.xr-section-summary, .xr-section-inline-details { padding-top: 4px; padding-bottom: 4px; }
.xr-section-inline-details { grid-column: 2 / -1; }
.xr-section-details { display: none; grid-column: 1 / -1; margin-bottom: 5px; }
.xr-section-summary-in:checked ~ .xr-section-details { display: contents; }
.xr-array-wrap { grid-column: 1 / -1; display: grid; grid-template-columns: 20px auto; }
.xr-array-wrap > label { grid-column: 1; vertical-align: top; }
.xr-preview { color: var(--xr-font-color3); }
.xr-array-preview, .xr-array-data { padding: 0 5px !important; grid-column: 2; }
.xr-array-data, .xr-array-in:checked ~ .xr-array-preview { display: none; }
.xr-array-in:checked ~ .xr-array-data, .xr-array-preview { display: inline-block; }
.xr-dim-list { display: inline-block !important; list-style: none; padding: 0 !important; margin: 0; }
.xr-dim-list li { display: inline-block; padding: 0; margin: 0; }
.xr-dim-list:before { content: '('; }
.xr-dim-list:after { content: ')'; }
.xr-dim-list li:not(:last-child):after { content: ','; padding-right: 5px; }
.xr-has-index { font-weight: bold; }
.xr-var-list, .xr-var-item { display: contents; }
.xr-var-item > div, .xr-var-item label, .xr-var-item > .xr-var-name span { background-color: var(--xr-background-color-row-even); margin-bottom: 0; }
.xr-var-item > .xr-var-name:hover span { padding-right: 5px; }
.xr-var-list > li:nth-child(odd) > div, .xr-var-list > li:nth-child(odd) > label, .xr-var-list > li:nth-child(odd) > .xr-var-name span { background-color: var(--xr-background-color-row-odd); }
.xr-var-name { grid-column: 1; }
.xr-var-dims { grid-column: 2; }
.xr-var-dtype { grid-column: 3; text-align: right; color: var(--xr-font-color2); }
.xr-var-preview { grid-column: 4; }
.xr-var-name, .xr-var-dims, .xr-var-dtype, .xr-preview, .xr-attrs dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.xr-var-name:hover, .xr-var-dims:hover, .xr-var-dtype:hover, .xr-attrs dt:hover { overflow: visible; width: auto; z-index: 1; }
.xr-var-attrs, .xr-var-data { display: none; background-color: var(--xr-background-color) !important; padding-bottom: 5px !important; }
.xr-var-attrs-in:checked ~ .xr-var-attrs, .xr-var-data-in:checked ~ .xr-var-data { display: block; }
.xr-var-data > table { float: right; }
.xr-var-name span, .xr-var-data, .xr-attrs { padding-left: 25px !important; }
.xr-attrs, .xr-var-attrs, .xr-var-data { grid-column: 1 / -1; }
dl.xr-attrs { padding: 0; margin: 0; display: grid; grid-template-columns: 125px auto; }
.xr-attrs dt, .xr-attrs dd { padding: 0; margin: 0; float: left; padding-right: 10px; width: auto; }
.xr-attrs dt { font-weight: normal; grid-column: 1; }
.xr-attrs dt:hover span { display: inline-block; background: var(--xr-background-color); padding-right: 10px; }
.xr-attrs dd { grid-column: 2; white-space: pre-wrap; word-break: break-all; }
.xr-icon-database, .xr-icon-file-text2 { display: inline-block; vertical-align: middle; width: 1em; height: 1.5em !important; stroke-width: 0; stroke: currentColor; fill: currentColor; } </style>
<xarray.Dataset> Dimensions: (gene: 114, sgrna: 338, cell_line: 10, chain: 2, draw: 1000, lineage: 2, eta_dim_0: 2188, mu_dim_0: 2188) Coordinates:
-
gene (gene) object 'ACVR1C' 'ADAMTS2' ... 'ZC2HC1C' 'ZNF44'
-
sgrna (sgrna) object 'AAACTTGCTGACGTGCCTGG' ... 'TTTGTTGGGACC...
-
cell_line (cell_line) object 'ACH-000007' ... 'ACH-002116'
-
chain (chain) int64 0 1
-
draw (draw) int64 0 1 2 3 4 5 6 ... 993 994 995 996 997 998 999
-
lineage (lineage) object 'bone' 'colorectal'
-
eta_dim_0 (eta_dim_0) int64 0 1 2 3 4 5 ... 2183 2184 2185 2186 2187
-
mu_dim_0 (mu_dim_0) int64 0 1 2 3 4 5 ... 2183 2184 2185 2186 2187 Data variables: (12/19) a (chain, draw) float64 0.1645 -0.1402 ... 0.1484 0.03593 mu_beta (chain, draw, gene) float64 ... beta_s (chain, draw, sgrna) float64 ... delta_mu_gamma_c (chain, draw, lineage) float64 -0.4591 -1.155 ... 0.4972 delta_gamma_c (chain, draw, cell_line) float64 0.5488 -0.9459 ... 0.123 delta_kappa_sc (chain, draw, sgrna, cell_line) float64 ... ... ... kappa_sc (chain, draw, sgrna, cell_line) float64 ... eta (chain, draw, eta_dim_0) float64 ... mu (chain, draw, mu_dim_0) float64 ... alpha_alpha (chain, draw) float64 2.091 1.877 1.573 ... 1.55 1.611 beta_alpha (chain, draw) float64 0.3625 0.3501 ... 0.2348 0.2785 alpha (chain, draw, gene) float64 ... Attributes: created_at: 2022-01-26 09:17:31.708330 arviz_version: 0.11.2 inference_library: pymc3 inference_library_version: 3.11.4 sampling_time: 513.8245859146118 tuning_steps: 1000 previous_created_at: ['2022-01-26T14:09:19.816304', '2022-01-26T14... combined_sampling_time: [513.82458591 406.79231596]
- Dimensions:
- gene: 114
- sgrna: 338
- cell_line: 10
- chain: 2
- draw: 1000
- lineage: 2
- eta_dim_0: 2188
- mu_dim_0: 2188
- Coordinates: (8)
- gene(gene)object'ACVR1C' 'ADAMTS2' ... 'ZNF44'
array(['ACVR1C', 'ADAMTS2', 'ADPRHL1', 'ALKBH8', 'APC', 'ARID3B', 'BRAF', 'C12orf75', 'CAPN13', 'CCR3', 'CCR9', 'CDK5RAP1', 'CFD', 'CSDC2', 'CTNNB1', 'CYTL1', 'DARS2', 'DMTN', 'DNAJC12', 'DPY19L1', 'DSG3', 'DUOX2', 'EEF1AKMT4', 'EIF2AK1', 'FAM92A', 'FBXW7', 'FCN1', 'FDXACB1', 'FOXP1', 'FUCA2', 'FUT7', 'GABRG1', 'GATA6', 'GOLPH3L', 'GPR162', 'GRIN2D', 'HSBP1L1', 'HYI', 'IL4R', 'IMPA1', 'ING5', 'INPP5A', 'KDELC1', 'KLF15', 'KLF5', 'KLHL32', 'KRAS', 'KRT31', 'LAPTM4B', 'LCP1', 'MDM2', 'MDM4', 'MED13', 'NBN', 'NCDN', 'NKAPL', 'NLRP8', 'NOSTRIN', 'NRAS', 'NRTN', 'OR4K15', 'OTOF', 'PAFAH1B3', 'PIK3CA', 'PLCD4', 'PLIN2', 'PLK5', 'PLXNB3', 'POFUT2', 'POU4F3', 'PPA2', 'PPM1F', 'PPP2CA', 'PRICKLE2', 'PTK2', 'PTPN12', 'REC8', 'RFWD3', 'RNLS', 'RPL18A', 'RPS26', 'RTL3', 'S100A7A', 'SAMD8', 'SCAF11', 'SEC14L5', 'SEC23B', 'SLAMF1', 'SLC19A1', 'SLC27A2', 'SNX33', 'SOSTDC1', 'SOWAHC', 'SQLE', 'STK11', 'TBX19', 'TENT5B', 'TFPT', 'TMEM101', 'TMEM192', 'TMEM241', 'TMEM62', 'TMEM9', 'TMPRSS3', 'TP53', 'TXNDC17', 'UBR2', 'USF1', 'USP46', 'VCL', 'VSTM2A', 'YY1', 'ZC2HC1C', 'ZNF44'], dtype=object)
- sgrna(sgrna)object'AAACTTGCTGACGTGCCTGG' ... 'TTTG...
array(['AAACTTGCTGACGTGCCTGG', 'AACAACTAACTTTGTACAT', 'AACAGCTCGTTGTACCGCT', ..., 'TTTAAACGACTGTCAAACC', 'TTTGAGAAGTCCCCCCTGC', 'TTTGTTGGGACCAATGGAA'], dtype=object)
- cell_line(cell_line)object'ACH-000007' ... 'ACH-002116'
array(['ACH-000007', 'ACH-000087', 'ACH-000249', 'ACH-000722', 'ACH-000997', 'ACH-001283', 'ACH-001345', 'ACH-001526', 'ACH-001957', 'ACH-002116'], dtype=object)
- chain(chain)int640 1
array([0, 1])
- draw(draw)int640 1 2 3 4 5 ... 995 996 997 998 999
array([ 0, 1, 2, ..., 997, 998, 999])
- lineage(lineage)object'bone' 'colorectal'
array(['bone', 'colorectal'], dtype=object)
- eta_dim_0(eta_dim_0)int640 1 2 3 4 ... 2184 2185 2186 2187
array([ 0, 1, 2, ..., 2185, 2186, 2187])
- mu_dim_0(mu_dim_0)int640 1 2 3 4 ... 2184 2185 2186 2187
array([ 0, 1, 2, ..., 2185, 2186, 2187])
- Data variables: (19)
- a(chain, draw)float64...
array([[ 0.164486, -0.14024 , 0.120575, ..., 0.164749, 0.171035, 0.13328 ], [ 0.172084, 0.262444, 0.321494, ..., 0.111869, 0.148366, 0.035928]])
- mu_beta(chain, draw, gene)float64...
[228000 values with dtype=float64]
- beta_s(chain, draw, sgrna)float64...
[676000 values with dtype=float64]
- delta_mu_gamma_c(chain, draw, lineage)float64...
array([[[-0.459085, -1.155269], [ 0.807179, 0.627285], ..., [-0.091458, -0.448119], [-0.327281, -0.921868]],
[[-0.369824, -0.894325], [-0.453562, -0.6062 ], ..., [-0.778314, -2.150409], [ 2.102879, 0.497168]]])
- delta_gamma_c(chain, draw, cell_line)float64...
array([[[ 0.548838, -0.945874, ..., 0.598136, -1.80894 ], [ 0.573342, 1.308016, ..., -1.058649, 2.727523], ..., [ 0.733133, 0.688381, ..., -0.124965, 1.423597], [-0.700446, -0.35084 , ..., 0.666654, 1.416288]],
[[ 0.775069, -0.864397, ..., -0.164049, 0.428187], [-0.130064, 0.918985, ..., -0.424294, 1.074267], ..., [-0.349605, -1.021699, ..., 0.580504, -0.205165], [ 0.881146, -0.538615, ..., -2.11175 , 0.122994]]])
- delta_kappa_sc(chain, draw, sgrna, cell_line)float64...
[6760000 values with dtype=float64]
- sigma_mu_beta(chain, draw)float64...
array([[0.073448, 0.068707, 0.079534, ..., 0.126737, 0.169811, 0.180631], [0.159477, 0.144317, 0.161356, ..., 0.073541, 0.074664, 0.067717]])
- sigma_beta(chain, draw)float64...
array([[0.183883, 0.184822, 0.207118, ..., 0.198157, 0.19633 , 0.195718], [0.174132, 0.154171, 0.1896 , ..., 0.205956, 0.189203, 0.197166]])
- sigma_mu_gamma_c(chain, draw)float64...
array([[0.069265, 0.32479 , 0.031219, ..., 0.091131, 0.142815, 0.064256], [0.1187 , 0.308552, 0.414415, ..., 0.036572, 0.036064, 0.044784]])
- mu_gamma_c(chain, draw, lineage)float64...
array([[[-0.031799, -0.08002 ], [ 0.262164, 0.203736], ..., [-0.013062, -0.063998], [-0.02103 , -0.059235]],
[[-0.043898, -0.106156], [-0.139947, -0.187044], ..., [-0.028069, -0.077551], [ 0.094175, 0.022265]]])
- sigma_gamma_c(chain, draw)float64...
array([[0.016342, 0.014862, 0.000599, ..., 0.024354, 0.018916, 0.03116 ], [0.024955, 0.022456, 0.05197 , ..., 0.009747, 0.010173, 0.012376]])
- gamma_c(chain, draw, cell_line)float64...
array([[[-7.105085e-02, -4.725642e-02, ..., -2.202381e-02, -6.136087e-02], [ 2.122573e-01, 2.816041e-01, ..., 2.464298e-01, 3.027014e-01], ..., [-5.013062e-02, -4.046633e-05, ..., -1.542536e-02, 1.386656e-02], [-8.106119e-02, -3.196184e-02, ..., -2.567666e-04, 2.310181e-02]],
[[-8.681422e-02, -6.546887e-02, ..., -4.799179e-02, -3.321264e-02], [-1.899651e-01, -1.193109e-01, ..., -1.494752e-01, -1.158239e-01], ..., [-8.110805e-02, -3.846269e-02, ..., -2.216325e-02, -3.015597e-02], [ 3.317005e-02, 8.750897e-02, ..., 6.803996e-02, 9.569701e-02]]])
- sigma_kappa_sc(chain, draw)float64...
array([[0.033969, 0.024344, 0.020063, ..., 0.08502 , 0.097453, 0.103265], [0.003868, 0.005493, 0.001901, ..., 0.078374, 0.046928, 0.048428]])
- kappa_sc(chain, draw, sgrna, cell_line)float64...
[6760000 values with dtype=float64]
- eta(chain, draw, eta_dim_0)float64...
[4376000 values with dtype=float64]
- mu(chain, draw, mu_dim_0)float64...
[4376000 values with dtype=float64]
- alpha_alpha(chain, draw)float64...
array([[2.090686, 1.87656 , 1.572822, ..., 1.437136, 1.686256, 1.816395], [1.889389, 1.840569, 2.003335, ..., 1.552576, 1.550066, 1.611426]])
- beta_alpha(chain, draw)float64...
array([[0.362473, 0.350128, 0.265291, ..., 0.23358 , 0.271979, 0.306668], [0.344189, 0.365177, 0.29308 , ..., 0.238887, 0.234845, 0.278467]])
- alpha(chain, draw, gene)float64...
[228000 values with dtype=float64]
- Attributes: (8)
- created_at :
- 2022-01-26 09:17:31.708330
- arviz_version :
- 0.11.2
- inference_library :
- pymc3
- inference_library_version :
- 3.11.4
- sampling_time :
- 513.8245859146118
- tuning_steps :
- 1000
- previous_created_at :
- ['2022-01-26T14:09:19.816304', '2022-01-26T14:16:53.495696']
- combined_sampling_time :
- [513.82458591 406.79231596]
<li class = "xr-section-item">
<input id="idata_posterior_predictive31fc4ffb-558d-4ecf-ae9f-ad6116bc1745" class="xr-section-summary-in" type="checkbox">
<label for="idata_posterior_predictive31fc4ffb-558d-4ecf-ae9f-ad6116bc1745" class = "xr-section-summary">posterior_predictive</label>
<div class="xr-section-inline-details"></div>
<div class="xr-section-details">
<ul id="xr-dataset-coord-list" class="xr-var-list">
<div style="padding-left:2rem;"><div><svg style="position: absolute; width: 0; height: 0; overflow: hidden">
:root { --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54)); --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38)); --xr-border-color: var(--jp-border-color2, #e0e0e0); --xr-disabled-color: var(--jp-layout-color3, #bdbdbd); --xr-background-color: var(--jp-layout-color0, white); --xr-background-color-row-even: var(--jp-layout-color1, white); --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); }
html[theme=dark], body.vscode-dark { --xr-font-color0: rgba(255, 255, 255, 1); --xr-font-color2: rgba(255, 255, 255, 0.54); --xr-font-color3: rgba(255, 255, 255, 0.38); --xr-border-color: #1F1F1F; --xr-disabled-color: #515151; --xr-background-color: #111111; --xr-background-color-row-even: #111111; --xr-background-color-row-odd: #313131; }
.xr-wrap { display: block !important; min-width: 300px; max-width: 700px; }
.xr-text-repr-fallback { /* fallback to plain text repr when CSS is not injected (untrusted notebook) */ display: none; }
.xr-header { padding-top: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: solid 1px var(--xr-border-color); }
.xr-header > div, .xr-header > ul { display: inline; margin-top: 0; margin-bottom: 0; }
.xr-obj-type, .xr-array-name { margin-left: 2px; margin-right: 10px; }
.xr-obj-type { color: var(--xr-font-color2); }
.xr-sections { padding-left: 0 !important; display: grid; grid-template-columns: 150px auto auto 1fr 20px 20px; }
.xr-section-item { display: contents; }
.xr-section-item input { display: none; }
.xr-section-item input + label { color: var(--xr-disabled-color); }
.xr-section-item input:enabled + label { cursor: pointer; color: var(--xr-font-color2); }
.xr-section-item input:enabled + label:hover { color: var(--xr-font-color0); }
.xr-section-summary { grid-column: 1; color: var(--xr-font-color2); font-weight: 500; }
.xr-section-summary > span { display: inline-block; padding-left: 0.5em; }
.xr-section-summary-in:disabled + label { color: var(--xr-font-color2); }
.xr-section-summary-in + label:before { display: inline-block; content: '►'; font-size: 11px; width: 15px; text-align: center; }
.xr-section-summary-in:disabled + label:before { color: var(--xr-disabled-color); }
.xr-section-summary-in:checked + label:before { content: '▼'; }
.xr-section-summary-in:checked + label > span { display: none; }
.xr-section-summary, .xr-section-inline-details { padding-top: 4px; padding-bottom: 4px; }
.xr-section-inline-details { grid-column: 2 / -1; }
.xr-section-details { display: none; grid-column: 1 / -1; margin-bottom: 5px; }
.xr-section-summary-in:checked ~ .xr-section-details { display: contents; }
.xr-array-wrap { grid-column: 1 / -1; display: grid; grid-template-columns: 20px auto; }
.xr-array-wrap > label { grid-column: 1; vertical-align: top; }
.xr-preview { color: var(--xr-font-color3); }
.xr-array-preview, .xr-array-data { padding: 0 5px !important; grid-column: 2; }
.xr-array-data, .xr-array-in:checked ~ .xr-array-preview { display: none; }
.xr-array-in:checked ~ .xr-array-data, .xr-array-preview { display: inline-block; }
.xr-dim-list { display: inline-block !important; list-style: none; padding: 0 !important; margin: 0; }
.xr-dim-list li { display: inline-block; padding: 0; margin: 0; }
.xr-dim-list:before { content: '('; }
.xr-dim-list:after { content: ')'; }
.xr-dim-list li:not(:last-child):after { content: ','; padding-right: 5px; }
.xr-has-index { font-weight: bold; }
.xr-var-list, .xr-var-item { display: contents; }
.xr-var-item > div, .xr-var-item label, .xr-var-item > .xr-var-name span { background-color: var(--xr-background-color-row-even); margin-bottom: 0; }
.xr-var-item > .xr-var-name:hover span { padding-right: 5px; }
.xr-var-list > li:nth-child(odd) > div, .xr-var-list > li:nth-child(odd) > label, .xr-var-list > li:nth-child(odd) > .xr-var-name span { background-color: var(--xr-background-color-row-odd); }
.xr-var-name { grid-column: 1; }
.xr-var-dims { grid-column: 2; }
.xr-var-dtype { grid-column: 3; text-align: right; color: var(--xr-font-color2); }
.xr-var-preview { grid-column: 4; }
.xr-var-name, .xr-var-dims, .xr-var-dtype, .xr-preview, .xr-attrs dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.xr-var-name:hover, .xr-var-dims:hover, .xr-var-dtype:hover, .xr-attrs dt:hover { overflow: visible; width: auto; z-index: 1; }
.xr-var-attrs, .xr-var-data { display: none; background-color: var(--xr-background-color) !important; padding-bottom: 5px !important; }
.xr-var-attrs-in:checked ~ .xr-var-attrs, .xr-var-data-in:checked ~ .xr-var-data { display: block; }
.xr-var-data > table { float: right; }
.xr-var-name span, .xr-var-data, .xr-attrs { padding-left: 25px !important; }
.xr-attrs, .xr-var-attrs, .xr-var-data { grid-column: 1 / -1; }
dl.xr-attrs { padding: 0; margin: 0; display: grid; grid-template-columns: 125px auto; }
.xr-attrs dt, .xr-attrs dd { padding: 0; margin: 0; float: left; padding-right: 10px; width: auto; }
.xr-attrs dt { font-weight: normal; grid-column: 1; }
.xr-attrs dt:hover span { display: inline-block; background: var(--xr-background-color); padding-right: 10px; }
.xr-attrs dd { grid-column: 2; white-space: pre-wrap; word-break: break-all; }
.xr-icon-database, .xr-icon-file-text2 { display: inline-block; vertical-align: middle; width: 1em; height: 1.5em !important; stroke-width: 0; stroke: currentColor; fill: currentColor; } </style>
<xarray.Dataset> Dimensions: (chain: 2, draw: 1000, ct_final_dim_0: 2188) Coordinates:
-
chain (chain) int64 0 1
-
draw (draw) int64 0 1 2 3 4 5 6 7 ... 993 994 995 996 997 998 999
-
ct_final_dim_0 (ct_final_dim_0) int64 0 1 2 3 4 ... 2184 2185 2186 2187 Data variables: ct_final (chain, draw, ct_final_dim_0) int64 ... Attributes: created_at: 2022-01-26 09:17:31.708330 arviz_version: 0.11.2 inference_library: pymc3 inference_library_version: 3.11.4 previous_created_at: ['2022-01-26T14:09:26.735827', '2022-01-26T14...
- Dimensions:
- chain: 2
- draw: 1000
- ct_final_dim_0: 2188
- Coordinates: (3)
- chain(chain)int640 1
array([0, 1])
- draw(draw)int640 1 2 3 4 5 ... 995 996 997 998 999
array([ 0, 1, 2, ..., 997, 998, 999])
- ct_final_dim_0(ct_final_dim_0)int640 1 2 3 4 ... 2184 2185 2186 2187
array([ 0, 1, 2, ..., 2185, 2186, 2187])
- Data variables: (1)
- ct_final(chain, draw, ct_final_dim_0)int64...
[4376000 values with dtype=int64]
- Attributes: (5)
- created_at :
- 2022-01-26 09:17:31.708330
- arviz_version :
- 0.11.2
- inference_library :
- pymc3
- inference_library_version :
- 3.11.4
- previous_created_at :
- ['2022-01-26T14:09:26.735827', '2022-01-26T14:16:59.787699']
<li class = "xr-section-item">
<input id="idata_log_likelihooda94c2771-9d8b-4109-94b3-b20ee046e926" class="xr-section-summary-in" type="checkbox">
<label for="idata_log_likelihooda94c2771-9d8b-4109-94b3-b20ee046e926" class = "xr-section-summary">log_likelihood</label>
<div class="xr-section-inline-details"></div>
<div class="xr-section-details">
<ul id="xr-dataset-coord-list" class="xr-var-list">
<div style="padding-left:2rem;"><div><svg style="position: absolute; width: 0; height: 0; overflow: hidden">
:root { --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54)); --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38)); --xr-border-color: var(--jp-border-color2, #e0e0e0); --xr-disabled-color: var(--jp-layout-color3, #bdbdbd); --xr-background-color: var(--jp-layout-color0, white); --xr-background-color-row-even: var(--jp-layout-color1, white); --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); }
html[theme=dark], body.vscode-dark { --xr-font-color0: rgba(255, 255, 255, 1); --xr-font-color2: rgba(255, 255, 255, 0.54); --xr-font-color3: rgba(255, 255, 255, 0.38); --xr-border-color: #1F1F1F; --xr-disabled-color: #515151; --xr-background-color: #111111; --xr-background-color-row-even: #111111; --xr-background-color-row-odd: #313131; }
.xr-wrap { display: block !important; min-width: 300px; max-width: 700px; }
.xr-text-repr-fallback { /* fallback to plain text repr when CSS is not injected (untrusted notebook) */ display: none; }
.xr-header { padding-top: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: solid 1px var(--xr-border-color); }
.xr-header > div, .xr-header > ul { display: inline; margin-top: 0; margin-bottom: 0; }
.xr-obj-type, .xr-array-name { margin-left: 2px; margin-right: 10px; }
.xr-obj-type { color: var(--xr-font-color2); }
.xr-sections { padding-left: 0 !important; display: grid; grid-template-columns: 150px auto auto 1fr 20px 20px; }
.xr-section-item { display: contents; }
.xr-section-item input { display: none; }
.xr-section-item input + label { color: var(--xr-disabled-color); }
.xr-section-item input:enabled + label { cursor: pointer; color: var(--xr-font-color2); }
.xr-section-item input:enabled + label:hover { color: var(--xr-font-color0); }
.xr-section-summary { grid-column: 1; color: var(--xr-font-color2); font-weight: 500; }
.xr-section-summary > span { display: inline-block; padding-left: 0.5em; }
.xr-section-summary-in:disabled + label { color: var(--xr-font-color2); }
.xr-section-summary-in + label:before { display: inline-block; content: '►'; font-size: 11px; width: 15px; text-align: center; }
.xr-section-summary-in:disabled + label:before { color: var(--xr-disabled-color); }
.xr-section-summary-in:checked + label:before { content: '▼'; }
.xr-section-summary-in:checked + label > span { display: none; }
.xr-section-summary, .xr-section-inline-details { padding-top: 4px; padding-bottom: 4px; }
.xr-section-inline-details { grid-column: 2 / -1; }
.xr-section-details { display: none; grid-column: 1 / -1; margin-bottom: 5px; }
.xr-section-summary-in:checked ~ .xr-section-details { display: contents; }
.xr-array-wrap { grid-column: 1 / -1; display: grid; grid-template-columns: 20px auto; }
.xr-array-wrap > label { grid-column: 1; vertical-align: top; }
.xr-preview { color: var(--xr-font-color3); }
.xr-array-preview, .xr-array-data { padding: 0 5px !important; grid-column: 2; }
.xr-array-data, .xr-array-in:checked ~ .xr-array-preview { display: none; }
.xr-array-in:checked ~ .xr-array-data, .xr-array-preview { display: inline-block; }
.xr-dim-list { display: inline-block !important; list-style: none; padding: 0 !important; margin: 0; }
.xr-dim-list li { display: inline-block; padding: 0; margin: 0; }
.xr-dim-list:before { content: '('; }
.xr-dim-list:after { content: ')'; }
.xr-dim-list li:not(:last-child):after { content: ','; padding-right: 5px; }
.xr-has-index { font-weight: bold; }
.xr-var-list, .xr-var-item { display: contents; }
.xr-var-item > div, .xr-var-item label, .xr-var-item > .xr-var-name span { background-color: var(--xr-background-color-row-even); margin-bottom: 0; }
.xr-var-item > .xr-var-name:hover span { padding-right: 5px; }
.xr-var-list > li:nth-child(odd) > div, .xr-var-list > li:nth-child(odd) > label, .xr-var-list > li:nth-child(odd) > .xr-var-name span { background-color: var(--xr-background-color-row-odd); }
.xr-var-name { grid-column: 1; }
.xr-var-dims { grid-column: 2; }
.xr-var-dtype { grid-column: 3; text-align: right; color: var(--xr-font-color2); }
.xr-var-preview { grid-column: 4; }
.xr-var-name, .xr-var-dims, .xr-var-dtype, .xr-preview, .xr-attrs dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.xr-var-name:hover, .xr-var-dims:hover, .xr-var-dtype:hover, .xr-attrs dt:hover { overflow: visible; width: auto; z-index: 1; }
.xr-var-attrs, .xr-var-data { display: none; background-color: var(--xr-background-color) !important; padding-bottom: 5px !important; }
.xr-var-attrs-in:checked ~ .xr-var-attrs, .xr-var-data-in:checked ~ .xr-var-data { display: block; }
.xr-var-data > table { float: right; }
.xr-var-name span, .xr-var-data, .xr-attrs { padding-left: 25px !important; }
.xr-attrs, .xr-var-attrs, .xr-var-data { grid-column: 1 / -1; }
dl.xr-attrs { padding: 0; margin: 0; display: grid; grid-template-columns: 125px auto; }
.xr-attrs dt, .xr-attrs dd { padding: 0; margin: 0; float: left; padding-right: 10px; width: auto; }
.xr-attrs dt { font-weight: normal; grid-column: 1; }
.xr-attrs dt:hover span { display: inline-block; background: var(--xr-background-color); padding-right: 10px; }
.xr-attrs dd { grid-column: 2; white-space: pre-wrap; word-break: break-all; }
.xr-icon-database, .xr-icon-file-text2 { display: inline-block; vertical-align: middle; width: 1em; height: 1.5em !important; stroke-width: 0; stroke: currentColor; fill: currentColor; } </style>
<xarray.Dataset> Dimensions: (chain: 2, draw: 1000, ct_final_dim_0: 2188) Coordinates:
-
chain (chain) int64 0 1
-
draw (draw) int64 0 1 2 3 4 5 6 7 ... 993 994 995 996 997 998 999
-
ct_final_dim_0 (ct_final_dim_0) int64 0 1 2 3 4 ... 2184 2185 2186 2187 Data variables: ct_final (chain, draw, ct_final_dim_0) float64 ... Attributes: created_at: 2022-01-26 09:17:31.708330 arviz_version: 0.11.2 inference_library: pymc3 inference_library_version: 3.11.4 previous_created_at: ['2022-01-26T14:09:20.668731', '2022-01-26T14...
- Dimensions:
- chain: 2
- draw: 1000
- ct_final_dim_0: 2188
- Coordinates: (3)
- chain(chain)int640 1
array([0, 1])
- draw(draw)int640 1 2 3 4 5 ... 995 996 997 998 999
array([ 0, 1, 2, ..., 997, 998, 999])
- ct_final_dim_0(ct_final_dim_0)int640 1 2 3 4 ... 2184 2185 2186 2187
array([ 0, 1, 2, ..., 2185, 2186, 2187])
- Data variables: (1)
- ct_final(chain, draw, ct_final_dim_0)float64...
[4376000 values with dtype=float64]
- Attributes: (5)
- created_at :
- 2022-01-26 09:17:31.708330
- arviz_version :
- 0.11.2
- inference_library :
- pymc3
- inference_library_version :
- 3.11.4
- previous_created_at :
- ['2022-01-26T14:09:20.668731', '2022-01-26T14:16:54.424579']
<li class = "xr-section-item">
<input id="idata_sample_stats1291ba84-0628-4893-aae7-a5d195b6cb27" class="xr-section-summary-in" type="checkbox">
<label for="idata_sample_stats1291ba84-0628-4893-aae7-a5d195b6cb27" class = "xr-section-summary">sample_stats</label>
<div class="xr-section-inline-details"></div>
<div class="xr-section-details">
<ul id="xr-dataset-coord-list" class="xr-var-list">
<div style="padding-left:2rem;"><div><svg style="position: absolute; width: 0; height: 0; overflow: hidden">
:root { --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54)); --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38)); --xr-border-color: var(--jp-border-color2, #e0e0e0); --xr-disabled-color: var(--jp-layout-color3, #bdbdbd); --xr-background-color: var(--jp-layout-color0, white); --xr-background-color-row-even: var(--jp-layout-color1, white); --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); }
html[theme=dark], body.vscode-dark { --xr-font-color0: rgba(255, 255, 255, 1); --xr-font-color2: rgba(255, 255, 255, 0.54); --xr-font-color3: rgba(255, 255, 255, 0.38); --xr-border-color: #1F1F1F; --xr-disabled-color: #515151; --xr-background-color: #111111; --xr-background-color-row-even: #111111; --xr-background-color-row-odd: #313131; }
.xr-wrap { display: block !important; min-width: 300px; max-width: 700px; }
.xr-text-repr-fallback { /* fallback to plain text repr when CSS is not injected (untrusted notebook) */ display: none; }
.xr-header { padding-top: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: solid 1px var(--xr-border-color); }
.xr-header > div, .xr-header > ul { display: inline; margin-top: 0; margin-bottom: 0; }
.xr-obj-type, .xr-array-name { margin-left: 2px; margin-right: 10px; }
.xr-obj-type { color: var(--xr-font-color2); }
.xr-sections { padding-left: 0 !important; display: grid; grid-template-columns: 150px auto auto 1fr 20px 20px; }
.xr-section-item { display: contents; }
.xr-section-item input { display: none; }
.xr-section-item input + label { color: var(--xr-disabled-color); }
.xr-section-item input:enabled + label { cursor: pointer; color: var(--xr-font-color2); }
.xr-section-item input:enabled + label:hover { color: var(--xr-font-color0); }
.xr-section-summary { grid-column: 1; color: var(--xr-font-color2); font-weight: 500; }
.xr-section-summary > span { display: inline-block; padding-left: 0.5em; }
.xr-section-summary-in:disabled + label { color: var(--xr-font-color2); }
.xr-section-summary-in + label:before { display: inline-block; content: '►'; font-size: 11px; width: 15px; text-align: center; }
.xr-section-summary-in:disabled + label:before { color: var(--xr-disabled-color); }
.xr-section-summary-in:checked + label:before { content: '▼'; }
.xr-section-summary-in:checked + label > span { display: none; }
.xr-section-summary, .xr-section-inline-details { padding-top: 4px; padding-bottom: 4px; }
.xr-section-inline-details { grid-column: 2 / -1; }
.xr-section-details { display: none; grid-column: 1 / -1; margin-bottom: 5px; }
.xr-section-summary-in:checked ~ .xr-section-details { display: contents; }
.xr-array-wrap { grid-column: 1 / -1; display: grid; grid-template-columns: 20px auto; }
.xr-array-wrap > label { grid-column: 1; vertical-align: top; }
.xr-preview { color: var(--xr-font-color3); }
.xr-array-preview, .xr-array-data { padding: 0 5px !important; grid-column: 2; }
.xr-array-data, .xr-array-in:checked ~ .xr-array-preview { display: none; }
.xr-array-in:checked ~ .xr-array-data, .xr-array-preview { display: inline-block; }
.xr-dim-list { display: inline-block !important; list-style: none; padding: 0 !important; margin: 0; }
.xr-dim-list li { display: inline-block; padding: 0; margin: 0; }
.xr-dim-list:before { content: '('; }
.xr-dim-list:after { content: ')'; }
.xr-dim-list li:not(:last-child):after { content: ','; padding-right: 5px; }
.xr-has-index { font-weight: bold; }
.xr-var-list, .xr-var-item { display: contents; }
.xr-var-item > div, .xr-var-item label, .xr-var-item > .xr-var-name span { background-color: var(--xr-background-color-row-even); margin-bottom: 0; }
.xr-var-item > .xr-var-name:hover span { padding-right: 5px; }
.xr-var-list > li:nth-child(odd) > div, .xr-var-list > li:nth-child(odd) > label, .xr-var-list > li:nth-child(odd) > .xr-var-name span { background-color: var(--xr-background-color-row-odd); }
.xr-var-name { grid-column: 1; }
.xr-var-dims { grid-column: 2; }
.xr-var-dtype { grid-column: 3; text-align: right; color: var(--xr-font-color2); }
.xr-var-preview { grid-column: 4; }
.xr-var-name, .xr-var-dims, .xr-var-dtype, .xr-preview, .xr-attrs dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.xr-var-name:hover, .xr-var-dims:hover, .xr-var-dtype:hover, .xr-attrs dt:hover { overflow: visible; width: auto; z-index: 1; }
.xr-var-attrs, .xr-var-data { display: none; background-color: var(--xr-background-color) !important; padding-bottom: 5px !important; }
.xr-var-attrs-in:checked ~ .xr-var-attrs, .xr-var-data-in:checked ~ .xr-var-data { display: block; }
.xr-var-data > table { float: right; }
.xr-var-name span, .xr-var-data, .xr-attrs { padding-left: 25px !important; }
.xr-attrs, .xr-var-attrs, .xr-var-data { grid-column: 1 / -1; }
dl.xr-attrs { padding: 0; margin: 0; display: grid; grid-template-columns: 125px auto; }
.xr-attrs dt, .xr-attrs dd { padding: 0; margin: 0; float: left; padding-right: 10px; width: auto; }
.xr-attrs dt { font-weight: normal; grid-column: 1; }
.xr-attrs dt:hover span { display: inline-block; background: var(--xr-background-color); padding-right: 10px; }
.xr-attrs dd { grid-column: 2; white-space: pre-wrap; word-break: break-all; }
.xr-icon-database, .xr-icon-file-text2 { display: inline-block; vertical-align: middle; width: 1em; height: 1.5em !important; stroke-width: 0; stroke: currentColor; fill: currentColor; } </style>
<xarray.Dataset> Dimensions: (chain: 2, draw: 1000) Coordinates:
-
chain (chain) int64 0 1
-
draw (draw) int64 0 1 2 3 4 5 6 ... 994 995 996 997 998 999 Data variables: (12/13) acceptance_rate (chain, draw) float64 0.9984 0.9769 ... 0.9729 0.9998 process_time_diff (chain, draw) float64 0.2611 0.2611 ... 0.1423 0.1399 tree_depth (chain, draw) int64 8 8 8 8 8 8 8 8 ... 7 7 7 7 7 7 7 7 perf_counter_start (chain, draw) float64 285.0 285.3 285.5 ... 439.8 439.9 diverging (chain, draw) bool False False False ... False False perf_counter_diff (chain, draw) float64 0.2616 0.2618 ... 0.1431 0.1404 ... ... energy_error (chain, draw) float64 -0.02757 0.03392 ... -0.06675 max_energy_error (chain, draw) float64 -0.2021 108.1 ... -0.1555 -0.172 n_steps (chain, draw) float64 255.0 255.0 255.0 ... 127.0 127.0 step_size (chain, draw) float64 0.04564 0.04564 ... 0.01685 energy (chain, draw) float64 2.107e+04 2.11e+04 ... 2.114e+04 step_size_bar (chain, draw) float64 0.02386 0.02386 ... 0.025 0.025 Attributes: created_at: 2022-01-26 09:17:31.708330 arviz_version: 0.11.2 inference_library: pymc3 inference_library_version: 3.11.4 sampling_time: 513.8245859146118 tuning_steps: 1000 previous_created_at: ['2022-01-26T14:09:19.833277', '2022-01-26T14... combined_sampling_time: [513.82458591 406.79231596]
- Dimensions:
- chain: 2
- draw: 1000
- Coordinates: (2)
- chain(chain)int640 1
array([0, 1])
- draw(draw)int640 1 2 3 4 5 ... 995 996 997 998 999
array([ 0, 1, 2, ..., 997, 998, 999])
- Data variables: (13)
- acceptance_rate(chain, draw)float64...
array([[0.998449, 0.976867, 0.991693, ..., 0.509752, 0.995778, 0.880502], [0.091901, 0.993763, 0.896557, ..., 0.659296, 0.97289 , 0.999812]])
- process_time_diff(chain, draw)float64...
array([[0.261084, 0.261104, 0.266857, ..., 0.262513, 0.263496, 0.261364], [0.1406 , 0.139476, 0.137998, ..., 0.145958, 0.142311, 0.139859]])
- tree_depth(chain, draw)int64...
array([[8, 8, 8, ..., 8, 8, 8], [7, 7, 7, ..., 7, 7, 7]])
- perf_counter_start(chain, draw)float64...
array([[284.996274, 285.258439, 285.52083 , ..., 545.260038, 545.524091, 545.789041], [292.668504, 292.810279, 292.950828, ..., 439.617553, 439.764797, 439.90843 ]])
- diverging(chain, draw)bool...
array([[False, False, False, ..., False, False, False], [False, False, False, ..., False, False, False]])
- perf_counter_diff(chain, draw)float64...
array([[0.2616 , 0.261841, 0.270336, ..., 0.263496, 0.26436 , 0.262236], [0.14121 , 0.139969, 0.138644, ..., 0.146701, 0.143068, 0.140391]])
- lp(chain, draw)float64...
array([[-19133.188415, -19143.287552, -19313.653023, ..., -19151.393401, -19184.975218, -19163.355112], [-19297.316882, -19185.501196, -19226.409339, ..., -19197.172918, -19216.651016, -19149.410865]])
- energy_error(chain, draw)float64...
array([[-2.757414e-02, 3.391936e-02, -4.841337e-02, ..., 8.190860e-01, -3.285830e-03, 2.857464e-01], [ 3.683828e+00, -3.620826e-02, -1.320665e-01, ..., 4.826039e-01, 8.016908e-02, -6.674801e-02]])
- max_energy_error(chain, draw)float64...
array([[-2.020929e-01, 1.080610e+02, -1.048874e+00, ..., 1.451944e+00, -7.488662e-02, -2.568079e+00], [ 4.527390e+01, -2.618344e-01, 2.857236e-01, ..., 8.012077e-01, -1.555487e-01, -1.720377e-01]])
- n_steps(chain, draw)float64...
array([[255., 255., 255., ..., 255., 255., 255.], [127., 127., 127., ..., 127., 127., 127.]])
- step_size(chain, draw)float64...
array([[0.045641, 0.045641, 0.045641, ..., 0.045641, 0.045641, 0.045641], [0.01685 , 0.01685 , 0.01685 , ..., 0.01685 , 0.01685 , 0.01685 ]])
- energy(chain, draw)float64...
array([[21071.874779, 21101.032167, 21306.300766, ..., 21115.093906, 21138.744851, 21129.353892], [21341.78142 , 21222.499393, 21178.67449 , ..., 21183.808668, 21142.186808, 21138.344935]])
- step_size_bar(chain, draw)float64...
array([[0.023865, 0.023865, 0.023865, ..., 0.023865, 0.023865, 0.023865], [0.025003, 0.025003, 0.025003, ..., 0.025003, 0.025003, 0.025003]])
- Attributes: (8)
- created_at :
- 2022-01-26 09:17:31.708330
- arviz_version :
- 0.11.2
- inference_library :
- pymc3
- inference_library_version :
- 3.11.4
- sampling_time :
- 513.8245859146118
- tuning_steps :
- 1000
- previous_created_at :
- ['2022-01-26T14:09:19.833277', '2022-01-26T14:16:53.519601']
- combined_sampling_time :
- [513.82458591 406.79231596]
<li class = "xr-section-item">
<input id="idata_observed_dataa9ad8d90-619e-4c28-bea9-e63f43e6dba0" class="xr-section-summary-in" type="checkbox">
<label for="idata_observed_dataa9ad8d90-619e-4c28-bea9-e63f43e6dba0" class = "xr-section-summary">observed_data</label>
<div class="xr-section-inline-details"></div>
<div class="xr-section-details">
<ul id="xr-dataset-coord-list" class="xr-var-list">
<div style="padding-left:2rem;"><div><svg style="position: absolute; width: 0; height: 0; overflow: hidden">
:root { --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54)); --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38)); --xr-border-color: var(--jp-border-color2, #e0e0e0); --xr-disabled-color: var(--jp-layout-color3, #bdbdbd); --xr-background-color: var(--jp-layout-color0, white); --xr-background-color-row-even: var(--jp-layout-color1, white); --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); }
html[theme=dark], body.vscode-dark { --xr-font-color0: rgba(255, 255, 255, 1); --xr-font-color2: rgba(255, 255, 255, 0.54); --xr-font-color3: rgba(255, 255, 255, 0.38); --xr-border-color: #1F1F1F; --xr-disabled-color: #515151; --xr-background-color: #111111; --xr-background-color-row-even: #111111; --xr-background-color-row-odd: #313131; }
.xr-wrap { display: block !important; min-width: 300px; max-width: 700px; }
.xr-text-repr-fallback { /* fallback to plain text repr when CSS is not injected (untrusted notebook) */ display: none; }
.xr-header { padding-top: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: solid 1px var(--xr-border-color); }
.xr-header > div, .xr-header > ul { display: inline; margin-top: 0; margin-bottom: 0; }
.xr-obj-type, .xr-array-name { margin-left: 2px; margin-right: 10px; }
.xr-obj-type { color: var(--xr-font-color2); }
.xr-sections { padding-left: 0 !important; display: grid; grid-template-columns: 150px auto auto 1fr 20px 20px; }
.xr-section-item { display: contents; }
.xr-section-item input { display: none; }
.xr-section-item input + label { color: var(--xr-disabled-color); }
.xr-section-item input:enabled + label { cursor: pointer; color: var(--xr-font-color2); }
.xr-section-item input:enabled + label:hover { color: var(--xr-font-color0); }
.xr-section-summary { grid-column: 1; color: var(--xr-font-color2); font-weight: 500; }
.xr-section-summary > span { display: inline-block; padding-left: 0.5em; }
.xr-section-summary-in:disabled + label { color: var(--xr-font-color2); }
.xr-section-summary-in + label:before { display: inline-block; content: '►'; font-size: 11px; width: 15px; text-align: center; }
.xr-section-summary-in:disabled + label:before { color: var(--xr-disabled-color); }
.xr-section-summary-in:checked + label:before { content: '▼'; }
.xr-section-summary-in:checked + label > span { display: none; }
.xr-section-summary, .xr-section-inline-details { padding-top: 4px; padding-bottom: 4px; }
.xr-section-inline-details { grid-column: 2 / -1; }
.xr-section-details { display: none; grid-column: 1 / -1; margin-bottom: 5px; }
.xr-section-summary-in:checked ~ .xr-section-details { display: contents; }
.xr-array-wrap { grid-column: 1 / -1; display: grid; grid-template-columns: 20px auto; }
.xr-array-wrap > label { grid-column: 1; vertical-align: top; }
.xr-preview { color: var(--xr-font-color3); }
.xr-array-preview, .xr-array-data { padding: 0 5px !important; grid-column: 2; }
.xr-array-data, .xr-array-in:checked ~ .xr-array-preview { display: none; }
.xr-array-in:checked ~ .xr-array-data, .xr-array-preview { display: inline-block; }
.xr-dim-list { display: inline-block !important; list-style: none; padding: 0 !important; margin: 0; }
.xr-dim-list li { display: inline-block; padding: 0; margin: 0; }
.xr-dim-list:before { content: '('; }
.xr-dim-list:after { content: ')'; }
.xr-dim-list li:not(:last-child):after { content: ','; padding-right: 5px; }
.xr-has-index { font-weight: bold; }
.xr-var-list, .xr-var-item { display: contents; }
.xr-var-item > div, .xr-var-item label, .xr-var-item > .xr-var-name span { background-color: var(--xr-background-color-row-even); margin-bottom: 0; }
.xr-var-item > .xr-var-name:hover span { padding-right: 5px; }
.xr-var-list > li:nth-child(odd) > div, .xr-var-list > li:nth-child(odd) > label, .xr-var-list > li:nth-child(odd) > .xr-var-name span { background-color: var(--xr-background-color-row-odd); }
.xr-var-name { grid-column: 1; }
.xr-var-dims { grid-column: 2; }
.xr-var-dtype { grid-column: 3; text-align: right; color: var(--xr-font-color2); }
.xr-var-preview { grid-column: 4; }
.xr-var-name, .xr-var-dims, .xr-var-dtype, .xr-preview, .xr-attrs dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.xr-var-name:hover, .xr-var-dims:hover, .xr-var-dtype:hover, .xr-attrs dt:hover { overflow: visible; width: auto; z-index: 1; }
.xr-var-attrs, .xr-var-data { display: none; background-color: var(--xr-background-color) !important; padding-bottom: 5px !important; }
.xr-var-attrs-in:checked ~ .xr-var-attrs, .xr-var-data-in:checked ~ .xr-var-data { display: block; }
.xr-var-data > table { float: right; }
.xr-var-name span, .xr-var-data, .xr-attrs { padding-left: 25px !important; }
.xr-attrs, .xr-var-attrs, .xr-var-data { grid-column: 1 / -1; }
dl.xr-attrs { padding: 0; margin: 0; display: grid; grid-template-columns: 125px auto; }
.xr-attrs dt, .xr-attrs dd { padding: 0; margin: 0; float: left; padding-right: 10px; width: auto; }
.xr-attrs dt { font-weight: normal; grid-column: 1; }
.xr-attrs dt:hover span { display: inline-block; background: var(--xr-background-color); padding-right: 10px; }
.xr-attrs dd { grid-column: 2; white-space: pre-wrap; word-break: break-all; }
.xr-icon-database, .xr-icon-file-text2 { display: inline-block; vertical-align: middle; width: 1em; height: 1.5em !important; stroke-width: 0; stroke: currentColor; fill: currentColor; } </style>
<xarray.Dataset> Dimensions: (ct_final_dim_0: 2188) Coordinates:
-
ct_final_dim_0 (ct_final_dim_0) int64 0 1 2 3 4 ... 2184 2185 2186 2187 Data variables: ct_final (ct_final_dim_0) int64 135 188 243 407 307 ... 88 220 13 189 Attributes: created_at: 2022-01-26 09:17:31.708330 arviz_version: 0.11.2 inference_library: pymc3 inference_library_version: 3.11.4 previous_created_at: ['2022-01-26T14:09:20.670619', '2022-01-26T14...
- Dimensions:
- ct_final_dim_0: 2188
- Coordinates: (1)
- ct_final_dim_0(ct_final_dim_0)int640 1 2 3 4 ... 2184 2185 2186 2187
array([ 0, 1, 2, ..., 2185, 2186, 2187])
- Data variables: (1)
- ct_final(ct_final_dim_0)int64...
array([135, 188, 243, ..., 220, 13, 189])
- Attributes: (5)
- created_at :
- 2022-01-26 09:17:31.708330
- arviz_version :
- 0.11.2
- inference_library :
- pymc3
- inference_library_version :
- 3.11.4
- previous_created_at :
- ['2022-01-26T14:09:20.670619', '2022-01-26T14:16:54.426497']
</ul>
</div>
<style> /* CSS stylesheet for displaying InferenceData objects in jupyterlab.
*/
:root { --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1)); --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54)); --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38)); --xr-border-color: var(--jp-border-color2, #e0e0e0); --xr-disabled-color: var(--jp-layout-color3, #bdbdbd); --xr-background-color: var(--jp-layout-color0, white); --xr-background-color-row-even: var(--jp-layout-color1, white); --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee); }
html[theme=dark], body.vscode-dark { --xr-font-color0: rgba(255, 255, 255, 1); --xr-font-color2: rgba(255, 255, 255, 0.54); --xr-font-color3: rgba(255, 255, 255, 0.38); --xr-border-color: #1F1F1F; --xr-disabled-color: #515151; --xr-background-color: #111111; --xr-background-color-row-even: #111111; --xr-background-color-row-odd: #313131; }
.xr-wrap { display: block; min-width: 300px; max-width: 700px; }
.xr-text-repr-fallback { /* fallback to plain text repr when CSS is not injected (untrusted notebook) */ display: none; }
.xr-header { padding-top: 6px; padding-bottom: 6px; margin-bottom: 4px; border-bottom: solid 1px var(--xr-border-color); }
.xr-header > div, .xr-header > ul { display: inline; margin-top: 0; margin-bottom: 0; }
.xr-obj-type, .xr-array-name { margin-left: 2px; margin-right: 10px; }
.xr-obj-type { color: var(--xr-font-color2); }
.xr-sections { padding-left: 0 !important; display: grid; grid-template-columns: 150px auto auto 1fr 20px 20px; }
.xr-sections.group-sections { grid-template-columns: auto; }
.xr-section-item { display: contents; }
.xr-section-item input { display: none; }
.xr-section-item input + label { color: var(--xr-disabled-color); }
.xr-section-item input:enabled + label { cursor: pointer; color: var(--xr-font-color2); }
.xr-section-item input:enabled + label:hover { color: var(--xr-font-color0); }
.xr-section-summary { grid-column: 1; color: var(--xr-font-color2); font-weight: 500; }
.xr-section-summary > span { display: inline-block; padding-left: 0.5em; }
.xr-section-summary-in:disabled + label { color: var(--xr-font-color2); }
.xr-section-summary-in + label:before { display: inline-block; content: '►'; font-size: 11px; width: 15px; text-align: center; }
.xr-section-summary-in:disabled + label:before { color: var(--xr-disabled-color); }
.xr-section-summary-in:checked + label:before { content: '▼'; }
.xr-section-summary-in:checked + label > span { display: none; }
.xr-section-summary, .xr-section-inline-details { padding-top: 4px; padding-bottom: 4px; }
.xr-section-inline-details { grid-column: 2 / -1; }
.xr-section-details { display: none; grid-column: 1 / -1; margin-bottom: 5px; }
.xr-section-summary-in:checked ~ .xr-section-details { display: contents; }
.xr-array-wrap { grid-column: 1 / -1; display: grid; grid-template-columns: 20px auto; }
.xr-array-wrap > label { grid-column: 1; vertical-align: top; }
.xr-preview { color: var(--xr-font-color3); }
.xr-array-preview, .xr-array-data { padding: 0 5px !important; grid-column: 2; }
.xr-array-data, .xr-array-in:checked ~ .xr-array-preview { display: none; }
.xr-array-in:checked ~ .xr-array-data, .xr-array-preview { display: inline-block; }
.xr-dim-list { display: inline-block !important; list-style: none; padding: 0 !important; margin: 0; }
.xr-dim-list li { display: inline-block; padding: 0; margin: 0; }
.xr-dim-list:before { content: '('; }
.xr-dim-list:after { content: ')'; }
.xr-dim-list li:not(:last-child):after { content: ','; padding-right: 5px; }
.xr-has-index { font-weight: bold; }
.xr-var-list, .xr-var-item { display: contents; }
.xr-var-item > div, .xr-var-item label, .xr-var-item > .xr-var-name span { background-color: var(--xr-background-color-row-even); margin-bottom: 0; }
.xr-var-item > .xr-var-name:hover span { padding-right: 5px; }
.xr-var-list > li:nth-child(odd) > div, .xr-var-list > li:nth-child(odd) > label, .xr-var-list > li:nth-child(odd) > .xr-var-name span { background-color: var(--xr-background-color-row-odd); }
.xr-var-name { grid-column: 1; }
.xr-var-dims { grid-column: 2; }
.xr-var-dtype { grid-column: 3; text-align: right; color: var(--xr-font-color2); }
.xr-var-preview { grid-column: 4; }
.xr-var-name, .xr-var-dims, .xr-var-dtype, .xr-preview, .xr-attrs dt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.xr-var-name:hover, .xr-var-dims:hover, .xr-var-dtype:hover, .xr-attrs dt:hover { overflow: visible; width: auto; z-index: 1; }
.xr-var-attrs, .xr-var-data { display: none; background-color: var(--xr-background-color) !important; padding-bottom: 5px !important; }
.xr-var-attrs-in:checked ~ .xr-var-attrs, .xr-var-data-in:checked ~ .xr-var-data { display: block; }
.xr-var-data > table { float: right; }
.xr-var-name span, .xr-var-data, .xr-attrs { padding-left: 25px !important; }
.xr-attrs, .xr-var-attrs, .xr-var-data { grid-column: 1 / -1; }
dl.xr-attrs { padding: 0; margin: 0; display: grid; grid-template-columns: 125px auto; }
.xr-attrs dt, dd { padding: 0; margin: 0; float: left; padding-right: 10px; width: auto; }
.xr-attrs dt { font-weight: normal; grid-column: 1; }
.xr-attrs dt:hover span { display: inline-block; background: var(--xr-background-color); padding-right: 10px; }
.xr-attrs dd { grid-column: 2; white-space: pre-wrap; word-break: break-all; }
.xr-icon-database, .xr-icon-file-text2 { display: inline-block; vertical-align: middle; width: 1em; height: 1.5em !important; stroke-width: 0; stroke: currentColor; fill: currentColor; } .xr-wrap{width:700px!important;} </style>
data_manager = CrisprScreenDataManager(
data_file=speclet.io.DataFile.DEPMAP_CRC_BONE_SUBSAMPLE
)
counts_data = data_manager.get_data()
valid_data = speclet_hnb.data_processing_pipeline(counts_data)
valid_data
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
sgrna | replicate_id | lfc | p_dna_batch | genome_alignment | hugo_symbol | screen | multiple_hits_on_gene | sgrna_target_chr | sgrna_target_pos | ... | is_mutated | copy_number | lineage | primary_or_metastasis | is_male | age | counts_final_total | counts_initial_total | counts_final_rpm | counts_initial_adj | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | AGCTGAGCGCAGGGACCGGG | LS513-311Cas9_RepA_p6_batch2 | -0.020788 | 2 | chr1_27012633_- | TENT5B | broad | True | 1 | 27012633 | ... | False | 0.961139 | colorectal | primary | True | 63.0 | 35176093 | 1.072163e+06 | 4.837834 | 142.977169 |
1 | CTACTAGACTTCCTGCCGGC | LS513-311Cas9_RepA_p6_batch2 | -0.666070 | 2 | chr1_27006754_- | TENT5B | broad | True | 1 | 27006754 | ... | False | 0.961139 | colorectal | primary | True | 63.0 | 35176093 | 1.072163e+06 | 6.344539 | 287.920163 |
2 | AAACTTGCTGACGTGCCTGG | LS513-311Cas9_RepA_p6_batch2 | -0.130231 | 2 | chr4_52628042_- | USP46 | broad | True | 4 | 52628042 | ... | False | 0.952543 | colorectal | primary | True | 63.0 | 35176093 | 1.072163e+06 | 7.908101 | 246.725036 |
3 | AACGATCTCATCCTCAAAAG | LS513-311Cas9_RepA_p6_batch2 | 0.198958 | 2 | chr11_107549790_+ | ALKBH8 | broad | True | 11 | 107549790 | ... | False | 0.960147 | colorectal | primary | True | 63.0 | 35176093 | 1.072163e+06 | 12.570358 | 311.083872 |
4 | AAGTTCCTCTGAAGTTCGCA | LS513-311Cas9_RepA_p6_batch2 | -0.182191 | 2 | chr2_241704672_- | ING5 | broad | True | 2 | 241704672 | ... | False | 0.973700 | colorectal | primary | True | 63.0 | 35176093 | 1.072163e+06 | 9.727518 | 314.749171 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2183 | TTGTGTCGTTCGCCGCACA | EW22_c907R1 | 0.244659 | CRISPR_C6596666.sample | chr13_113429046_- | ADPRHL1 | sanger | True | 13 | 113429046 | ... | False | 0.785368 | bone | NaN | NaN | NaN | 28939388 | 1.101090e+06 | 15.202097 | 294.396335 |
2184 | TTGTGTCTACTGTTCTAGA | EW22_c907R1 | -0.116722 | CRISPR_C6596666.sample | chr12_25225698_+ | KRAS | sanger | True | 12 | 25225698 | ... | False | 1.155020 | bone | NaN | NaN | NaN | 28939388 | 1.101090e+06 | 4.040838 | 103.372307 |
2185 | TTTAAACGACTGTCAAACC | EW22_c907R1 | 0.558014 | CRISPR_C6596666.sample | chr4_46065548_+ | GABRG1 | sanger | True | 4 | 46065548 | ... | False | 0.962042 | bone | NaN | NaN | NaN | 28939388 | 1.101090e+06 | 8.602096 | 135.115172 |
2186 | TTTGAGAAGTCCCCCCTGC | EW22_c907R1 | -3.103909 | CRISPR_C6596666.sample | chr19_17862113_+ | RPL18A | sanger | True | 19 | 17862113 | ... | False | 1.146916 | bone | NaN | NaN | NaN | 28939388 | 1.101090e+06 | 1.449215 | 313.668789 |
2187 | TTTGTTGGGACCAATGGAA | EW22_c907R1 | -0.360181 | CRISPR_C6596666.sample | chr6_42573875_+ | UBR2 | sanger | True | 6 | 42573875 | ... | False | 1.026703 | bone | NaN | NaN | NaN | 28939388 | 1.101090e+06 | 7.530891 | 224.108562 |
2188 rows × 28 columns
az.plot_trace(
hnb_trace,
var_names=speclet_hnb.vars_regex(ModelFitMethod.PYMC3_MCMC),
filter_vars="regex",
)
plt.tight_layout();
mu_beta_post = az.summary(
hnb_trace, var_names=["mu_beta"], hdi_prob=HDI_PROB, kind="stats"
).assign(hugo_symbol=hnb_trace.posterior.coords["gene"])
sgrna_to_gene_map = valid_data[["hugo_symbol", "sgrna"]].drop_duplicates()
beta_s_post = (
az.summary(hnb_trace, var_names=["beta_s"], hdi_prob=HDI_PROB, kind="stats")
.assign(sgrna=hnb_trace.posterior.coords["sgrna"])
.merge(sgrna_to_gene_map, on="sgrna")
)
(
gg.ggplot(mu_beta_post, gg.aes(x="hugo_symbol", y="mean"))
+ gg.geom_linerange(gg.aes(ymin="hdi_5.5%", ymax="hdi_94.5%"), alpha=0.3, size=0.8)
+ gg.geom_point(size=1)
+ gg.geom_point(data=beta_s_post, size=0.5, color="blue")
+ gg.scale_y_continuous(expand=(0.02, 0))
+ gg.theme(
axis_text_x=gg.element_blank(),
figure_size=(10, 4),
panel_grid_major_x=gg.element_blank(),
)
+ gg.labs(x="gene", y=f"gene effects posterior\n(mean and {HDI_LBL} HDI)")
)
<ggplot: (376505242)>
mu_gamma_post = az.summary(
hnb_trace, var_names=["mu_gamma_c"], hdi_prob=HDI_PROB, kind="stats"
).assign(lineage=hnb_trace.posterior.coords["lineage"])
cellline_to_lineage_map = valid_data[["depmap_id", "lineage"]].drop_duplicates()
gamma_post = (
az.summary(hnb_trace, var_names=["gamma_c"], hdi_prob=HDI_PROB, kind="stats")
.assign(depmap_id=hnb_trace.posterior.coords["cell_line"])
.merge(cellline_to_lineage_map, on="depmap_id")
)
(
gg.ggplot(gamma_post, gg.aes(x="depmap_id", y="mean"))
+ gg.facet_wrap("~lineage", nrow=1, scales="free_x")
+ gg.geom_hline(gg.aes(yintercept="mean"), data=mu_gamma_post, linetype="--")
+ gg.geom_linerange(
gg.aes(ymin="hdi_5.5%", ymax="hdi_94.5%"), alpha=0.3, size=1, color="blue"
)
+ gg.geom_point(size=1.5, color="blue")
+ gg.scale_y_continuous(expand=(0.02, 0))
+ gg.theme(
axis_text_x=gg.element_blank(),
figure_size=(4, 4),
panel_grid_major_x=gg.element_blank(),
)
+ gg.labs(x="cell line", y=f"cell line effects posterior\n(mean and {HDI_LBL} HDI)")
)
<ggplot: (375587825)>
def _variable_index_to_coords(
df: pd.DataFrame, col: str, var_name: str
) -> pd.DataFrame:
return df.assign(
coords=lambda d: [
x.replace(f"{var_name}[", "").replace("]", "").split(",") for x in d[col]
]
)
kappa_post = (
az.summary(hnb_trace, var_names=["kappa_sc"], hdi_prob=HDI_PROB, kind="stats")
.reset_index(drop=False)
.pipe(_variable_index_to_coords, col="index", var_name="kappa_sc")
.assign(
sgrna=lambda d: [x[0].strip() for x in d["coords"]],
depmap_id=lambda d: [x[1].strip() for x in d["coords"]],
)
.drop(columns=["coords"])
.merge(sgrna_to_gene_map, on="sgrna")
.merge(cellline_to_lineage_map, on="depmap_id")
)
kappa_post.head()
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
index | mean | sd | hdi_5.5% | hdi_94.5% | sgrna | depmap_id | hugo_symbol | lineage | |
---|---|---|---|---|---|---|---|---|---|
0 | kappa_sc[AAACTTGCTGACGTGCCTGG, ACH-000007] | -0.000 | 0.045 | -0.072 | 0.061 | AAACTTGCTGACGTGCCTGG | ACH-000007 | USP46 | colorectal |
1 | kappa_sc[AACAACTAACTTTGTACAT, ACH-000007] | -0.004 | 0.043 | -0.065 | 0.061 | AACAACTAACTTTGTACAT | ACH-000007 | IMPA1 | colorectal |
2 | kappa_sc[AACAGCTCGTTGTACCGCT, ACH-000007] | -0.003 | 0.043 | -0.062 | 0.069 | AACAGCTCGTTGTACCGCT | ACH-000007 | CTNNB1 | colorectal |
3 | kappa_sc[AACCACTCGCTACCGAAGC, ACH-000007] | 0.002 | 0.042 | -0.066 | 0.060 | AACCACTCGCTACCGAAGC | ACH-000007 | FUCA2 | colorectal |
4 | kappa_sc[AACGATCTCATCCTCAAAAG, ACH-000007] | 0.000 | 0.040 | -0.070 | 0.054 | AACGATCTCATCCTCAAAAG | ACH-000007 | ALKBH8 | colorectal |
(
gg.ggplot(kappa_post, gg.aes(x="depmap_id", y="sgrna", fill="mean"))
+ gg.facet_grid("hugo_symbol ~ lineage", scales="free")
+ gg.geom_tile(color=None)
+ gg.scale_x_discrete(expand=(0, 0.5))
+ gg.scale_fill_gradient2(low="#ca0020", mid="white", high="#0571b0", midpoint=0)
+ gg.theme(
axis_text_x=gg.element_text(angle=90, size=8),
axis_text_y=gg.element_blank(),
figure_size=(3, 25),
strip_text_x=gg.element_text(size=8),
strip_text_y=gg.element_text(size=6, angle=0, hjust=0),
subplots_adjust={"hspace": 0.0},
panel_border=gg.element_rect(color="gray"),
panel_grid=gg.element_blank(),
legend_position="right",
)
+ gg.labs(x="cell line", y="sgRNA", fill="mean")
)
<ggplot: (375735028)>
sd_posts = az.summary(
hnb_trace, var_names=["sigma"], filter_vars="like", hdi_prob=HDI_PROB
)
sd_posts
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
mean | sd | hdi_5.5% | hdi_94.5% | mcse_mean | mcse_sd | ess_bulk | ess_tail | r_hat | |
---|---|---|---|---|---|---|---|---|---|
sigma_mu_beta | 0.131 | 0.028 | 0.087 | 0.177 | 0.003 | 0.002 | 91.0 | 249.0 | 1.01 |
sigma_beta | 0.188 | 0.018 | 0.156 | 0.215 | 0.001 | 0.001 | 285.0 | 452.0 | 1.00 |
sigma_mu_gamma_c | 0.224 | 0.224 | 0.000 | 0.526 | 0.009 | 0.006 | 581.0 | 790.0 | 1.00 |
sigma_gamma_c | 0.018 | 0.014 | 0.000 | 0.036 | 0.001 | 0.000 | 509.0 | 553.0 | 1.01 |
sigma_kappa_sc | 0.035 | 0.026 | 0.000 | 0.071 | 0.002 | 0.002 | 143.0 | 311.0 | 1.01 |
sd_post_draws = pd.DataFrame()
for varname in sd_posts.index.values:
_x = hnb_trace.posterior.get(varname).values.flatten()
_df = pd.DataFrame({"value": _x}).assign(var_name=varname)
sd_post_draws = pd.concat([sd_post_draws, _df])
(
gg.ggplot(sd_post_draws, gg.aes(x="value", color="var_name", fill="var_name"))
+ gg.geom_density(alpha=0.1)
+ gg.scale_x_continuous(expand=(0, 0), limits=(0, 2))
+ gg.scale_y_continuous(expand=(0, 0, 0.02, 0))
+ gg.scale_color_brewer(
type="qual", palette="Set1", guide=gg.guide_legend(override_aes={"alpha": 0.6})
)
+ gg.scale_fill_brewer(type="qual", palette="Set1")
+ gg.theme(
figure_size=(6, 4),
legend_position=(0.75, 0.6),
legend_background=gg.element_blank(),
)
+ gg.labs(x="posterior", y="probability density", color="variable", fill="variable")
)
<ggplot: (353610487)>
az.plot_trace(hnb_trace, var_names=["sigma"], filter_vars="like")
plt.tight_layout();
sigma_gamma_post_draws = hnb_trace.posterior["sigma_gamma_c"].values.flatten()
divergences = hnb_trace.sample_stats.diverging.values.flatten()
N_CELL_LINES = valid_data.depmap_id.nunique()
gamma_post_draws = hnb_trace.posterior["gamma_c"].values.reshape(-1, N_CELL_LINES)
gamma_post_draws_df = (
pd.DataFrame(
gamma_post_draws, columns=hnb_trace.posterior.coords["cell_line"].values
)
.assign(sigma_gamma=sigma_gamma_post_draws, divergence=divergences)
.reset_index(drop=False)
.pivot_longer(index=["index", "sigma_gamma", "divergence"], names_to="depmap_id")
)
gamma_post_draws_df.head()
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
index | sigma_gamma | divergence | depmap_id | value | |
---|---|---|---|---|---|
0 | 0 | 0.016342 | False | ACH-000007 | -0.071051 |
1 | 1 | 0.014862 | False | ACH-000007 | 0.212257 |
2 | 2 | 0.000599 | False | ACH-000007 | -0.037676 |
3 | 3 | 0.013518 | False | ACH-000007 | -0.018243 |
4 | 4 | 0.009521 | False | ACH-000007 | 0.006166 |
def organize_group_mean_against_stddev(
trace: az.InferenceData, sd_var: str, mu_var: str, coord: str
) -> pd.DataFrame:
groups = trace.posterior.coords[coord].values
sd_post_draws = trace.posterior[sd_var].values.flatten()
divergences = trace.sample_stats.diverging.values.flatten()
mu_post_draws = trace.posterior[mu_var].values.reshape(-1, len(groups))
post_draws_df = (
pd.DataFrame(mu_post_draws, columns=groups)
.assign(__sd_var=sd_post_draws, divergence=divergences)
.reset_index(drop=False)
.pivot_longer(
index=["index", "__sd_var", "divergence"], names_to=coord, values_to=mu_var
)
.rename(columns={"__sd_var": sd_var})
)
return post_draws_df
def plot_group_mean_against_stddev(
sd_and_mu_df: pd.DataFrame, x: str, y: str, fct: str
) -> gg.ggplot:
return (
gg.ggplot(sd_and_mu_df.sort_values("divergence"), gg.aes(x=x, y=y))
+ gg.facet_wrap(f"~{fct}")
+ gg.geom_point(gg.aes(color="divergence"), size=0.7, alpha=0.7)
+ gg.scale_color_manual(values={True: "red", False: "k"})
)
gamma_post_draws_df = organize_group_mean_against_stddev(
hnb_trace, sd_var="sigma_gamma_c", mu_var="gamma_c", coord="cell_line"
)
plot_group_mean_against_stddev(
gamma_post_draws_df, x="gamma_c", y="np.log10(sigma_gamma_c)", fct="cell_line"
) + gg.theme(figure_size=(8, 8))
<ggplot: (354035929)>
mu_gamma_post_draws_df = organize_group_mean_against_stddev(
hnb_trace, sd_var="sigma_mu_gamma_c", mu_var="mu_gamma_c", coord="lineage"
)
(
plot_group_mean_against_stddev(
mu_gamma_post_draws_df,
x="mu_gamma_c",
y="np.log10(sigma_mu_gamma_c)",
fct="lineage",
)
+ gg.theme(figure_size=(6, 4))
)
<ggplot: (354588820)>
hnb_ppc = hnb_trace.posterior_predictive["ct_final"].values.reshape(
-1, valid_data.shape[0]
)
hnb_ppc.shape
(2000, 2188)
hnb_ppc_sample = (
pd.DataFrame(hnb_ppc[::80, :].T)
.reset_index(drop=False)
.rename(columns={"index": "data_idx"})
.pivot_longer(index="data_idx", names_to="ppc_draw", values_to="counts_final")
)
print(f"num. examples: {len(hnb_ppc_sample.ppc_draw.unique())}")
hnb_ppc_avg = pd.DataFrame({"counts_final": np.median(hnb_ppc, axis=0)})
ppc_hdi = az.hdi(hnb_ppc, hdi_prob=HDI_PROB)
hnb_ppc_avg["hdi_low"] = ppc_hdi[:, 0]
hnb_ppc_avg["hdi_hi"] = ppc_hdi[:, 1]
plt_df = pd.concat(
[
hnb_ppc_sample.assign(lbl="PP draw"),
hnb_ppc_avg[["counts_final"]].assign(lbl="PP avg.", ppc_draw="PP avg."),
valid_data[["counts_final"]].assign(lbl="obs.", ppc_draw="obs."),
]
)
plt_df.head()
num. examples: 25
/var/folders/r4/qpcdgl_14hbd412snp1jnv300000gn/T/ipykernel_1541/295761941.py:10: FutureWarning: hdi currently interprets 2d data as (draw, shape) but this will change in a future release to (chain, draw) for coherence with other functions
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
data_idx | ppc_draw | counts_final | lbl | |
---|---|---|---|---|
0 | 0.0 | 0 | 73.0 | PP draw |
1 | 1.0 | 0 | 509.0 | PP draw |
2 | 2.0 | 0 | 268.0 | PP draw |
3 | 3.0 | 0 | 458.0 | PP draw |
4 | 4.0 | 0 | 212.0 | PP draw |
(
gg.ggplot(plt_df, gg.aes(x="counts_final", color="lbl", group="ppc_draw"))
+ gg.geom_density(gg.aes(size="lbl", linetype="lbl"), alpha=0)
+ gg.scale_x_continuous(expand=(0, 0), limits=(0, 2500))
+ gg.scale_y_continuous(expand=(0, 0, 0.02, 0))
+ gg.scale_color_manual(
values={"PP draw": "k", "PP avg.": "#6baed6", "obs.": "#dd1c77"},
guide=gg.guide_legend(override_aes={"size": 1, "fill": "white"}),
)
+ gg.scale_size_manual(values={"PP draw": 0.1, "PP avg.": 1, "obs.": 1})
+ gg.scale_linetype_manual(values={"PP draw": "--", "PP avg.": "-", "obs.": "-"})
+ gg.theme(
legend_title=gg.element_blank(),
legend_position=(0.8, 0.5),
legend_background=gg.element_blank(),
)
+ gg.labs(x="final counts", y="density")
)
/usr/local/Caskroom/miniconda/base/envs/speclet/lib/python3.9/site-packages/plotnine/layer.py:324: PlotnineWarning: stat_density : Removed 752 rows containing non-finite values.
<ggplot: (354983446)>
plt_df = (
valid_data.copy()
.assign(
ppc_avg=hnb_ppc_avg.counts_final,
hdi_low=hnb_ppc_avg.hdi_low,
hdi_hi=hnb_ppc_avg.hdi_hi,
)
.reset_index(drop=False)
)
(
gg.ggplot(plt_df, gg.aes(x="counts_final", y="ppc_avg"))
+ gg.geom_point(size=0.2, alpha=0.5)
+ gg.geom_abline(slope=1, intercept=0, linetype="--", color="blue", size=0.8)
+ gg.geom_smooth(
formula="y~x", method="lm", linetype="--", color="red", size=0.8, se=False
)
+ gg.scale_x_continuous(expand=(0, 0, 0.02, 0))
+ gg.scale_y_continuous(expand=(0, 0, 0.02, 0), limits=(0, 3100))
+ gg.labs(x="observed final counts", y="MAP predicted final counts")
)
/usr/local/Caskroom/miniconda/base/envs/speclet/lib/python3.9/site-packages/plotnine/layer.py:401: PlotnineWarning: geom_smooth : Removed 2 rows containing missing values.
<ggplot: (355207129)>
(
gg.ggplot(plt_df, gg.aes(x="counts_final", y="ppc_avg"))
+ gg.geom_point(size=0.2, alpha=0.5)
+ gg.geom_abline(slope=1, intercept=0, linetype="--", color="blue", size=0.8)
+ gg.geom_smooth(
formula="y~x", method="lm", linetype="--", color="red", size=0.8, se=False
)
+ gg.scale_x_continuous(expand=(0, 0), limits=(0, 1000))
+ gg.scale_y_continuous(expand=(0, 0), limits=(0, 1000))
+ gg.coord_equal()
+ gg.labs(x="observed final counts", y="MAP predicted final counts")
)
/usr/local/Caskroom/miniconda/base/envs/speclet/lib/python3.9/site-packages/plotnine/layer.py:401: PlotnineWarning: geom_point : Removed 372 rows containing missing values.
<ggplot: (354564106)>
notebook_toc = time()
print(f"execution time: {(notebook_toc - notebook_tic) / 60:.2f} minutes")
execution time: 5.52 minutes
%load_ext watermark
%watermark -d -u -v -iv -b -h -m
Last updated: 2022-01-26
Python implementation: CPython
Python version : 3.9.9
IPython version : 8.0.0
Compiler : Clang 11.1.0
OS : Darwin
Release : 21.2.0
Machine : x86_64
Processor : i386
CPU cores : 4
Architecture: 64bit
Hostname: JHCookMac
Git branch: nb-model
arviz : 0.11.4
pandas : 1.3.5
seaborn : 0.11.2
speclet : 0.0.9000
janitor : 0.22.0
numpy : 1.22.0
matplotlib: 3.5.1
plotnine : 0.8.0