Skip to content

Commit

Permalink
add negctrl as separate arg
Browse files Browse the repository at this point in the history
  • Loading branch information
jykr committed Mar 30, 2024
1 parent 1dc0593 commit fb92a65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
## Overview
`bean` supports end-to-end analysis of pooled sorting screens, with or without reporter.

<img src="imgs/dag_bean_v2.svg" alt="dag_bean_v2.svg" width="700"/>
<img src="imgs/dag_bean_v2.svg" alt="dag_bean_v2.svg" height="500"/>

`bean` subcommands include the following:
1. [`count`](https://pinellolab.github.io/crispr-bean/count.html), [`count-samples`](https://pinellolab.github.io/crispr-bean/count_samples.html): Base-editing-aware **mapping** of guide, optionally with reporter from `.fastq` files.
Expand All @@ -24,7 +24,7 @@
* Screen data is saved as *ReporterScreen* object in the pipeline.
BEAN stores mapped gRNA and allele counts in `ReporterScreen` object which is compatible with [AnnData](https://anndata.readthedocs.io/en/latest/index.html). See [Data Structure](#data-structure) section for more information.
## Installation
First install [PyT}orch](https://pytorch.org/get-started/).
First install [PyTorch](https://pytorch.org/get-started/).
Then download from PyPI:
```
pip install crispr-bean[model]
Expand Down
3 changes: 2 additions & 1 deletion bean/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def main(args):
f"Using {len(negctrl_idx)} negative control elements to adjust phenotypic effect sizes..."
)
ndata_negctrl = ndata[negctrl_idx]
param_history_dict["negctrl"], save_dict["negctrl"] = deepcopy(
param_history_dict_negctrl, save_dict["negctrl"] = deepcopy(
run_inference(
negctrl_model, negctrl_guide, ndata_negctrl, num_steps=args.n_iter
)
Expand All @@ -188,6 +188,7 @@ def main(args):
write_result_table(
target_info_df,
param_history_dict,
negctrl_params=param_history_dict_negctrl,
model_label=model_label,
prefix=f"{prefix}/",
suffix=args.result_suffix,
Expand Down
13 changes: 4 additions & 9 deletions bean/model/readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def write_result_table(
model_label: str,
prefix: str = "",
suffix: str = "",
negctrl_params=None,
write_fitted_eff: bool = True,
adjust_confidence_by_negative_control: bool = True,
adjust_confidence_negatives: np.ndarray = None,
Expand Down Expand Up @@ -100,17 +101,11 @@ def write_result_table(
)

fit_df = pd.DataFrame(param_dict)
if "negctrl" in param_hist_dict.keys():
if negctrl_params is not None:
print("Normalizing with common negative control distribution")
mu0 = param_hist_dict["negctrl"]["params"]["mu_loc"].detach().cpu().numpy()
mu0 = negctrl_params["params"]["mu_loc"].detach().cpu().numpy()
if sd_is_fitted:
sd0 = (
param_hist_dict["negctrl"]["params"]["sd_loc"]
.detach()
.exp()
.cpu()
.numpy()
)
sd0 = negctrl_params["params"]["sd_loc"].detach().exp().cpu().numpy()
else:
sd0 = 1.0
print(f"Fitted mu0={mu0}" + (f", sd0={sd0}." if sd_is_fitted else ""))
Expand Down

0 comments on commit fb92a65

Please sign in to comment.