Structure probing

From GPTomics/bioSkills · View interactive version

Structure probing is an AI agent skill from the GitHub repository GPTomics/bioSkills. Processes experimental RNA structure probing data (SHAPE-MaP, DMS-MaPseq) into per-nucleotide reactivity profiles with ShapeMapper2, then uses them as soft restraints on thermodynamic folding. Covers reagent and readout choice (SHAPE vs DMS, mutational-profiling vs RT-stop), the three control sample

How to use this skill

Skill file

Version Compatibility

Reference examples tested with: ShapeMapper2 2.1.5+, ViennaRNA 2.6+, SEISMIC-RNA 0.20+, matplotlib 3.8+, pandas 2.2+, numpy 1.26+

Before using code patterns, verify installed versions match. If versions differ:

If code throws ImportError, AttributeError, or TypeError, introspect the installed

package and adapt the example to match the actual API rather than retrying.

Structure Probing

"Process my SHAPE-MaP experiment to get RNA reactivity profiles" -> Convert per-nucleotide chemical-modification signal into reactivities, normalize them, then feed them as SOFT restraints into thermodynamic folding.

The governing principle: reactivity is flexibility, not pairing, and it is a constraint, not a structure

SHAPE reagents acylate the ribose 2'-OH at a rate set by local nucleotide FLEXIBILITY / conformational dynamics; DMS methylates the Watson-Crick face of A (N1) and C (N3). High reactivity means flexible/accessible, low means constrained. The routine over-interpretation is "low reactivity = base-paired": a nucleotide can be unreactive because it is base-paired OR because it is tertiary-contacted, protein-bound, ligand-occluded, or stacked. Reactivity probes CONSTRAINT, and it cannot by itself distinguish pairing from other protection. Before interpreting any low-reactivity region, rule out the TECHNICAL causes first: a long flat run can be low read depth / no-data or global undermodification, not structure -- check effective depth and confirm low-depth positions are carried as -999, not 0.

Two consequences govern everything below:

Reagent and readout choices

SHAPE acts on the backbone 2'-OH, so it reports all four bases; DMS reads only A/C by default (G/U carry no Watson-Crick-face signal and must be masked to no-data before folding). Newer DMS-MaPseq protocols recover G(N1)/U(N3) signal for a four-base readout (via mutation-signature filtering plus optimized buffer, not the buffer alone) -- only treat DMS as four-base if the protocol and analysis explicitly enable it; otherwise mask G/U.

| Goal | Reagent | Reads | Note |

|------|---------|-------|------|

| In-vitro, all-base, fast | 1M7 (SHAPE) | A/C/G/U flexibility | default; m/b = 1.8/-0.6 |

| In-cell SHAPE (membrane-permeable) | NAI, NAI-N3, 5NIA, 2A3 | A/C/G/U | NAI-N3 -> icSHAPE click enrichment; 2A3 among the strongest in vivo |

| In-cell, cheap, A/C-resolved | DMS | A(N1)/C(N3) | works in vivo; mask G/U to no-data |

| Tertiary-contact flagging | 1M6/NMIA vs 1M7 (differential SHAPE) | A/C/G/U | report the DIFFERENCE, not absolute |

| Fill G/U coverage | CMCT (G/U), kethoxal (G) | G,U / G | low throughput, rarely MaP-coupled |

Mutational profiling (MaP) vs RT-stop is a fundamental analysis fork, not a detail: in MaP the reverse transcriptase reads THROUGH the adduct (Mn2+/TGIRT/Marathon-RT) and misincorporates, encoding each modification as a point mutation; in RT-stop the adduct truncates the cDNA and the read 5'-end is counted. They need different scoring, and a pipeline tuned for one is wrong for the other.

| Axis | MaP (mutation) | RT-stop (truncation) |

|------|----------------|----------------------|

| Adduct encoded as | misincorporation/deletion | RT drop-off (read 5'-end) |

| Reads/molecule informative | many | one |

| Single-molecule / correlated analysis | yes (per-read mutation strings) | no |

| Tools | ShapeMapper2, SEISMIC-RNA, rf-count -sm 3/4 | rf-count -sm 1/2, icSHAPE, StructureFold |

| Methods | SHAPE-MaP, DMS-MaPseq | Mod-seq, Structure-seq, DMS-seq, icSHAPE |

icSHAPE / Structure-seq / DMS-seq are RT-stop methods; do not push them through a MaP mutation-rate pipeline (ShapeMapper2/SEISMIC).

ShapeMapper2: the three samples and verified flags

The three sample roles are distinct: MODIFIED is the signal; UNTREATED subtracts background (SNPs, RT errors, intrinsic damage); DENATURED normalizes sequence-dependent reactivity bias (divide modified by denatured when no good no-data reference exists). The untreated control is mandatory; the denatured control improves normalization.

# ShapeMapper2 is Linux-only; on macOS use Docker/Singularity (see usage-guide).
shapemapper \
    --target target_rna.fa \
    --name my_rna \
    --modified --R1 mod_R1.fastq.gz --R2 mod_R2.fastq.gz \
    --untreated --R1 unmod_R1.fastq.gz --R2 unmod_R2.fastq.gz \
    --out results/ \
    --nproc 8 \
    --min-depth 5000

| Option | Effect (verified default) |

|--------|---------------------------|

| --target / --name | reference FASTA / output basename |

| --modified / --untreated / --denatured | the three samples, each followed by --R1/--R2 |

| --amplicon | primer-trimmed amplicon mode |

| --min-depth | minimum effective depth to report a nt (default 5000) |

| --min-qual-to-count | minimum basecall quality in a mutation (default 30, not 20) |

| --max-bg | max untreated mutation frequency (default 0.05) |

| --star-aligner | use STAR instead of Bowtie2 (recommended for long targets) |

| --nproc / --overwrite | threads / overwrite output |

ShapeMapper2 writes a results/ tree. The reactivity table is <name>_<RNA>_profile.txt; the folder-ready files are SEPARATE: <name>_<RNA>.shape (2 columns: position, normalized reactivity; excluded = -999) and <name>_<RNA>.map (4 columns: position, normalized reactivity, stderr, base). There is no combined _map.shape file.

Key profile.txt columns: Nucleotide is the POSITION integer (1-based); Sequence is the base character; Reactivity_profile is raw; Norm_profile is after normalization. Fold with Norm_profile (or the .shape/.map file), never the raw Reactivity_profile -- the pseudo-energy parameters assume normalized input.

Normalization: per-transcript, and why raw reactivities are not comparable

Raw reactivity (background-subtracted modified mutation rate) sits on an arbitrary, experiment-specific scale set by reagent dose, RT efficiency, and depth. The standard 2-8% / box-plot normalization excludes outliers (top ~2% as a whisker cap), then scales by the mean of the next most-reactive ~8-10% of nucleotides, so normalized values mostly fall ~0-2 with ~1.0 = average reactivity. This scale factor is PER TRANSCRIPT: raw reactivities from different transcripts or experiments are NOT comparable, so never pool or compare raw reactivities across them. To compare two conditions (e.g. +/- ligand), use delta-SHAPE at matched positions with the per-nt standard errors, not raw subtraction. Low-depth nucleotides must become no-data (-999), not zero.

Reactivity-restrained folding and the pseudo-energy model

The Deigan model adds a soft pseudo-energy to every nucleotide in a stacked pair: deltaG = m * ln(1 + reactivity) + b. It is a restraint, not a hard constraint -- a nucleotide can still pair against the data if the global fold demands it.

| Situation | Model / ViennaRNA flag | Parameters |

|-----------|------------------------|------------|

| Standard SHAPE (1M7/NAI) | Deigan --shapeMethod="Dm1.8b-0.6" | m=1.8, b=-0.6 (Hajdin 2013) |

| Noisy data / probabilistic target | Zarringhalam --shapeMethod="Z" | target pairing probability |

| Penalize unpaired only | Washietl --shapeMethod="W" | perturbation vector |

| DMS-MaPseq | Deigan-style, A/C only, G/U set to -999 | no DMS-specific standard; commonly reuse 1.8/-0.6, or tune |

The m=1.8, b=-0.6 pair is the Hajdin et al. 2013 standard and the ViennaRNA "Deigan" DEFAULT -- it is NOT Deigan et al. 2009's own values (m=2.6, b=-0.8); cite it correctly. For DMS, apply the restraint ONLY to A/C and set G/U to -999, or the model invents constraints at bases that carry no signal. The folded energy a tool reports after a SHAPE/DMS restraint INCLUDES the pseudo-energy bonus, so it is not comparable to an unrestrained MFE -- judge the result by structure agreement, not by a more-negative energy.

# Fold directly from the ShapeMapper2 .shape file (already normalized)
RNAfold --shape=results/my_rna_my_rna.shape --shapeMethod="Dm1.8b-0.6" --noPS < target_rna.fa

In-cell vs in-vitro: the occupancy trap

In-vitro (refolded, deproteinized) RNA reports pure thermodynamics; in-cell reports the RNA as it exists, with bound proteins, ligands, and chaperone-remodeled states all altering reactivity. An in-cell PROTECTED nucleotide may be protein-bound or ligand-occluded, not base-paired -- the single biggest in-cell misinterpretation. Cells also actively unfold mRNA: genome-wide in-vivo DMS showed mRNAs are MORE unfolded in vivo than in vitro (Rouskin 2014). The in-cell-minus-in-vitro difference is itself the signal for protein/ligand footprints (Spitale 2015).

| Want | Condition | Reagent | Caveat |

|------|-----------|---------|--------|

| De-novo thermodynamic structure | in-vitro refolded | 1M7 SHAPE / DMS | MFE-like, no proteins |

| Functional in-cell state | in-cell | NAI/2A3/5NIA, DMS | protected != paired (occupancy) |

| Protein/ligand footprint | in-cell vs in-vitro delta | matched reagent | needs both, matched depth |

Multiple conformations: cluster, do not average

If a profile looks inconsistent with any single structure, the RNA may populate more than one. DREEM (Tomezsko 2020) and its maintained successor SEISMIC-RNA cluster MaP reads by co-occurring mutations (expectation-maximization) to deconvolve coexisting conformers; RING-MaP (Homan 2014) and PAIR-MaP (Mustoe 2019) use correlated mutations between positions to detect through-space communication and direct base pairs. These need per-read mutation data, which only MaP provides.

# DMS-MaPseq processing and multi-conformation clustering with SEISMIC-RNA
# Subcommand names vary by version (released: align/relate/mask/cluster; recent dev renames
# relate->idmut, mask->filter). Run `seismic --help` to confirm before scripting.
seismic align target.fa reads_R1.fq.gz reads_R2.fq.gz --out seismic_out
seismic relate seismic_out target.fa --out seismic_out
seismic mask seismic_out --out seismic_out
seismic cluster seismic_out --max-clusters 3 --out seismic_out

For RNA Framework (rf-count -> rf-norm), the reference is -f and the BAM/SAM files are positional; choose the MaP-vs-RT-stop scoring in rf-norm with -sm (1 Ding RT-stop, 2 Rouskin RT-stop, 3 Siegfried MaP, 4 Zubradt MaP) and the normalization with -nm (1 = 2-8% default, 3 = box-plot); restrict reactive bases for DMS with -rb AC.

rf-count -f reference.fa modified.bam untreated.bam -o rf_out/
rf-norm -i rf_out/index.rci -t rf_out/modified.rc -u rf_out/untreated.rc -sm 3 -nm 1 -rb AC

Quality thresholds

| Metric | Threshold | Rationale |

|--------|-----------|-----------|

| Effective depth | >= 5000 | reliable per-nt mutation-rate estimation for MaP |

| Untreated mutation rate | < 0.5% | overall expectation; higher suggests SNP, RT-prone motif, or damage (individual nt above --max-bg=5% are auto-excluded) |

| Modified mutation rate | ~1-10% | too low = undermodified; too high = degraded |

| No-data marker | -999 | low-depth/high-background nt; carry through folding, do not treat as 0 |

Common Errors

| Symptom | Cause | Fix |

|---------|-------|-----|

| KeyError: 'Reactivity_profile' or garbled sequence | reading base from Nucleotide (it is the position integer) | read the base from Sequence; fold with Norm_profile |

| FileNotFoundError: my_rna_map.shape | no combined file is written | use the separate <name>_<RNA>.shape (2-col) and .map (4-col) |

| Folding barely changes with SHAPE data | folding with raw Reactivity_profile, or vector mis-indexed | use Norm_profile; vector is 1-indexed (prepend -999), -999 = no data |

| DMS constraints look noisy at G/U | G/U carry no Watson-Crick DMS signal | mask G/U to -999 before folding and before normalization |

| rf-count -t target.fa -r mod.bam -rc unt.bam errors | wrong flags | reference is -f; BAMs are positional; there is no -r/-rc |

| Two conditions disagree but raw reactivities were compared | raw values are per-transcript, non-comparable | compare normalized profiles (delta-SHAPE) with standard errors |

| Profile fits no single structure | RNA populates multiple conformations | cluster MaP reads with SEISMIC-RNA / DREEM |

| In-cell protected region called "paired" | protection may be protein/ligand occupancy | compare in-cell vs in-vitro; do not equate protection with pairing |

| A long unreactive stretch read as a stable hairpin | could be low depth/no-data or undermodification, not pairing | check effective depth (>=5000) and that low-depth nt are -999 before interpreting |

Related Skills

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.