RNAvigate 1.1.2__tar.gz → 1.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rnavigate-1.1.2 → rnavigate-1.1.4}/PKG-INFO +2 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/RNAvigate.egg-info/PKG-INFO +2 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/RNAvigate.egg-info/SOURCES.txt +1 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/RNAvigate.egg-info/requires.txt +1 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/pyproject.toml +2 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/__init__.py +2 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/alignments.py +2 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/annotation.py +2 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/data.py +70 -2
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/interactions.py +218 -14
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/profile.py +532 -41
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/secondary_structure.py +8 -4
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data_loading.py +5 -2
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/__init__.py +4 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/helper_functions.py +103 -19
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/arc.py +26 -2
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/functions/functions.py +11 -6
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/linreg.py +4 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/ntdist.py +3 -1
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/roc.py +5 -6
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/ss.py +3 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plotting_functions.py +32 -7
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/rnavigate.py +1 -78
- rnavigate-1.1.4/tests/test_helper_functions.py +101 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/LICENSE +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/README.md +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/RNAvigate.egg-info/dependency_links.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/RNAvigate.egg-info/top_level.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/analysis/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/analysis/auroc.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/analysis/check_sequence.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/analysis/deltashape.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/analysis/fragmapper.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/analysis/logcompare.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/analysis/lowss.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/colors.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/data/pdb.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rmrp_data/RMRP-RNPMaP-Example_RESULTS.csv +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rmrp_data/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rmrp_data/hs-RMRP.nsd +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/3dhsCrystal_PlusLoops.pdb +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/RC_CRYSTAL_STRUCTURE.xrna +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/RNaseP-lit-like.nsd +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/RNaseP-noSC.fasta +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/RNaseP-withSC.fasta +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/RNaseP.ct +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example-rnasep-deletions.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example1-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example1-rnasep.corrs +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example1_rnasep_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example1_shapemapper_log.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example2-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example2-rnasep.corrs +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example2_rnasep_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example2_shapemapper_log.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example3-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example3-rnasep.corrs +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example3_rnasep_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example3_shapemapper_log.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example4-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example4-rnasep.corrs +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example4_rnasep_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/example4_shapemapper_log.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rnasep_data/rnasep.dp +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/2_Methyl_DMSO_subtracted_LSU_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/2_QN_DMSO_subtracted_LSU_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/2_ZLD_DMSO_subtracted_LSU_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.fasta +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.json +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.pdb +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/6HA1_SSU.fasta +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/6HA1_SSU.json +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/6HA1_SSU.pdb +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/rrna_fragmap_data/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/tpp_data/2gdi.pdb +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/tpp_data/DMS_TPP_profile.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/tpp_data/DMS_TPP_rings.txt +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/tpp_data/TPP-2GDI.nsd +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/tpp_data/TPP-dms-bp.dp +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/examples/tpp_data/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/alignment.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/circle.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/disthist.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/functions/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/functions/circle.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/functions/ss.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/functions/tracks.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/heatmap.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/mol.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/plots.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/profile.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/qc.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/skyline.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/plots/sm.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/styles.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/transcriptomics/__init__.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/transcriptomics/bed.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/transcriptomics/eclip.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/rnavigate/transcriptomics/transcriptome.py +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/setup.cfg +0 -0
- {rnavigate-1.1.2 → rnavigate-1.1.4}/tests/test_import.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RNAvigate
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
4
4
|
Summary: RNA visualization and graphical analysis toolset
|
|
5
5
|
Author-email: Patrick Irving <psirving@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -39,6 +39,7 @@ Requires-Dist: sphinx; extra == "docs"
|
|
|
39
39
|
Requires-Dist: sphinx-autobuild; extra == "docs"
|
|
40
40
|
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
41
41
|
Requires-Dist: nbsphinx; extra == "docs"
|
|
42
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
42
43
|
Requires-Dist: ipykernel; extra == "docs"
|
|
43
44
|
Dynamic: license-file
|
|
44
45
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RNAvigate
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
4
4
|
Summary: RNA visualization and graphical analysis toolset
|
|
5
5
|
Author-email: Patrick Irving <psirving@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -39,6 +39,7 @@ Requires-Dist: sphinx; extra == "docs"
|
|
|
39
39
|
Requires-Dist: sphinx-autobuild; extra == "docs"
|
|
40
40
|
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
|
41
41
|
Requires-Dist: nbsphinx; extra == "docs"
|
|
42
|
+
Requires-Dist: myst-parser; extra == "docs"
|
|
42
43
|
Requires-Dist: ipykernel; extra == "docs"
|
|
43
44
|
Dynamic: license-file
|
|
44
45
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "RNAvigate"
|
|
7
|
-
version = "1.1.
|
|
7
|
+
version = "1.1.4"
|
|
8
8
|
description = "RNA visualization and graphical analysis toolset"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -48,6 +48,7 @@ docs = [
|
|
|
48
48
|
"sphinx-autobuild",
|
|
49
49
|
"sphinx-rtd-theme",
|
|
50
50
|
"nbsphinx",
|
|
51
|
+
"myst-parser",
|
|
51
52
|
"ipykernel",
|
|
52
53
|
]
|
|
53
54
|
|
|
@@ -7,6 +7,7 @@ probing data.
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
from rnavigate.rnavigate import Sample
|
|
10
|
+
from rnavigate.helper_functions import resolve_data
|
|
10
11
|
from rnavigate.plotting_functions import (
|
|
11
12
|
plot_options,
|
|
12
13
|
plot_alignment,
|
|
@@ -37,6 +38,7 @@ __version__ = version("rnavigate")
|
|
|
37
38
|
|
|
38
39
|
__all__ = [
|
|
39
40
|
"Sample",
|
|
41
|
+
"resolve_data",
|
|
40
42
|
# plotting functions
|
|
41
43
|
"plot_options",
|
|
42
44
|
"plot_alignment",
|
|
@@ -154,7 +154,8 @@ def set_alignment(
|
|
|
154
154
|
Alignment 1 and 2 must have matching lengths.
|
|
155
155
|
alignment(1,2) and sequence(1,2) must differ only by dashes "-".
|
|
156
156
|
|
|
157
|
-
e.g
|
|
157
|
+
e.g.::
|
|
158
|
+
|
|
158
159
|
sequence1 ="AAGCUUCGGUACAUGCAAGAUGUAC"
|
|
159
160
|
sequence2 ="AUCGAUCGAGCUGCUGUGUACGUAC"
|
|
160
161
|
alignment1="AAGCUUCG---------GUACAUGCAAGAUGUAC"
|
|
@@ -294,8 +294,9 @@ class Motif(Annotation):
|
|
|
294
294
|
"R": "[AG]",
|
|
295
295
|
"Y": "[CTU]", # purine and pyrimidine
|
|
296
296
|
"N": "[ATUGC]",
|
|
297
|
+
"I": "I", # inosine
|
|
297
298
|
} # any nuc
|
|
298
|
-
re_pattern = "".join([nuc_codes
|
|
299
|
+
re_pattern = "".join([nuc_codes.get(n, re.escape(n)) for n in motif])
|
|
299
300
|
spans = []
|
|
300
301
|
for match in re.finditer(re_pattern, sequence):
|
|
301
302
|
start, end = match.span()
|
|
@@ -100,6 +100,71 @@ class Sequence:
|
|
|
100
100
|
return "seq-object"
|
|
101
101
|
return self.name
|
|
102
102
|
|
|
103
|
+
@classmethod
|
|
104
|
+
def resolve_from_dict(cls, value, sample):
|
|
105
|
+
"""Raises an error if resolve_from_dict is not implemented for the class."""
|
|
106
|
+
raise NotImplementedError(
|
|
107
|
+
f"resolve_from_dict is not implemented for {cls.__name__} class."
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
def translate_positions(self, positions, sequence=None):
|
|
111
|
+
"""Translates positions from another sequence's coordinate frame.
|
|
112
|
+
|
|
113
|
+
Parameters
|
|
114
|
+
----------
|
|
115
|
+
positions : list of int and/or tuple/list of 2 int
|
|
116
|
+
1-indexed positions, and/or (start, end) inclusive, 1-indexed
|
|
117
|
+
ranges, given in `sequence`'s coordinate frame (or in this
|
|
118
|
+
object's own coordinate frame, if `sequence` is None).
|
|
119
|
+
sequence : rnavigate.data.Sequence or string, defaults to None
|
|
120
|
+
The coordinate frame that `positions` are given in. If None,
|
|
121
|
+
`positions` are returned unchanged.
|
|
122
|
+
|
|
123
|
+
Returns
|
|
124
|
+
-------
|
|
125
|
+
list of int and/or tuple of 2 int
|
|
126
|
+
`positions`, translated to this object's native positions via
|
|
127
|
+
alignment. Positions that fall outside of the alignment are
|
|
128
|
+
translated to 0, which will not match any real position.
|
|
129
|
+
"""
|
|
130
|
+
if sequence is None:
|
|
131
|
+
return positions
|
|
132
|
+
alignment = data.SequenceAlignment(sequence, self)
|
|
133
|
+
translated = []
|
|
134
|
+
for position in positions:
|
|
135
|
+
if isinstance(position, (tuple, list)):
|
|
136
|
+
start, end = alignment.map_positions(list(position))
|
|
137
|
+
translated.append((int(start), int(end)))
|
|
138
|
+
else:
|
|
139
|
+
translated.append(int(alignment.map_positions([position])[0]))
|
|
140
|
+
return translated
|
|
141
|
+
|
|
142
|
+
@staticmethod
|
|
143
|
+
def position_in_ranges(position, ranges):
|
|
144
|
+
"""Checks whether a position matches any entry in a list of ranges.
|
|
145
|
+
|
|
146
|
+
Parameters
|
|
147
|
+
----------
|
|
148
|
+
position : int
|
|
149
|
+
a single 1-indexed position
|
|
150
|
+
ranges : list of int and/or tuple/list of 2 int
|
|
151
|
+
1-indexed positions, and/or (start, end) inclusive, 1-indexed
|
|
152
|
+
ranges, to check `position` against.
|
|
153
|
+
|
|
154
|
+
Returns
|
|
155
|
+
-------
|
|
156
|
+
bool
|
|
157
|
+
True if `position` equals or falls within any entry in `ranges`.
|
|
158
|
+
"""
|
|
159
|
+
for entry in ranges:
|
|
160
|
+
if isinstance(entry, (tuple, list)):
|
|
161
|
+
start, end = entry
|
|
162
|
+
if start <= position <= end:
|
|
163
|
+
return True
|
|
164
|
+
elif position == entry:
|
|
165
|
+
return True
|
|
166
|
+
return False
|
|
167
|
+
|
|
103
168
|
def read_fasta(self, fasta, entry):
|
|
104
169
|
"""Parse a fasta file for the first sequence.
|
|
105
170
|
|
|
@@ -573,8 +638,11 @@ class Data(Sequence):
|
|
|
573
638
|
@property
|
|
574
639
|
def error_column(self):
|
|
575
640
|
"""Get the column of the dataframe to use as the error for visualization."""
|
|
576
|
-
|
|
577
|
-
|
|
641
|
+
error_column = self._metric["error_column"]
|
|
642
|
+
if error_column is None:
|
|
643
|
+
return None
|
|
644
|
+
if error_column in self.data.columns:
|
|
645
|
+
return error_column
|
|
578
646
|
print(f"Warning: {self} missing expected error column")
|
|
579
647
|
return None
|
|
580
648
|
|
|
@@ -224,28 +224,50 @@ class Interactions(data.Data):
|
|
|
224
224
|
self.update_mask(mask)
|
|
225
225
|
return mask
|
|
226
226
|
|
|
227
|
-
def mask_on_position(self, exclude=None, isolate=None):
|
|
227
|
+
def mask_on_position(self, exclude=None, isolate=None, sequence=None):
|
|
228
228
|
"""Mask interactions based on their i and j positions.
|
|
229
229
|
|
|
230
|
+
An interaction is excluded (or kept, for isolate) if either its i or
|
|
231
|
+
its j position matches.
|
|
232
|
+
|
|
230
233
|
Parameters
|
|
231
234
|
----------
|
|
232
|
-
exclude : list of int, defaults to None
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
exclude : list of int and/or tuple/list of 2 int, defaults to None
|
|
236
|
+
Positions to exclude. An int excludes that single 1-indexed
|
|
237
|
+
position; a tuple or list of 2 ints (start, end) excludes an
|
|
238
|
+
inclusive, 1-indexed range of positions.
|
|
239
|
+
isolate : list of int and/or tuple/list of 2 int, defaults to None
|
|
240
|
+
Positions to isolate; all other interactions are masked. An int
|
|
241
|
+
isolates that single 1-indexed position; a tuple or list of 2
|
|
242
|
+
ints (start, end) isolates an inclusive, 1-indexed range of
|
|
243
|
+
positions.
|
|
244
|
+
sequence : rnavigate.data.Sequence or string, defaults to None
|
|
245
|
+
If provided, `exclude` and `isolate` positions are interpreted in
|
|
246
|
+
this sequence's coordinate frame and translated to this
|
|
247
|
+
Interactions object's native positions via alignment. If None,
|
|
248
|
+
positions are interpreted as this object's native positions.
|
|
236
249
|
|
|
237
250
|
Returns
|
|
238
251
|
-------
|
|
239
252
|
mask : numpy array
|
|
240
253
|
a boolean array of the same length as self.data
|
|
241
254
|
"""
|
|
255
|
+
if exclude is not None:
|
|
256
|
+
exclude = self.translate_positions(exclude, sequence)
|
|
257
|
+
if isolate is not None:
|
|
258
|
+
isolate = self.translate_positions(isolate, sequence)
|
|
242
259
|
mask = np.full(len(self.data), True)
|
|
243
260
|
for index, (i, j) in self.data[["i", "j"]].iterrows():
|
|
244
261
|
if exclude is not None:
|
|
245
|
-
if (i
|
|
262
|
+
if self.position_in_ranges(i, exclude) or self.position_in_ranges(
|
|
263
|
+
j, exclude
|
|
264
|
+
):
|
|
246
265
|
mask[index] = False
|
|
247
266
|
if isolate is not None:
|
|
248
|
-
if
|
|
267
|
+
if not (
|
|
268
|
+
self.position_in_ranges(i, isolate)
|
|
269
|
+
or self.position_in_ranges(j, isolate)
|
|
270
|
+
):
|
|
249
271
|
mask[index] = False
|
|
250
272
|
self.update_mask(mask)
|
|
251
273
|
return mask
|
|
@@ -358,14 +380,16 @@ class Interactions(data.Data):
|
|
|
358
380
|
new_data = alignment.map_dataframe(
|
|
359
381
|
dataframe=dataframe, position_columns=["i", "j"]
|
|
360
382
|
)
|
|
361
|
-
|
|
383
|
+
new_interactions = self.__class__(
|
|
362
384
|
input_data=new_data,
|
|
363
385
|
sequence=alignment.target_sequence,
|
|
364
|
-
metric=self.
|
|
386
|
+
metric=self.default_metric,
|
|
365
387
|
metric_defaults=self.metric_defaults,
|
|
366
388
|
window=self.window,
|
|
367
389
|
name=self.name,
|
|
368
390
|
)
|
|
391
|
+
new_interactions.metric = self._metric
|
|
392
|
+
return new_interactions
|
|
369
393
|
|
|
370
394
|
def update_mask(self, mask):
|
|
371
395
|
"""Updates the mask by ANDing the current mask with the given mask."""
|
|
@@ -399,6 +423,7 @@ class Interactions(data.Data):
|
|
|
399
423
|
min_distance=None,
|
|
400
424
|
exclude_nts=None,
|
|
401
425
|
isolate_nts=None,
|
|
426
|
+
sequence=None,
|
|
402
427
|
# others
|
|
403
428
|
resolve_conflicts=None,
|
|
404
429
|
**kwargs,
|
|
@@ -439,10 +464,21 @@ class Interactions(data.Data):
|
|
|
439
464
|
The maximum distance to allow. If None, no maximum distance is set.
|
|
440
465
|
min_distance : int, defaults to None
|
|
441
466
|
The minimum distance to allow. If None, no minimum distance is set.
|
|
442
|
-
exclude_nts : list of int, defaults to None
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
467
|
+
exclude_nts : list of int and/or tuple/list of 2 int, defaults to None
|
|
468
|
+
Positions to exclude. An int excludes that single 1-indexed
|
|
469
|
+
position; a tuple or list of 2 ints (start, end) excludes an
|
|
470
|
+
inclusive, 1-indexed range of positions.
|
|
471
|
+
isolate_nts : list of int and/or tuple/list of 2 int, defaults to None
|
|
472
|
+
Positions to isolate; all other interactions are masked. An int
|
|
473
|
+
isolates that single 1-indexed position; a tuple or list of 2
|
|
474
|
+
ints (start, end) isolates an inclusive, 1-indexed range of
|
|
475
|
+
positions.
|
|
476
|
+
sequence : rnavigate.data.Sequence or string, defaults to None
|
|
477
|
+
If provided, `exclude_nts` and `isolate_nts` positions are
|
|
478
|
+
interpreted in this sequence's coordinate frame and translated to
|
|
479
|
+
this Interactions object's native positions via alignment. If
|
|
480
|
+
None, positions are interpreted as this object's native
|
|
481
|
+
positions.
|
|
446
482
|
resolve_conflicts : str, defaults to None
|
|
447
483
|
If not None, conflicting windows are resolved using the Maximal
|
|
448
484
|
Weighted Independent Set. The weights are taken from the metric
|
|
@@ -478,7 +514,9 @@ class Interactions(data.Data):
|
|
|
478
514
|
self.reset_mask()
|
|
479
515
|
mask = np.full(len(self.data), True)
|
|
480
516
|
if filters_are_on(exclude_nts, isolate_nts):
|
|
481
|
-
mask &= self.mask_on_position(
|
|
517
|
+
mask &= self.mask_on_position(
|
|
518
|
+
exclude=exclude_nts, isolate=isolate_nts, sequence=sequence
|
|
519
|
+
)
|
|
482
520
|
if filters_are_on(max_distance, min_distance):
|
|
483
521
|
mask &= self.mask_on_distance(max_dist=max_distance, min_dist=min_distance)
|
|
484
522
|
if filters_are_on(min_profile, max_profile):
|
|
@@ -512,6 +550,69 @@ class Interactions(data.Data):
|
|
|
512
550
|
"""
|
|
513
551
|
return kwargs, np.full(len(self.data), True)
|
|
514
552
|
|
|
553
|
+
@classmethod
|
|
554
|
+
def resolve_from_dict(cls, value, sample):
|
|
555
|
+
"""Resolves a {"interactions": ..., filter/metric kwargs} dict.
|
|
556
|
+
|
|
557
|
+
Parameters
|
|
558
|
+
----------
|
|
559
|
+
value : dict
|
|
560
|
+
Must contain an "interactions" key, whose value is any flexible
|
|
561
|
+
data argument accepted by `rnavigate.resolve_data` (a Data
|
|
562
|
+
object, data keyword string, list, dict, or None). The remaining
|
|
563
|
+
keys configure coloring and filtering, see `rnavigate.resolve_data`
|
|
564
|
+
for details.
|
|
565
|
+
sample : rnavigate.Sample
|
|
566
|
+
The sample used to resolve data keywords and sibling defaults
|
|
567
|
+
("default_profile", "default_structure", "default_pdb").
|
|
568
|
+
|
|
569
|
+
Returns
|
|
570
|
+
-------
|
|
571
|
+
Interactions or None
|
|
572
|
+
The resolved, colored, and filtered Interactions object, or None
|
|
573
|
+
if the "interactions" key's value resolves to None.
|
|
574
|
+
"""
|
|
575
|
+
value = dict(value)
|
|
576
|
+
# check interactions is given and resolve it to a Interactions object
|
|
577
|
+
if "interactions" not in value:
|
|
578
|
+
raise ValueError('Interactions dict is missing a "interactions" key.')
|
|
579
|
+
interactions = sample.get_data(value.pop("interactions"), cls)
|
|
580
|
+
if interactions is None:
|
|
581
|
+
return None
|
|
582
|
+
interactions = interactions.copy()
|
|
583
|
+
# check for structure and resolve to a SecondaryStructure object
|
|
584
|
+
keys = ["structure", "sequence", "profile"]
|
|
585
|
+
data_classes = [data.SecondaryStructure, data.Sequence, data.Profile]
|
|
586
|
+
for key, data_class in zip(keys, data_classes):
|
|
587
|
+
if key in value:
|
|
588
|
+
value[key] = sample.get_data(value[key], data_class)
|
|
589
|
+
else:
|
|
590
|
+
try:
|
|
591
|
+
value[key] = sample.get_data(f"default_{key}", data_class)
|
|
592
|
+
except (KeyError, ValueError):
|
|
593
|
+
value[key] = None
|
|
594
|
+
# set up metric dict for coloring
|
|
595
|
+
metric_dict = {}
|
|
596
|
+
for key in ["metric", "cmap", "normalization", "values"]:
|
|
597
|
+
if key in value:
|
|
598
|
+
metric_dict[key] = value.pop(key)
|
|
599
|
+
metric_dict |= value.pop("metric_kwargs", {})
|
|
600
|
+
metric_str = metric_dict.pop("metric", None)
|
|
601
|
+
pdb = None
|
|
602
|
+
if metric_str is not None and metric_str.startswith("Distance"):
|
|
603
|
+
try:
|
|
604
|
+
pdb = sample.get_data("default_pdb", data.PDB)
|
|
605
|
+
except (KeyError, ValueError) as exception:
|
|
606
|
+
raise ValueError(
|
|
607
|
+
f'metric="{metric_str}" requires 3D distance, but sample '
|
|
608
|
+
"has no default_pdb"
|
|
609
|
+
) from exception
|
|
610
|
+
metric_dict["metric_column"] = interactions.resolve_metric(metric_str, pdb)
|
|
611
|
+
interactions.metric = metric_dict
|
|
612
|
+
# any remaining keys are used to filter the interactions
|
|
613
|
+
interactions.filter(**value)
|
|
614
|
+
return interactions
|
|
615
|
+
|
|
515
616
|
def get_ij_colors(self):
|
|
516
617
|
"""Gets i, j, and colors lists for plotting interactions.
|
|
517
618
|
|
|
@@ -579,6 +680,38 @@ class Interactions(data.Data):
|
|
|
579
680
|
else:
|
|
580
681
|
print(self.header, csv)
|
|
581
682
|
|
|
683
|
+
def resolve_metric(self, metric, pdb=None):
|
|
684
|
+
"""Resolves a metric string, computing 3D/contact distances if needed.
|
|
685
|
+
|
|
686
|
+
"Distance" and "Distance_<atom>" are special metric strings: they
|
|
687
|
+
request 3D distance (using `pdb`), computed and stored in a new
|
|
688
|
+
"Distance" column via `set_distances`, using `atom` (or the 2'-OH
|
|
689
|
+
atom, by default) to compute the distance.
|
|
690
|
+
|
|
691
|
+
Parameters
|
|
692
|
+
----------
|
|
693
|
+
metric : str or None
|
|
694
|
+
The requested metric column name, or a "Distance"/"Distance_<atom>"
|
|
695
|
+
string. If None, `self.default_metric` is used.
|
|
696
|
+
pdb : rnavigate.data.PDB, defaults to None
|
|
697
|
+
The PDB structure to use for 3D distance calculations. Required if
|
|
698
|
+
`metric` is a "Distance"/"Distance_<atom>" string.
|
|
699
|
+
|
|
700
|
+
Returns
|
|
701
|
+
-------
|
|
702
|
+
str
|
|
703
|
+
The resolved metric column name.
|
|
704
|
+
"""
|
|
705
|
+
if metric is None:
|
|
706
|
+
return self.default_metric
|
|
707
|
+
if metric.startswith("Distance"):
|
|
708
|
+
if len(metric.split("_")) == 2:
|
|
709
|
+
metric, atom = metric.split("_")
|
|
710
|
+
else:
|
|
711
|
+
atom = "O2'"
|
|
712
|
+
self.set_distances(pdb, atom)
|
|
713
|
+
return metric
|
|
714
|
+
|
|
582
715
|
def set_3d_distances(self, pdb, atom):
|
|
583
716
|
"""Wrapper for set_distances for backwards compatibility."""
|
|
584
717
|
self.set_distances(pdb, atom)
|
|
@@ -922,6 +1055,77 @@ class RINGMaP(Interactions):
|
|
|
922
1055
|
name=name,
|
|
923
1056
|
)
|
|
924
1057
|
|
|
1058
|
+
@classmethod
|
|
1059
|
+
def from_N7G(
|
|
1060
|
+
cls,
|
|
1061
|
+
input_data,
|
|
1062
|
+
sequence=None,
|
|
1063
|
+
metric="Statistic",
|
|
1064
|
+
metric_defaults=None,
|
|
1065
|
+
read_table_kw=None,
|
|
1066
|
+
window=1,
|
|
1067
|
+
name=None,
|
|
1068
|
+
):
|
|
1069
|
+
"""Construct a RINGMaP object for msDMS-MaP N7G correlations data.
|
|
1070
|
+
|
|
1071
|
+
Loads an extended ``rings.txt`` file produced by the Mustoe Lab
|
|
1072
|
+
msDMS-MaP pipeline. In this format, positions ``i`` or ``j`` greater
|
|
1073
|
+
than the sequence length indicate N7G (N7 of guanosine) nucleotides,
|
|
1074
|
+
encoded as ``position + sequence_length``. This constructor decodes
|
|
1075
|
+
those positions back to their true nucleotide indices and adds a
|
|
1076
|
+
``Type`` column classifying each pair as ``"N1N1"``, ``"N7N1"``,
|
|
1077
|
+
``"N1N7"``, or ``"N7N7"``, where the order indicates which of ``i``
|
|
1078
|
+
(first) and ``j`` (second) is the N7G position.
|
|
1079
|
+
|
|
1080
|
+
Use ``Type_eq`` and ``Type_ne`` filter kwargs when plotting to separate
|
|
1081
|
+
N1/N1 (backbone) and N7G-involving correlations.
|
|
1082
|
+
|
|
1083
|
+
Parameters
|
|
1084
|
+
----------
|
|
1085
|
+
input_data : str or pandas.DataFrame
|
|
1086
|
+
Path to an msDMS-MaP ``rings.txt`` file, or a DataFrame with
|
|
1087
|
+
the standard RINGMaP column layout plus the extended columns
|
|
1088
|
+
(``Zi``, ``Zj``, ``Mod_Depth``, ``Mod_Comuts``, ``Alpha``,
|
|
1089
|
+
``Unt_Depth``, ``Unt_Comuts``).
|
|
1090
|
+
sequence : str or rnavigate.Sequence
|
|
1091
|
+
The RNA sequence. Required to decode N7G-encoded positions.
|
|
1092
|
+
metric : str, defaults to "Statistic"
|
|
1093
|
+
The metric column to use for visualization.
|
|
1094
|
+
metric_defaults : dict, optional
|
|
1095
|
+
Additional metric defaults. See ``RINGMaP`` for details.
|
|
1096
|
+
read_table_kw : dict, optional
|
|
1097
|
+
Keyword arguments passed to ``pandas.read_table``. Defaults to None.
|
|
1098
|
+
window : int, defaults to 1
|
|
1099
|
+
Window size. Overwritten by the value in the file header.
|
|
1100
|
+
name : str, optional
|
|
1101
|
+
A name for the data object. Defaults to None.
|
|
1102
|
+
|
|
1103
|
+
Returns
|
|
1104
|
+
-------
|
|
1105
|
+
RINGMaP
|
|
1106
|
+
A RINGMaP object with a ``Type`` column and corrected ``i``/``j``
|
|
1107
|
+
positions.
|
|
1108
|
+
"""
|
|
1109
|
+
ringmap = cls(
|
|
1110
|
+
input_data=input_data,
|
|
1111
|
+
sequence=sequence,
|
|
1112
|
+
metric=metric,
|
|
1113
|
+
metric_defaults=metric_defaults,
|
|
1114
|
+
read_table_kw=read_table_kw,
|
|
1115
|
+
window=window,
|
|
1116
|
+
name=name,
|
|
1117
|
+
)
|
|
1118
|
+
length = ringmap.length
|
|
1119
|
+
i_N7G = ringmap.data["i"] > length
|
|
1120
|
+
j_N7G = ringmap.data["j"] > length
|
|
1121
|
+
ringmap.data["Type"] = "N1N1"
|
|
1122
|
+
ringmap.data.loc[i_N7G & j_N7G, "Type"] = "N7N7"
|
|
1123
|
+
ringmap.data.loc[i_N7G & ~j_N7G, "Type"] = "N7N1"
|
|
1124
|
+
ringmap.data.loc[~i_N7G & j_N7G, "Type"] = "N1N7"
|
|
1125
|
+
ringmap.data.loc[i_N7G, "i"] -= length
|
|
1126
|
+
ringmap.data.loc[j_N7G, "j"] -= length
|
|
1127
|
+
return ringmap
|
|
1128
|
+
|
|
925
1129
|
def read_file(self, filepath, read_table_kw=None):
|
|
926
1130
|
"""Parses a RINGMaP correlations file and stores data as a dataframe.
|
|
927
1131
|
|