コード例 #1
0
import matplotlib.patheffects as path_effects
import seaborn as sns
import bebi103.viz

import srep.viz
from srep.utils import load_FISH_by_promoter

# Set PBoC plotting style
srep.viz.plotting_style()
# %%
repo = Repo("./", search_parent_directories=True)
# repo_rootdir holds the absolute path to the top-level of our repo
repo_rootdir = repo.working_tree_dir

# Import sm-FISH data along with promoter information
df_unreg, df_energies, = load_FISH_by_promoter(("unreg", "energies"))
df_energies.sort_values('Energy (kT)', inplace=True)

# %%
# Group FISH data by promoters
df_group = df_unreg.groupby("experiment")

# Initialize dataframe to save mean expression and Fano factor
names = ["promoter", "mean", "var", "fano", "energy_kT"]
df_summary = pd.DataFrame([], columns=names)

# Loop through promoters computing mean expression and Fano
for prom, data in df_group:
    # Compute mean expression
    mean_m = data["mRNA_cell"].mean()
    # Compute variance
コード例 #2
0
import numpy as np
import pandas as pd

import cmdstanpy
import arviz as az

from bebi103.stan import disable_logging as be_quiet_stan
from bebi103.stan import check_all_diagnostics
from srep.utils import load_FISH_by_promoter

repo = Repo("./", search_parent_directories=True)
# repo_rootdir holds the absolute path to the top-level of our repo
repo_rootdir = repo.working_tree_dir

# first load data using module util
df_unreg, = load_FISH_by_promoter(("unreg", ))
# pull out one specific promoter for convenience for prior pred check & SBC
df_UV5 = df_unreg[df_unreg["experiment"] == "UV5"]

sm = cmdstanpy.CmdStanModel(
    stan_file=f"{repo_rootdir}/code/stan/constit_post_inf.stan",
    compile=True,
)

all_samples = {}
for gene in df_unreg['experiment'].unique():
    temp_df = df_unreg[df_unreg['experiment'] == gene]
    stan_data = dict(
        N=len(temp_df),
        mRNA_counts=temp_df["mRNA_cell"].values.astype(int),
        ppc=0  # if you produce ppc samples, the InferenceData obj is HUGE