[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ECF8W2SYCGRCX2RVK8B5CJ":3,"skill-same:01M7ECF8W2SYCGRCX2RVK8B5CJ":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":14,"repositoryHtmlUrl":33,"repositoryHomepageUrl":33,"ownerHtmlUrl":34,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":35,"install":36,"resources":49},"01M7ECF8W2SYCGRCX2RVK8B5CJ","bio-crispr-screens-bagel-essentiality",null,"Identifies essential genes from CRISPR-Cas9 fitness screens using BAGEL2 (Kim & Hart 2021 Genome Med), a Bayesian classifier scoring per-gene Bayes Factors via log-likelihood ratios over per-sgRNA fold changes, calibrated against CEGv2 core-essentials (Hart 2017 G3, ~684 genes) and NEGv1 non-essentials (Hart 2014, ~927 genes). Covers the fc + bf + pr workflow, the linear-extrapolation improvement over BAGEL1 truncation, multi-target off-target correction, tumor-suppressor sensitivity (BAGEL2 detects enrichment), and BF calibration (BF >6 ≈ 90% posterior per Hart 2017; ~5% FDR by BAGEL convention). Use when classifying essential vs non-essential genes, calibrating BAGEL2 thresholds against PR curves, identifying tumor suppressors alongside essentials, comparing BAGEL2 hits to MAGeCK \u002F drugZ, or generating publication-quality essentiality calls.","Mr-Nobody-Anonymous\u002FAll-skills","Mr-Nobody-Anonymous","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184253119?v=4","01M7AEXFJHKTYQW5R0ZCQQTWFV","anonymous","01M7C00M3GQR4QKP9GZA42GFAK",0,"MIT","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-crispr-screens-bagel-essentiality\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: bio-crispr-screens-bagel-essentiality\ndescription: Identifies essential genes from CRISPR-Cas9 fitness screens using BAGEL2 (Kim & Hart 2021 Genome Med), a Bayesian classifier scoring per-gene Bayes Factors via log-likelihood ratios over per-sgRNA fold changes, calibrated against CEGv2 core-essentials (Hart 2017 G3, ~684 genes) and NEGv1 non-essentials (Hart 2014, ~927 genes). Covers the fc + bf + pr workflow, the linear-extrapolation improvement over BAGEL1 truncation, multi-target off-target correction, tumor-suppressor sensitivity (BAGEL2 detects enrichment), and BF calibration (BF >6 ≈ 90% posterior per Hart 2017; ~5% FDR by BAGEL convention). Use when classifying essential vs non-essential genes, calibrating BAGEL2 thresholds against PR curves, identifying tumor suppressors alongside essentials, comparing BAGEL2 hits to MAGeCK \u002F drugZ, or generating publication-quality essentiality calls.\ntool_type: cli\nprimary_tool: BAGEL2\nsource: \"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills\"\nsource_repository: \"GPTomics\u002FbioSkills\"\nsource_path: \"crispr-screens\u002Fbagel-essentiality\u002FSKILL.md\"\nlicense: \"MIT\"\nimported_at: \"2026-09-20\"\n---\n\n## Version Compatibility\n\nReference examples tested with: BAGEL2 2.0 (hart-lab\u002Fbagel, build 115), pandas 2.2+, numpy 1.26+, scipy 1.12+, matplotlib 3.8+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `BAGEL.py fc --help`; `BAGEL.py bf --help`; `BAGEL.py pr --help`\n- Python: BAGEL2 is distributed via `git clone` (no canonical PyPI release); confirm `BAGEL.py version` after checkout.\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.\n\n## BAGEL2 Essentiality Analysis\n\n**\"Identify essential genes from my CRISPR fitness screen using BAGEL2\"** -> Compute per-sgRNA fold changes from counts, derive per-gene log-likelihood ratios against reference essential and non-essential gene sets, sum to Bayes Factor, and apply BF threshold calibrated by precision-recall against the reference.\n\n- CLI: `BAGEL.py fc` to compute fold changes\n- CLI: `BAGEL.py bf` to compute Bayes Factors\n- CLI: `BAGEL.py pr` for precision-recall curves\n- Reference sets: CEGv2 (essentials) and NEGv1 (non-essentials); both at https:\u002F\u002Fgithub.com\u002Fhart-lab\u002Fbagel\n\n## The BAGEL2 Bayesian Framework (under the hood)\n\n**Why this matters for postdoc-level use:** BAGEL2 uses a Bayes-factor classifier trained on known essential and non-essential genes. The chain:\n\n1. For each sgRNA, compute log-fold-change (LFC) treatment vs control.\n2. For each gene, look up per-sgRNA LFCs.\n3. For each sgRNA, compute the log-likelihood ratio: `log( P(LFC | gene is essential) \u002F P(LFC | gene is non-essential) )`. The numerator and denominator are KDEs (kernel density estimates) of LFC distributions from CEGv2 and NEGv1 reference sgRNAs.\n4. Sum per-gene log-likelihood ratios across all sgRNAs targeting the gene -> per-gene Bayes Factor.\n5. Resampling for the confidence interval (default: 10-fold cross-validation; `-b` switches to bootstrapping with `-NB`, default 1000); BF >6 corresponds to ~90% posterior probability (Hart 2017 G3); ~5% FDR by BAGEL convention.\n\n**Critical BAGEL2 improvements over BAGEL1:**\n\n- **Linear extrapolation**: BAGEL1 truncated the LLR at the edges of its KDE; BAGEL2 fits a linear regression in the stable region and extrapolates, giving wider dynamic range. This recovers tumor suppressors (highly positive LFC) that BAGEL1 missed.\n- **Multi-target correction**: For sgRNAs targeting multiple genomic loci (off-targets), BAGEL2 discards them and regresses out their BF contribution, but only when `-m\u002F--filter-multi-target` is given together with `--align-info`. The original BAGEL counted off-target hits as essentiality signal.\n- **Tumor suppressor sensitivity**: BAGEL2 correctly identifies positive selection (enrichment) genes -- not possible in BAGEL1.\n\n## Calibration to CEGv2 \u002F NEGv1\n\n**Why these reference sets matter:** BAGEL2's discriminative power depends on KDEs of LFCs from known essential vs known non-essential genes. CEGv2 (Hart 2017) is 684 core essential genes shared across cell lines; NEGv1 (Hart 2014) is 927 non-essential genes verified across multiple screens. These act as positive and negative controls within every screen.\n\nReference set integrity:\n- CEGv2: pan-cancer essentials -- common dropouts across most cancer cell lines\n- NEGv1: confidently non-essential -- genes without expression or genes with verified neutral status\n\n**Critical pitfall:** Using a custom essentiality reference (e.g., a single-cell-line CRISPR screen) instead of CEGv2 biases the BAGEL2 model toward that line's specific biology. Always use the standardized references unless there is a specific reason for custom training.\n\n## Compute Per-Sample Fold Changes\n\n**Goal:** Generate per-sgRNA fold-change matrix as input for Bayes-factor calculation.\n\n**Approach:** Take normalized counts, compute log-fold-change vs a control (Day 0 or plasmid baseline) per sgRNA.\n\n```bash\n# BAGEL2 installation: distributed via git clone (no canonical PyPI release).\ngit clone https:\u002F\u002Fgithub.com\u002Fhart-lab\u002Fbagel\ncd bagel\n\n# Inputs:\n# counts.txt: tab-separated with columns: sgRNA, GENE, Sample1, Sample2, ...\n# Control column(s): typically Day 0 or plasmid sample(s)\n# Treatment column(s): screen endpoint\n\nBAGEL.py fc \\\n    -i counts.txt \\\n    -o foldchange \\                        # NOTE: -o is a LABEL for fc; writes foldchange.foldchange\n    -c Plasmid \\                           # control sample (or Day 0)\n    --min-reads 30                         # default is 0; 30 is a common convention\n# Output: foldchange.foldchange (per-sgRNA LFCs) and foldchange.normed_readcount\n```\n\n## Compute Bayes Factors\n\n**Goal:** Score per-gene essentiality as a Bayes Factor.\n\n**Approach:** Run `BAGEL.py bf` with the fold-change matrix and reference gene sets. Resampling defaults to 10-fold cross-validation; add `-b -NB N` to bootstrap instead.\n\n```bash\nBAGEL.py bf \\\n    -i foldchange.foldchange \\\n    -o bayes_factor.txt \\\n    -e CEGv2.txt \\                         # essentials reference (CEGv2)\n    -n NEGv1.txt \\                          # non-essentials reference\n    -c Sample1,Sample2,Sample3 \\            # treatment samples to score\n    -b -NB 1000                            # opt into bootstrapping (default is 10-fold cross-validation)\n# Output: bayes_factor.txt - per-gene Bayes Factor + CI\n```\n\n**Output columns:**\n\n| Column | Meaning |\n|--------|---------|\n| `GENE` | Gene symbol |\n| `BF` | Per-gene Bayes Factor (log-likelihood ratio summed across sgRNAs) |\n| `STD` | Standard deviation across the 10 cross-validation folds (or bootstrap iterations with `-b`) |\n| `NumObs` | Number of sgRNAs contributing |\n\n**Interpretation rule:** BF >6 corresponds to ~90% posterior probability of essentiality against CEGv2 (Hart 2017; FDR ≤3% in that calibration, with ~5% a looser BAGEL convention); higher BF = stronger evidence the gene is essential. BAGEL2 also reports negative BFs which can indicate tumor suppressors (positive selection).\n\n## Precision-Recall Curve\n\n**Goal:** Empirically select BF threshold for a given precision\u002Frecall tradeoff.\n\n**Approach:** Run `BAGEL.py pr` to compute precision and recall at every BF level against CEGv2; pick the BF that gives desired precision.\n\n```bash\nBAGEL.py pr \\\n    -i bayes_factor.txt \\\n    -o precision_recall.txt \\\n    -e CEGv2.txt \\\n    -n NEGv1.txt\n# Output: precision_recall.txt - precision\u002Frecall at each BF threshold\n```\n\n**Practical BF ladder (regenerate precision and recall per screen with `BAGEL.py pr`):**\n\n| BF threshold | Use case |\n|--------------|----------|\n| 0 | Exploratory; highest recall |\n| 6 | Standard call (~90% posterior, Hart 2017) |\n| 12 | High-confidence |\n| 30 | Ultra-stringent; near-certain essentials |\n\n**Pick threshold based on application:** For exploratory hit calling, BF >0 with low precision is acceptable; for clinical-grade essentiality calls, BF >12 or higher.\n\n## Interpret BAGEL2 Results\n\n**Goal:** Stratify genes into essential, non-essential, and tumor-suppressor categories.\n\n**Approach:** Apply BF threshold to classify; flag negative BF as candidate tumor suppressors.\n\n```python\nimport pandas as pd\n\ndef interpret_bagel(bf_path, bf_essential=6, bf_tumor_suppressor=-6):\n    '''Classify genes from BAGEL2 BF output.'''\n    df = pd.read_csv(bf_path, sep='\\t')\n    df['call'] = 'neutral'\n    df.loc[df['BF'] > bf_essential, 'call'] = 'essential'\n    df.loc[df['BF'] \u003C bf_tumor_suppressor, 'call'] = 'tumor_suppressor'\n    return df.sort_values('BF', ascending=False)\n```\n\n**Tumor suppressor identification:** Genes with significantly negative BF (e.g., \u003C-6) are enriched in the screen, indicating fitness advantage from their loss. This is biologically distinct from \"non-essential\" and may indicate tumor-suppressor function. BAGEL1 could not detect this; BAGEL2's linear extrapolation enables it.\n\n## Bayesian Reasoning Per Sgrna\n\n**Why this matters:** BAGEL2 computes per-sgRNA contributions; a gene with 4 sgRNAs each contributing +5 to BF gets +20 total. A gene with 3 sgRNAs contributing +5 and 1 sgRNA contributing -3 (off-target or low-efficacy) gets +12 net.\n\n```python\n# Per-sgRNA contributions for diagnosis\n# Output table: each sgRNA's LLR contribution to gene-level BF\n# Useful for identifying low-efficacy guides\n```\n\n**Critical:** When per-sgRNA contributions are very heterogeneous (one sgRNA dominates BF), the gene is \"guide-of-one\"; verify with JACKS efficiency analysis or apply the second-best-sgRNA rule from [[hit-calling]].\n\n## Comparing BAGEL2, MAGeCK, drugZ\n\n| Property | BAGEL2 | MAGeCK | drugZ |\n|----------|--------|--------|-------|\n| Statistical framework | Bayes factor with reference sets | NB GLM | Bidirectional Z-score |\n| Calibrated against | CEGv2 \u002F NEGv1 | Internal null | Vehicle distribution |\n| Tumor suppressor detection | YES | Limited (RRA positive-selection score) | YES |\n| Best for | Essentiality classification | General hit calling | Chemogenomic drug screens |\n| Output | Bayes factor + CI | FDR + LFC | Z-score + FDR per direction |\n| Hit threshold | BF >6 | FDR \u003C0.05 | FDR \u003C0.05 |\n| Library calibration | Indirect (reference set) | None | None |\n\n**Reconciliation:** BF >6 ≈ 90% posterior probability (Hart 2017 G3); commonly treated as roughly MAGeCK FDR 0.05 by convention. BAGEL2 hits absent from MAGeCK suggest weak signal that BAGEL2's reference anchoring detects but MAGeCK's null-based test misses; verify by inspecting per-sgRNA contributions.\n\n## Failure Modes\n\n### BAGEL2 returns no hits despite known essentials\n\n**Trigger:** Wrong reference gene set file; CEGv2 or NEGv1 file may have wrong format or be missing genes.\n**Mechanism:** BAGEL2 trains KDEs on the reference; if references are not representative, KDE separation is poor and no gene has BF >6.\n**Symptom:** Median BF near zero; no genes >6 even at low FDR.\n**Fix:** Re-download CEGv2 \u002F NEGv1 from https:\u002F\u002Fgithub.com\u002Fhart-lab\u002Fbagel. Verify gene symbols match the screen's annotation.\n\n### BAGEL2 calls negative-LFC genes \"tumor suppressors\"\n\n**Trigger:** Heavy dropout screen where many genes drop out; the dropout signal is captured as positive BF but the *enriched* genes (negative BF) are noise.\n**Mechanism:** BAGEL2's symmetric distribution treats deeply enriched genes as significant; in a dropout-only screen, the enrichment signal is purely noise.\n**Symptom:** Many genes with negative BF; these don't validate as tumor suppressors.\n**Fix:** Restrict tumor-suppressor calling to screens specifically expecting enrichment (e.g., drug-resistance, GoF screens); for dropout screens, only interpret positive BF.\n\n### Bootstrap CI is wide; BF estimates unstable\n\n**Trigger:** Per-gene number of sgRNAs too low (e.g., \u003C4 in some libraries).\n**Mechanism:** Bootstrap of LLR over very few sgRNAs creates wide CI.\n**Symptom:** STD column larger than BF; many genes have CI spanning zero.\n**Fix:** Use a library with at least 4-6 sgRNAs\u002Fgene; or switch to bootstrapping (`-b -NB 5000`); or filter out genes with \u003C3 sgRNAs.\n\n### Low BF for known essential despite high LFC\n\n**Trigger:** One sgRNA per gene is contributing very low LLR (off-target or low-efficacy).\n**Mechanism:** BAGEL2 sums LLR; one weak guide drags total down.\n**Symptom:** Known essential like RPS3 has BF \u003C6 despite 3 of 4 guides showing -5 LFC.\n**Fix:** Inspect per-sgRNA LLR; identify the dragging guide; verify whether to exclude or to use JACKS for efficacy-aware analysis.\n\n### Non-cancer cell-line screen with custom essentials\n\n**Trigger:** Human embryonic kidney HEK293T or iPSC-derived neurons where standard essentials may not be essential.\n**Mechanism:** CEGv2 is calibrated for cancer cell lines; some essentials in tumor cells are not essential in iPSC.\n**Symptom:** PR curve against CEGv2 shows poor separation; many CEGv2 essentials don't drop out.\n**Fix:** Use a cell-type-specific essentialome derived for the relevant lineage; or use MAGeCK \u002F Chronos which doesn't depend on reference sets.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F Rationale |\n|-----------|-------|--------------------|\n| Standard essentiality call | BF >6 | Hart 2017: BF>=6 ~ 90% posterior |\n| Stricter essentiality call | BF >12 | BAGEL convention; regenerate precision\u002Frecall per screen with `BAGEL.py pr` |\n| Ultra-stringent call | BF >30 | BAGEL convention |\n| BF for tumor-suppressor candidate | \u003C-6 | Empirical; verify with orthogonal screen |\n| Resampling | 10-fold cross-validation (default); `-b -NB 1000` to bootstrap | BAGEL2 default |\n| Min reads per sgRNA in control | 30 | Convention; the BAGEL2 default is 0 |\n| Min sgRNAs per gene for stable BF | 4-6 | Wider with library convention |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| No hits despite essentials present | Wrong reference set | Re-verify CEGv2 \u002F NEGv1 files |\n| Wide resampling CI | Too few sgRNAs\u002Fgene | Increase library coverage; bootstrap with more iterations |\n| Negative BF for known essentials | Confounding factor (e.g., CN amplification) | Pre-correct with CRISPRcleanR \u002F Chronos |\n| Tumor suppressor calls don't validate | Pure dropout screen; enrichment is noise | Restrict tumor suppressor calls to expected design |\n| Per-sgRNA LLR dominated by one guide | Outlier or off-target | Apply second-best-sgRNA rule |\n\n## References\n\n- Kim E & Hart T. 2021. *Genome Medicine* 13:2. BAGEL2 algorithm and improvements.\n- Hart T & Moffat J. 2016. *BMC Bioinformatics* 17:164. BAGEL Bayes factor framework.\n- Hart T et al. 2017. *G3* 7:2719. CEGv2 core-essential reference set; BF posterior calibration.\n- Hart T et al. 2014. *Mol Syst Biol* 10:733. Gold-standard essential and non-essential reference sets; source of NEGv1.\n- Pacini C et al. 2021. *Nat Commun* 12:1661. Integrated cross-study dependencies; reference essentiality benchmarks.\n\n## Related Skills\n\n- crispr-screens\u002Fmageck-analysis - MAGeCK RRA\u002FMLE alternative\n- crispr-screens\u002Fjacks-analysis - JACKS for per-guide efficacy\n- crispr-screens\u002Fdrugz-chemogenomic - drugZ for drug screens\n- crispr-screens\u002Fhit-calling - Cross-method decision tree\n- crispr-screens\u002Fscreen-qc - Pre-BAGEL QC including CEGv2 PR-AUC\n- crispr-screens\u002Flibrary-design - 4-6 sgRNAs\u002Fgene library standard\n- crispr-screens\u002Fcopy-number-correction - Pre-correction for cancer-line screens\n- pathway-analysis\u002Fgo-enrichment - Downstream functional analysis\n","## Version Compatibility\n\nReference examples tested with: BAGEL2 2.0 (hart-lab\u002Fbagel, build 115), pandas 2.2+, numpy 1.26+, scipy 1.12+, matplotlib 3.8+.\n\nBefore using code patterns, verify installed versions match. If versions differ:\n- CLI: `BAGEL.py fc --help`; `BAGEL.py bf --help`; `BAGEL.py pr --help`\n- Python: BAGEL2 is distributed via `git clone` (no canonical PyPI release); confirm `BAGEL.py version` after checkout.\n\nIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.\n\n## BAGEL2 Essentiality Analysis\n\n**\"Identify essential genes from my CRISPR fitness screen using BAGEL2\"** -> Compute per-sgRNA fold changes from counts, derive per-gene log-likelihood ratios against reference essential and non-essential gene sets, sum to Bayes Factor, and apply BF threshold calibrated by precision-recall against the reference.\n\n- CLI: `BAGEL.py fc` to compute fold changes\n- CLI: `BAGEL.py bf` to compute Bayes Factors\n- CLI: `BAGEL.py pr` for precision-recall curves\n- Reference sets: CEGv2 (essentials) and NEGv1 (non-essentials); both at https:\u002F\u002Fgithub.com\u002Fhart-lab\u002Fbagel\n\n## The BAGEL2 Bayesian Framework (under the hood)\n\n**Why this matters for postdoc-level use:** BAGEL2 uses a Bayes-factor classifier trained on known essential and non-essential genes. The chain:\n\n1. For each sgRNA, compute log-fold-change (LFC) treatment vs control.\n2. For each gene, look up per-sgRNA LFCs.\n3. For each sgRNA, compute the log-likelihood ratio: `log( P(LFC | gene is essential) \u002F P(LFC | gene is non-essential) )`. The numerator and denominator are KDEs (kernel density estimates) of LFC distributions from CEGv2 and NEGv1 reference sgRNAs.\n4. Sum per-gene log-likelihood ratios across all sgRNAs targeting the gene -> per-gene Bayes Factor.\n5. Resampling for the confidence interval (default: 10-fold cross-validation; `-b` switches to bootstrapping with `-NB`, default 1000); BF >6 corresponds to ~90% posterior probability (Hart 2017 G3); ~5% FDR by BAGEL convention.\n\n**Critical BAGEL2 improvements over BAGEL1:**\n\n- **Linear extrapolation**: BAGEL1 truncated the LLR at the edges of its KDE; BAGEL2 fits a linear regression in the stable region and extrapolates, giving wider dynamic range. This recovers tumor suppressors (highly positive LFC) that BAGEL1 missed.\n- **Multi-target correction**: For sgRNAs targeting multiple genomic loci (off-targets), BAGEL2 discards them and regresses out their BF contribution, but only when `-m\u002F--filter-multi-target` is given together with `--align-info`. The original BAGEL counted off-target hits as essentiality signal.\n- **Tumor suppressor sensitivity**: BAGEL2 correctly identifies positive selection (enrichment) genes -- not possible in BAGEL1.\n\n## Calibration to CEGv2 \u002F NEGv1\n\n**Why these reference sets matter:** BAGEL2's discriminative power depends on KDEs of LFCs from known essential vs known non-essential genes. CEGv2 (Hart 2017) is 684 core essential genes shared across cell lines; NEGv1 (Hart 2014) is 927 non-essential genes verified across multiple screens. These act as positive and negative controls within every screen.\n\nReference set integrity:\n- CEGv2: pan-cancer essentials -- common dropouts across most cancer cell lines\n- NEGv1: confidently non-essential -- genes without expression or genes with verified neutral status\n\n**Critical pitfall:** Using a custom essentiality reference (e.g., a single-cell-line CRISPR screen) instead of CEGv2 biases the BAGEL2 model toward that line's specific biology. Always use the standardized references unless there is a specific reason for custom training.\n\n## Compute Per-Sample Fold Changes\n\n**Goal:** Generate per-sgRNA fold-change matrix as input for Bayes-factor calculation.\n\n**Approach:** Take normalized counts, compute log-fold-change vs a control (Day 0 or plasmid baseline) per sgRNA.\n\n```bash\n# BAGEL2 installation: distributed via git clone (no canonical PyPI release).\ngit clone https:\u002F\u002Fgithub.com\u002Fhart-lab\u002Fbagel\ncd bagel\n\n# Inputs:\n# counts.txt: tab-separated with columns: sgRNA, GENE, Sample1, Sample2, ...\n# Control column(s): typically Day 0 or plasmid sample(s)\n# Treatment column(s): screen endpoint\n\nBAGEL.py fc \\\n    -i counts.txt \\\n    -o foldchange \\                        # NOTE: -o is a LABEL for fc; writes foldchange.foldchange\n    -c Plasmid \\                           # control sample (or Day 0)\n    --min-reads 30                         # default is 0; 30 is a common convention\n# Output: foldchange.foldchange (per-sgRNA LFCs) and foldchange.normed_readcount\n```\n\n## Compute Bayes Factors\n\n**Goal:** Score per-gene essentiality as a Bayes Factor.\n\n**Approach:** Run `BAGEL.py bf` with the fold-change matrix and reference gene sets. Resampling defaults to 10-fold cross-validation; add `-b -NB N` to bootstrap instead.\n\n```bash\nBAGEL.py bf \\\n    -i foldchange.foldchange \\\n    -o bayes_factor.txt \\\n    -e CEGv2.txt \\                         # essentials reference (CEGv2)\n    -n NEGv1.txt \\                          # non-essentials reference\n    -c Sample1,Sample2,Sample3 \\            # treatment samples to score\n    -b -NB 1000                            # opt into bootstrapping (default is 10-fold cross-validation)\n# Output: bayes_factor.txt - per-gene Bayes Factor + CI\n```\n\n**Output columns:**\n\n| Column | Meaning |\n|--------|---------|\n| `GENE` | Gene symbol |\n| `BF` | Per-gene Bayes Factor (log-likelihood ratio summed across sgRNAs) |\n| `STD` | Standard deviation across the 10 cross-validation folds (or bootstrap iterations with `-b`) |\n| `NumObs` | Number of sgRNAs contributing |\n\n**Interpretation rule:** BF >6 corresponds to ~90% posterior probability of essentiality against CEGv2 (Hart 2017; FDR ≤3% in that calibration, with ~5% a looser BAGEL convention); higher BF = stronger evidence the gene is essential. BAGEL2 also reports negative BFs which can indicate tumor suppressors (positive selection).\n\n## Precision-Recall Curve\n\n**Goal:** Empirically select BF threshold for a given precision\u002Frecall tradeoff.\n\n**Approach:** Run `BAGEL.py pr` to compute precision and recall at every BF level against CEGv2; pick the BF that gives desired precision.\n\n```bash\nBAGEL.py pr \\\n    -i bayes_factor.txt \\\n    -o precision_recall.txt \\\n    -e CEGv2.txt \\\n    -n NEGv1.txt\n# Output: precision_recall.txt - precision\u002Frecall at each BF threshold\n```\n\n**Practical BF ladder (regenerate precision and recall per screen with `BAGEL.py pr`):**\n\n| BF threshold | Use case |\n|--------------|----------|\n| 0 | Exploratory; highest recall |\n| 6 | Standard call (~90% posterior, Hart 2017) |\n| 12 | High-confidence |\n| 30 | Ultra-stringent; near-certain essentials |\n\n**Pick threshold based on application:** For exploratory hit calling, BF >0 with low precision is acceptable; for clinical-grade essentiality calls, BF >12 or higher.\n\n## Interpret BAGEL2 Results\n\n**Goal:** Stratify genes into essential, non-essential, and tumor-suppressor categories.\n\n**Approach:** Apply BF threshold to classify; flag negative BF as candidate tumor suppressors.\n\n```python\nimport pandas as pd\n\ndef interpret_bagel(bf_path, bf_essential=6, bf_tumor_suppressor=-6):\n    '''Classify genes from BAGEL2 BF output.'''\n    df = pd.read_csv(bf_path, sep='\\t')\n    df['call'] = 'neutral'\n    df.loc[df['BF'] > bf_essential, 'call'] = 'essential'\n    df.loc[df['BF'] \u003C bf_tumor_suppressor, 'call'] = 'tumor_suppressor'\n    return df.sort_values('BF', ascending=False)\n```\n\n**Tumor suppressor identification:** Genes with significantly negative BF (e.g., \u003C-6) are enriched in the screen, indicating fitness advantage from their loss. This is biologically distinct from \"non-essential\" and may indicate tumor-suppressor function. BAGEL1 could not detect this; BAGEL2's linear extrapolation enables it.\n\n## Bayesian Reasoning Per Sgrna\n\n**Why this matters:** BAGEL2 computes per-sgRNA contributions; a gene with 4 sgRNAs each contributing +5 to BF gets +20 total. A gene with 3 sgRNAs contributing +5 and 1 sgRNA contributing -3 (off-target or low-efficacy) gets +12 net.\n\n```python\n# Per-sgRNA contributions for diagnosis\n# Output table: each sgRNA's LLR contribution to gene-level BF\n# Useful for identifying low-efficacy guides\n```\n\n**Critical:** When per-sgRNA contributions are very heterogeneous (one sgRNA dominates BF), the gene is \"guide-of-one\"; verify with JACKS efficiency analysis or apply the second-best-sgRNA rule from [[hit-calling]].\n\n## Comparing BAGEL2, MAGeCK, drugZ\n\n| Property | BAGEL2 | MAGeCK | drugZ |\n|----------|--------|--------|-------|\n| Statistical framework | Bayes factor with reference sets | NB GLM | Bidirectional Z-score |\n| Calibrated against | CEGv2 \u002F NEGv1 | Internal null | Vehicle distribution |\n| Tumor suppressor detection | YES | Limited (RRA positive-selection score) | YES |\n| Best for | Essentiality classification | General hit calling | Chemogenomic drug screens |\n| Output | Bayes factor + CI | FDR + LFC | Z-score + FDR per direction |\n| Hit threshold | BF >6 | FDR \u003C0.05 | FDR \u003C0.05 |\n| Library calibration | Indirect (reference set) | None | None |\n\n**Reconciliation:** BF >6 ≈ 90% posterior probability (Hart 2017 G3); commonly treated as roughly MAGeCK FDR 0.05 by convention. BAGEL2 hits absent from MAGeCK suggest weak signal that BAGEL2's reference anchoring detects but MAGeCK's null-based test misses; verify by inspecting per-sgRNA contributions.\n\n## Failure Modes\n\n### BAGEL2 returns no hits despite known essentials\n\n**Trigger:** Wrong reference gene set file; CEGv2 or NEGv1 file may have wrong format or be missing genes.\n**Mechanism:** BAGEL2 trains KDEs on the reference; if references are not representative, KDE separation is poor and no gene has BF >6.\n**Symptom:** Median BF near zero; no genes >6 even at low FDR.\n**Fix:** Re-download CEGv2 \u002F NEGv1 from https:\u002F\u002Fgithub.com\u002Fhart-lab\u002Fbagel. Verify gene symbols match the screen's annotation.\n\n### BAGEL2 calls negative-LFC genes \"tumor suppressors\"\n\n**Trigger:** Heavy dropout screen where many genes drop out; the dropout signal is captured as positive BF but the *enriched* genes (negative BF) are noise.\n**Mechanism:** BAGEL2's symmetric distribution treats deeply enriched genes as significant; in a dropout-only screen, the enrichment signal is purely noise.\n**Symptom:** Many genes with negative BF; these don't validate as tumor suppressors.\n**Fix:** Restrict tumor-suppressor calling to screens specifically expecting enrichment (e.g., drug-resistance, GoF screens); for dropout screens, only interpret positive BF.\n\n### Bootstrap CI is wide; BF estimates unstable\n\n**Trigger:** Per-gene number of sgRNAs too low (e.g., \u003C4 in some libraries).\n**Mechanism:** Bootstrap of LLR over very few sgRNAs creates wide CI.\n**Symptom:** STD column larger than BF; many genes have CI spanning zero.\n**Fix:** Use a library with at least 4-6 sgRNAs\u002Fgene; or switch to bootstrapping (`-b -NB 5000`); or filter out genes with \u003C3 sgRNAs.\n\n### Low BF for known essential despite high LFC\n\n**Trigger:** One sgRNA per gene is contributing very low LLR (off-target or low-efficacy).\n**Mechanism:** BAGEL2 sums LLR; one weak guide drags total down.\n**Symptom:** Known essential like RPS3 has BF \u003C6 despite 3 of 4 guides showing -5 LFC.\n**Fix:** Inspect per-sgRNA LLR; identify the dragging guide; verify whether to exclude or to use JACKS for efficacy-aware analysis.\n\n### Non-cancer cell-line screen with custom essentials\n\n**Trigger:** Human embryonic kidney HEK293T or iPSC-derived neurons where standard essentials may not be essential.\n**Mechanism:** CEGv2 is calibrated for cancer cell lines; some essentials in tumor cells are not essential in iPSC.\n**Symptom:** PR curve against CEGv2 shows poor separation; many CEGv2 essentials don't drop out.\n**Fix:** Use a cell-type-specific essentialome derived for the relevant lineage; or use MAGeCK \u002F Chronos which doesn't depend on reference sets.\n\n## Quantitative Thresholds\n\n| Threshold | Value | Source \u002F Rationale |\n|-----------|-------|--------------------|\n| Standard essentiality call | BF >6 | Hart 2017: BF>=6 ~ 90% posterior |\n| Stricter essentiality call | BF >12 | BAGEL convention; regenerate precision\u002Frecall per screen with `BAGEL.py pr` |\n| Ultra-stringent call | BF >30 | BAGEL convention |\n| BF for tumor-suppressor candidate | \u003C-6 | Empirical; verify with orthogonal screen |\n| Resampling | 10-fold cross-validation (default); `-b -NB 1000` to bootstrap | BAGEL2 default |\n| Min reads per sgRNA in control | 30 | Convention; the BAGEL2 default is 0 |\n| Min sgRNAs per gene for stable BF | 4-6 | Wider with library convention |\n\n## Common Errors\n\n| Error \u002F symptom | Cause | Solution |\n|-----------------|-------|----------|\n| No hits despite essentials present | Wrong reference set | Re-verify CEGv2 \u002F NEGv1 files |\n| Wide resampling CI | Too few sgRNAs\u002Fgene | Increase library coverage; bootstrap with more iterations |\n| Negative BF for known essentials | Confounding factor (e.g., CN amplification) | Pre-correct with CRISPRcleanR \u002F Chronos |\n| Tumor suppressor calls don't validate | Pure dropout screen; enrichment is noise | Restrict tumor suppressor calls to expected design |\n| Per-sgRNA LLR dominated by one guide | Outlier or off-target | Apply second-best-sgRNA rule |\n\n## References\n\n- Kim E & Hart T. 2021. *Genome Medicine* 13:2. BAGEL2 algorithm and improvements.\n- Hart T & Moffat J. 2016. *BMC Bioinformatics* 17:164. BAGEL Bayes factor framework.\n- Hart T et al. 2017. *G3* 7:2719. CEGv2 core-essential reference set; BF posterior calibration.\n- Hart T et al. 2014. *Mol Syst Biol* 10:733. Gold-standard essential and non-essential reference sets; source of NEGv1.\n- Pacini C et al. 2021. *Nat Commun* 12:1661. Integrated cross-study dependencies; reference essentiality benchmarks.\n\n## Related Skills\n\n- crispr-screens\u002Fmageck-analysis - MAGeCK RRA\u002FMLE alternative\n- crispr-screens\u002Fjacks-analysis - JACKS for per-guide efficacy\n- crispr-screens\u002Fdrugz-chemogenomic - drugZ for drug screens\n- crispr-screens\u002Fhit-calling - Cross-method decision tree\n- crispr-screens\u002Fscreen-qc - Pre-BAGEL QC including CEGv2 PR-AUC\n- crispr-screens\u002Flibrary-design - 4-6 sgRNAs\u002Fgene library standard\n- crispr-screens\u002Fcopy-number-correction - Pre-correction for cancer-line screens\n- pathway-analysis\u002Fgo-enrichment - Downstream functional analysis\n",{"name":5,"source":24,"license":15,"tool_type":25,"description":7,"imported_at":26,"source_path":27,"primary_tool":28,"source_repository":29},"https:\u002F\u002Fgithub.com\u002FGPTomics\u002FbioSkills","cli","2026-09-20","crispr-screens\u002Fbagel-essentiality\u002FSKILL.md","BAGEL2","GPTomics\u002FbioSkills","main","2d1750717747097b602acf30bd09a7cbd4b4c6ea","awesome_skills\u002Fbiology\u002Fbio-crispr-screens-bagel-essentiality","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous","2026-11-09 11:45:36",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-crispr-screens-bagel-essentiality",{"tool":42,"command":43},"bunx","bunx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-crispr-screens-bagel-essentiality",{"tool":45,"command":46},"pnpm","pnpm dlx skills add Mr-Nobody-Anonymous\u002FAll-skills --skill bio-crispr-screens-bagel-essentiality","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-crispr-screens-bagel-essentiality\u002FSKILL.md",true,[50,56],{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Frun_bagel2.sh","SCRIPT","脚本",2701,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-crispr-screens-bagel-essentiality\u002Fexamples\u002Frun_bagel2.sh",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"usage-guide.md","REFERENCE","参考文档",7602,"https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fbiology\u002Fbio-crispr-screens-bagel-essentiality\u002Fusage-guide.md",[63,71,78,85,92,99],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":70},"01M7FFFZPC2025JQQHPHDX154J","dei-assessment","Assess diversity, equity, and inclusion with metrics. TRIGGERS - Use when user needs help with dei-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-assessment\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":70},"01M7FFFWN8H4WA7A6Y398QKB6J","dei-action-plan","Create DEI action plans with goals and initiatives. TRIGGERS - Use when user needs help with dei-action-plan related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fdei-action-plan\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":70},"01M7FFFSHTM0QZRVZ2NRJTJ0PY","culture-fit-assessment","Design culture add assessment processes. TRIGGERS - Use when user needs help with culture-fit-assessment related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fculture-fit-assessment\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":70},"01M7FFFMA12RKEQA38KHJSXXPS","cowork-to-code-bridge","Use an already-installed, independently verified cowork-to-code bridge to run narrowly approved actions on the user's own macOS, Linux, or WSL2 machine through a local file queue.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcowork-to-code-bridge\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":70},"01M7FFFH1F6M8YRGW5V487GH1K","counter-offer-response","Draft counter-offer responses for retention. TRIGGERS - Use when user needs help with counter-offer-response related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcounter-offer-response\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":70},"01M7FFFDGEHV8Y7J9N40HZXW52","continuous-feedback-system","Design continuous feedback systems. TRIGGERS - Use when user needs help with continuous-feedback-system related tasks.","https:\u002F\u002Fgithub.com\u002FMr-Nobody-Anonymous\u002FAll-skills\u002Fblob\u002Fmain\u002Fawesome_skills\u002Fhr-people\u002Fcontinuous-feedback-system\u002FSKILL.md",[],[]]