DeltaSHAPE
DeltaSHAPE analysis detects meaningful changes in SHAPE reactivity between two samples. Parameters are optimized for detecting in cell vs. cell free protein protections and enhancements, but they are flexible and useful for identifying any kind of meaningful differences.
Import RNAvigate
[1]:
import rnavigate as rnav
Create RNAvigate samples
These example data are available as ready-to-go samples in the examples module.
I’ll just verify the data keywords. DeltaSHAPE only requires “shapemap”.
[2]:
from rnavigate.examples import rnasep_1, rnasep_2
rnasep_1.print_data_keywords()
rnasep_2.print_data_keywords()
Example 1 data keywords:
annotations:
profiles:
shapemap (default)
structures:
ss_ct (default)
ss_pdb
ss_lit
interactions:
shapejump (default)
pairprob
pairmap
ringmap
pdbs:
pdb (default)
Example 2 data keywords:
annotations:
profiles:
shapemap (default)
structures:
ss_ct (default)
ss_pdb
ss_lit
interactions:
shapejump (default)
pairprob
pairmap
ringmap
pdbs:
pdb (default)
Perform and visualize deltaSHAPE analysis
The DeltaSHAPE module provides functionality to quickly perform the analysis and visualize results. The deltaSHAPE profile is the difference between rolling average normalized SHAPE reactivities. Significant protections (sample 1 > sample 2) are highlighted green. Significant enhancements (sample 1 < sample 2) are highlighted purple.
The additional optional arguments and default values are commented out below.
[3]:
delta12 = rnav.analysis.DeltaSHAPE(
sample1=rnasep_1,
sample2=rnasep_2,
# profile="shapemap",
# smoothing_window=3,
# zf_coeff=1.96,
# ss_thresh=1,
# site_window=3,
# site_nts=2,
)
plot = delta12.plot()
The returned value is an RNAvigate Sample
DeltaSHAPE analysis returns an RNAvigate Sample. This can be used to create additional plots, and color or highlight significant protections and/or enhancements.
DeltaSHAPE samples inherit all of the data keywords from sample 1 and 2. For keywords that are shared between samples 1 and 2, sample 1 data is inherited.
New data keywords are:
deltashape: the deltashape profile
profile_1: the sample 1 profile
profile_2: the sample 2 profile
protections: an annotation of protections
enhancements: an annotation of enhancements
[4]:
delta12.print_data_keywords()
Example 1 vs. Example 2 data keywords:
annotations:
protections
enhancements
profiles:
shapemap (default)
deltashape
profile_1
profile_2
structures:
ss_ct (default)
ss_pdb
ss_lit
interactions:
shapejump (default)
pairprob
pairmap
ringmap
pdbs:
pdb (default)
Using the Sample in other plots
Below, I use the Sample returned from the DeltaSHAPE analysis to create a secondary structure diagram. I can use the "ss_pdb" data keyword that was inherited from the parent samples.
[5]:
plot = rnav.plot_ss(
samples=[delta12],
structure="ss_pdb",
annotations=["protections", "enhancements"],
)
Help documentation
For more detailed information about the attributes of the DeltaSHAPE analysis and DeltaSHAPEProfile, use the help command.
[6]:
help(rnav.analysis.DeltaSHAPE)
Help on class DeltaSHAPE in module rnavigate.analysis.deltashape:
class DeltaSHAPE(rnavigate.rnavigate.Sample)
| DeltaSHAPE(sample1, sample2, profile='shapemap', smoothing_window=3, zf_coeff=1.96, ss_thresh=1, site_window=3, site_nts=2)
|
| Detects meaningful differences in chemical probing reactivity
|
| References
| ----------
| doi:10.1021/acs.biochem.5b00977
|
| Algorithm
| ---------
| 1. Extract SHAPE-MaP sequence, normalized profile, and normalized
| standard error from given samples
| 2. Calculated smoothed profiles (mean) and propagate standard errors
| over rolling windows
| 3. Subtract raw and smoothed normalized profiles and propogate errors
| 4. Calculate Z-factors for smoothed data. This is the magnitude of the
| difference relative to the standard error
| 5. Calculate Z-scores for smoothed data. This is the magnitude of the
| difference in standard deviations from the mean difference
| 6. Call sites. Called sites must have # nucleotides that pass Z-factor
| and Z-score thresholds per window.
|
| Smoothing window size, Z factor threshold, Z score threshold, site-calling
| window size and minimum nucleotides per site can be specified.
|
| Method resolution order:
| DeltaSHAPE
| rnavigate.rnavigate.Sample
| builtins.object
|
| Methods defined here:
|
| __init__(self, sample1, sample2, profile='shapemap', smoothing_window=3, zf_coeff=1.96, ss_thresh=1, site_window=3, site_nts=2)
| Performs DeltaSHAPE analysis between samples 1 and 2
|
| Parameters
| ----------
| sample1 : rnavigate.Sample
| First sample to compare
| sample2 : rnavigate.Sample
| Second sample to compare
| profile : str, default="shapemap"
| Data keyword pointing to SHAPE-MaP data in samples 1 and 2
| smoothing_window : int, default=3
| Size of windows for data smoothing
| zf_coeff : float, default=1.96
| Sites must have a difference more than zf_coeff standard errors
| ss_thresh : int, default=1
| Sites must have a difference that is ss_thresh standard
| deviations from the mean difference
| site_window : int, default=3
| Number of nucleotides to include when calling sites
| site_nts : int, default=2
| Number of nts within site_window that must pass thresholds
|
| calculate_deltashape(self, smoothing_window=3, zf_coeff=1.96, ss_thresh=1, site_window=2, site_nts=3)
| Calculate or recalculate deltaSHAPE profile and called sites
|
| Parameters
| ----------
| smoothing_window : int, default=3
| Size of windows for data smoothing
| zf_coeff : float, default=1.96
| Sites must have a difference more than zf_coeff standard errors
| ss_thresh : int, default=1
| Sites must have a difference that is ss_thresh standard
| deviations from the mean difference
| site_window : int, default=3
| Number of nucleotides to include when calling sites
| site_nts : int, default=2
| Number of nts within site_window that must pass thresholds
|
| plot(self, region='all')
| Plot the deltaSHAPE result
|
| Parameters
| ----------
| region : list of 2 integers, default="all"
| start and end positions to plot
|
| Returns
| -------
| rnav.plots.Profile
| The plot object
|
| ----------------------------------------------------------------------
| Methods inherited from rnavigate.rnavigate.Sample:
|
| filter_interactions(self, interactions, metric=None, cmap=None, normalization=None, values=None, **kwargs)
| sets coloring properties and applies filters to interactions data.
|
| Parameters
| ----------
| interactions : rnavigate.data.Interactions or data keyword string
| Interactions object to be filtered. If a string, value is
| replaced with self.get_data(interactions)
| metric : str, optional
| column of interactions data to be used as metric for coloring
| interactions.
| "Distance" will compute 3D distance in "pdb", defaulting to
| 2'OH atom. "Distance_DMS" or "Distance_[atom id]" will use
| those atoms to compute distance.
| cmap : str or list, optional
| sets the interactions colormap, used to color interactions
| according to metric values.
| normalization : str, optional
| `"norm"`: extreme values in colormap are given to the extreme values of interactions metric data
| `"bins"`: data are colored according to which bin they fall in; `values` defines bins (list, length = 2 less than cmap)
| `"min_max"`: extreme values in cmap are given to values beyond minimum and maximum, defined by `values`
| values : varies
| behavior depends on normalization.
| `"norm"`: values are not needed
| `"bins"`: list of floats containing the boundaries between bins (one fewer than the number of categories)
| `"min_max"`: list of floats containing the minimum and maximum
| **kwargs
| Other arguments are passed to interactions.filter()
|
| get_data(self, data_keyword, data_class=None)
| Replaces data keyword with data object, even if nested.
|
| Parameters
| ----------
| data_keyword : rnavigate.data.Data or data keyword or list/dict of these
| If None, returns None.
| If a data keyword, returns associated data from sample
| If Data, returns that data.
| If a list or dictionary, returns list or dictionary with data keyword values replaced with associated Data
| data_class : rnavigate.data.Data class or subclass, optional
| If provided, ensures that returned data is of this type.
|
| Returns
| -------
| Same type as data_keyword argument, with data keywords replaced by associated data.
|
| Raises
| ------
| ValueError:
| if data is not found in sample
| ValueError:
| if the data retrieved is not of the specified data_class
|
| inherit_data(self, inherit, keep_inherited_defaults, overwrite)
| retrieves and stores data and data keywords from other samples
|
| Parameters
| ----------
| inherit : Sample or list of Samples
| Other samples from which to inherit data and data keywords
| keep_inherited_defaults : bool
| Use default values from inherited samples
| overwrite : bool
| whether to overwrite any existing keywords with inherited keywords
|
| print_data_keywords(self, return_dict=False)
| Print a nicely formatted, organized list of data keywords.
|
| Returns a dictionary of data keywords, organized by data type, if
| return_dict is True.
|
| set_as_default(self, data_keyword, overwrite=True)
| Set the given data keyword as the default for its data class
|
| It's data class is determined automatically. Only one default exists
| per data class and per Sample object.
|
| Parameters
| ----------
| data_keyword : str
| The data keyword to set as the default
| overwrite : bool, defaults to ``True``
| whether to overwrite a pre-existing default data keyword
|
| set_data(self, data_keyword, inputs, overwrite=False)
| Add data to Sample using the given data keyword and inputs
|
| This methods works similarly to the data keywords arguments used
| during Sample initialization:
|
| my_sample = rnavigate.Sample(
| sample="name",
| data_keyword=inputs)
|
| is equivalent to:
|
| my_sample = rnavigate.Sample(
| sample="name")
| my_sample.add_data(
| "data_keyword", inputs)
|
| Parameters
| ----------
| data_keyword : str
| a data keyword used to store and/or parse the inputs
| inputs : dict or rnavigate.data.Data
| a dictionary used to create the data object or a data object itself
| overwrite : bool, defaults to False
| whether to overwrite a pre-existing data_keyword
|
| ----------------------------------------------------------------------
| Data descriptors inherited from rnavigate.rnavigate.Sample:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object