Daily Archives: 2026年2月23日

Guide RNA Design with GuideFinder for the Toxin–Antitoxin Unit in Staphylococcus epidermidis HD46 (CP052959.1)

Part A|把你“125 的流程”迁移到 CP052959.1 的 step-by-step(中文)

0️⃣ 目录结构建议(最省事)

新建一个工作目录,例如:

HD46_GuideFinder/
  CP052959.1.gbk
  CP052959.1.fna
  extract_cds_from_gbk.py
  PreProcessing_HD46.R
  GuideFinder_HD46_base.R
  ScanOfftarget_HD46.R
  (可选) *.Rmd

你可以把你当时的 PreProcessing_125.R / GuideFinder_125_base.R / ScanOfftarget_125.R 复制一份改名,然后把里面所有 “125” 的文件名前缀改成 “HD46” 或 “CP052959.1”。


1️⃣ 从 GenBank 提取 CDS → 生成 HD46_CDS.fasta(Python + Biopython)

输入: CP052959.1.gbk 输出: HD46_CDS.fasta(每个 CDS 一条序列,header 用 locus_tag)

运行(示例):

python extract_cds_from_gbk.py \
  --gbk CP052959.1.gbk \
  --out HD46_CDS.fasta

检查输出里应该能看到类似:

  • >HJI06_09100 ...
  • >HJI06_09105 ...

这一步的目的:后面要把每条 CDS 用 BLAST 定位回整条基因组,得到统一的坐标表(尤其适配 draft genome / 多 contig 的情况;complete genome 也能这么跑,流程统一)。


2️⃣ Pre-processing:把 CDS BLAST 回基因组 → 生成 gene coordinate table

2.1 建 BLAST 数据库(GenomeDB)

用基因组 FASTA 建库(输入 CP052959.1.fna):

makeblastdb -in CP052959.1.fna -dbtype nucl -out GenomeDB_HD46

2.2 BLAST:CDS vs Genome

(你笔记里用的是 -task blastn,这里沿用;如果你 CDS 很短也可用 blastn-short

blastn -task blastn \
  -query HD46_CDS.fasta \
  -db GenomeDB_HD46 \
  -outfmt "6 qseqid sseqid sstart send sstrand length pident bitscore" \
  -max_target_seqs 1 \
  -perc_identity 95 \
  -out CDS_vs_genome_HD46.blast

2.3 生成坐标表

运行你改好的预处理脚本(对应你笔记里的 PreProcessing_125.R):

Rscript PreProcessing_HD46.R
# 或者
Rscript -e "rmarkdown::render('PreProcessing_HD46.Rmd')"

输出: HD46_gene_coordinates.tsv

这张表通常会包含每个基因(locus_tag)的:

  • contig/seqid(这里应该是 CP052959.1)
  • start/end
  • strand
  • (如果脚本计算了)promoter 区、TSS 近似位置、gene length 等

3️⃣ Guide 设计:跑 GuideFinder(或你简化版 GuideFinder-like 脚本)

你笔记里分成:

  • GuideFinder_125_base.R:做 PAM 扫描、GC/同聚物过滤、计算 dist_to_tss、写出待 BLAST 的 guides fasta
  • 然后再 ScanOfftarget_125.R:根据 BLAST 命中做 off-target 分层(off_n3/off_n5/off_refined)

我建议你按同样分法跑(更清晰、也更容易 debug)。

3.1(可选但很推荐)只做 TA 这两个基因:建 targets 列表

新建 TA_targets.txt

HJI06_09100
HJI06_09105

然后在 GuideFinder 脚本里加一个“只保留这两个基因”的过滤(如果你当时 125 是全基因组,这里就能显著加速)。

3.2 运行 base 设计脚本

Rscript GuideFinder_HD46_base.R

你期望它会做:

  1. 扫 NGG PAM、生成 20bp(或 20/21/22)候选
  2. GC / homopolymer / bad-seed / restriction-site 过滤
  3. 正确计算 dist_to_tss(你笔记里写这次修好了)
  4. 写出 BLASTguides.fasta 并跑 BLAST(或至少准备好 BLAST 输入)
  5. 产生一个“preoff”的 guides 表(比如 HD46_guides_preoff.tsv

3.3 Off-target 扫描与分层输出

Rscript ScanOfftarget_HD46.R

它会把结果放进类似这样的目录结构(沿用你笔记习惯):

scan_results/
  off_n3/
    guides_all.tsv
    guides_top5.tsv
  off_n5/
    guides_all.tsv
    guides_top5.tsv
  off_refined/
    guides_all.tsv
    guides_top5.tsv

Part B|你要用 off_refined 的“选择逻辑”怎么理解(中文)

你笔记里这段非常关键,我用更直白的方式总结一下(保持你原有意图):

1) 现在脚本里的 n_hits 统计是什么?

  • 目前 n_hits 是“guide 的 BLAST 命中次数”,不区分 promoter / CDS / intergenic
  • 不检查命中位点是否旁边有 NGG PAM
  • 因此它会偏“保守”(宁可把一些其实没有 PAM 的匹配也算作潜在风险)

2) off_refined 策略核心是什么?

你笔记里这句说得很到位:

  • off_refined 已经在 BLAST level 上把真正危险的“第二个完美 20/20 命中”踢掉了
  • 剩下的 guide 通常是“1 个 on-target + 一堆残缺 off-target”(比如 mismatch 多、seed 不完整等),更接近你理想的“只在目标位点真正起作用”

3) 你提出的“只把有 PAM 的命中算 off-target”是对的

从 dCas9/Cas9 生物学机制看:

  • 没有合适 PAM(这里是 NGG),多数情况下不构成真实 off-target 风险
  • 你可以在后续加一层:对每个 BLAST 命中回到 genome 取邻域序列,检查是否存在 NGG,再把“有 PAM 的命中”纳入 n_hits

但就你现在说的用途(实际做 CRISPRi 设计),off_refined 已经是很实用的默认档位


Part C|给 Xxxxxx 的邮件草稿(你直接复制粘贴就能发)

你要“写一封邮件给 Xxxxxx,说原理上可行,并做了一个 probe-test;最佳匹配 Enterobacter intestinihominis…;用 off_refined;解释结果;并附算法细节;附件 guides_all.tsv / guides_top5.tsv”。 我下面给英文邮件(更像工作邮件)。你把方括号里的占位符替换成你的具体数字/文件名即可。

Hi Xxxxxx,

In principle the guide design pipeline is working end-to-end now. I ran a small probe-test on Patricia’s previously assembled complete isolate “125” genome input.

Quick taxonomy sanity check (PATRIC/closest match): Best match: Enterobacter intestinihominis (taxid = 3133180; species; lineage: Bacteria → Pseudomonadati/Pseudomonadota → Gammaproteobacteria → Enterobacterales → Enterobacteriaceae).

What the pipeline produced (strategy: off_refined):

  • It completes the sequence-level filters (GC + homopolymers) and computes dist_to_tss correctly.
  • It then runs a BLAST-based off-target scan and generates the final guide tables.
  • Attached are:

    • guides_all.tsv (all guides passing filters)
    • guides_top5.tsv (up to 5 best guides per gene)

Summary of the results (off_refined):

  • Total genes evaluated: [N_genes]
  • Genes with ≥1 guide: [N_with_guides] ([pct]% coverage)
  • Genes without guides: [N_without_guides]
  • Total guides retained in guides_all.tsv: [N_guides_all]
  • Median guides per gene (genes with guides): [median_guides_per_gene] (These numbers are from the attached tables.)

Algorithm details (off_refined, in plain terms):

  1. Candidate generation: scan for NGG PAM sites and create guide candidates (20 bp; optionally 21/22 bp depending on settings).
  2. Primary filters: remove candidates failing GC threshold and basic sequence-quality rules (e.g., long homopolymer runs; optional “bad-seed” motifs / restriction sites).
  3. TSS proximity scoring: compute dist_to_tss and prioritize guides closer to the inferred transcription start region for CRISPRi.
  4. Off-target screening via BLAST: align guide (or seed region, depending on mode) against the whole genome.
  5. off_refined rule: discard any guide that shows a second perfect full-length match elsewhere in the genome (i.e., another 20/20 hit besides the intended on-target). The remaining guides typically have 1 on-target hit plus only weak/partial off-target hits.

Note: in the current implementation, n_hits is counted genomewide from BLAST hits (no promoter/CDS distinction and no explicit PAM check at hit sites), which is conservative. If needed, we can further refine by counting only BLAST hits that also have an appropriate NGG PAM in the correct context.

Best, Yyyy


如果你接下来要把这个流程用到你真正关心的 HD46(CP052959.1)TA 单元,我建议你按上面 Part A 跑完后,把 scan_results/off_refined/guides_top5.tsvHJI06_09100HJI06_09105 的行贴出来,我可以再帮你快速做“最终挑哪 1 条单 guide / 哪一对 paired guides 最适合用来一起 knockdown 这个 TA 单元”的二次筛选。

GuideFinder-Based gRNA Design for CRISPRi Knockdown of a Toxin–Antitoxin Operon in S. epidermidis HD46 (CP052959.1)

两个基因的 locus_tag 分别是:

  • 毒素(toxin)HJI06_09100,坐标 complement(1889026..1889421)
  • 抗毒素(antitoxin)HJI06_09105,坐标 complement(1889421..1889651)

这里有一个非常重要的更正:它们在 complement,也就是 负链(minus strand)。 因此“操纵子上游/启动子在前端”对应的方向是:

  • 负链基因的“上游(5’端)”在 更大的坐标数那一侧
  • 你的 TA 单元从坐标上看是 1889651(更大)→ 1889026(更小) 这个方向转录

你想把 toxin+antitoxin 当一个单元一起 knockdown,那么最有效的策略通常是: 优先打在 antitoxin 的 5’端附近(靠近 1889651 一侧)以及其上游启动子区域,这样最容易把整条共转录本压下去。


1) “paired guides(成对 guides)”用中文再讲清楚

paired guides = 为同一个目标(同一个基因/同一转录单元)挑两条不同位置的 guide,同时表达,让 dCas9 在两个点上“堵住”转录,从而增强抑制的强度或稳定性。

  • 它不是“分别打两个基因”这个意思
  • 对你来说更合适的用法是:

    • 1 条 guide 卡在 启动子/TSS 附近
    • 另 1 条卡在 操纵子前段(这里就是 antitoxin 5’端或紧邻区域)
  • GuideFinder 会按你设置的“最小间距”(常见 100 bp)去输出可用的 guide 对

2) 用 GuideFinder 给 HD46(CP052959.1)这两个 locus_tag 设计 guides:实操步骤

下面按“你有完整基因组(complete genome)”的最常见流程写(你不需要自己手算 NGG 位点,GuideFinder 会做)。

Step A:准备文件

从 NCBI 下载这两个文件到同一目录(建议):

  1. 基因组序列 FASTACP052959.1.fna
  2. 基因组注释 GenBankCP052959.1.gbff(或 .gbk)

FASTA 提供序列;GenBank 提供 gene/CDS 坐标和 locus_tag。GuideFinder 依赖这些信息来定位目标基因并取启动子区域。

Step B:安装依赖

你需要:

  • R / RStudio
  • BLAST+(命令行 blastn):GuideFinder 用它做 off-target(脱靶)筛查
  • 下载 GuideFinder(GitHub: ohlab/Guide-Finder)的 Rmarkdown/R 脚本

Step C:准备目标基因列表

建一个文本文件(例如 targets.txt),内容就两行:

HJI06_09100
HJI06_09105

Step D:在 GuideFinder 里设置关键参数(推荐给 S. epidermidis 的组合)

因为 S. epidermidis GC 偏低,建议用“先严格、再迭代放宽”的策略(GuideFinder 的特色功能):

第一轮(主参数)

  • PAM:NGG(默认 SpCas9)
  • GC minimum:35%(或稍低一点)
  • TSS/启动子附近优先:让它偏向“离 TSS 更近”的 guide
  • off-target:开启(强烈建议不要关)

迭代轮(只针对第一轮找不到 guide 的基因自动放宽)

  • GC minimum:降到 30%
  • TSS 最大距离:放宽
  • 必要时再放宽一些序列过滤(同聚物等),但 off-target 最好别放得太松

Step E:运行并看输出

GuideFinder 通常会给你两类输出表(名字可能因版本略有不同):

  1. Top hits(单条 guide 推荐)
  2. Paired guides(成对 guide 推荐)

你现在的目标是“把 TA 单元一起压下去”,所以你从输出里优先挑:

  • 靠近 1889651 一侧(负链的 5’端/上游)的 guides

    • 重点看 HJI06_09105(antitoxin)输出里最靠前、最接近其 5’端/推定启动子区的 guides
    • HJI06_09100(toxin)也会出 guides,但从“整单元 knockdown”角度,最“入口”的位置通常更强

3) 针对你这个 TA 单元,怎么挑“最可能一把压住两基因”的 guide

因为它们紧挨着且共转录,你最推荐的组合是:

方案 1:单 guide(最简、最常成功)

  • 选 1 条 最接近操纵子启动子/TSS 的 guide
  • 实验上先用它验证 toxin 与 antitoxin 的 mRNA 是否都下降(RT-qPCR 两个都测)

方案 2:paired guides(更稳的增强版)

  • 选两条都位于“操纵子前端”的 guide(一般以 antitoxin 5’端/上游区域为核心)
  • 两条之间满足你设的最小间距(比如 100 bp)
  • 用同一个载体同时表达两条 guide(或串联表达)

4) 一个很关键的小提醒:负链时,“上游”在坐标更大端

你最初邮件里写的是 “(+)”,但 GenBank 注释清楚写了 complement。 所以当你在 GuideFinder 输出里看到坐标时,记住:

  • 越接近 1889651(更大坐标)越接近“转录起点/上游入口”
  • 这类 guide 通常更容易把整个 TA 转录单元一起压下去

把运行 GuideFinder 后输出表里与这两个 locus_tag 对应的前几条候选(包含坐标、链方向、序列、是否 off-target)贴出来,可以快速做二次筛选: 哪一条最适合做“单 guide 一把压住”,哪一对最适合做“paired guides 增强版”。