RNAvigate 1.1.4__tar.gz → 1.2.1__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.4 → rnavigate-1.2.1}/PKG-INFO +2 -2
- {rnavigate-1.1.4 → rnavigate-1.2.1}/RNAvigate.egg-info/PKG-INFO +2 -2
- {rnavigate-1.1.4 → rnavigate-1.2.1}/RNAvigate.egg-info/SOURCES.txt +3 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/RNAvigate.egg-info/requires.txt +1 -1
- {rnavigate-1.1.4 → rnavigate-1.2.1}/pyproject.toml +2 -2
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/__init__.py +2 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/interactions.py +2 -2
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/secondary_structure.py +2 -1
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data_loading.py +11 -5
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/__init__.py +1 -1
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/helper_functions.py +224 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/__init__.py +22 -2
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/alignment.py +8 -1
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/arc.py +182 -168
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/circle.py +103 -16
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/functions/__init__.py +20 -2
- rnavigate-1.2.1/rnavigate/plots/functions/circle.py +455 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/functions/functions.py +169 -25
- rnavigate-1.2.1/rnavigate/plots/functions/tracks.py +475 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/plots.py +35 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/profile.py +77 -62
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/skyline.py +101 -72
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/sm.py +9 -2
- rnavigate-1.2.1/rnavigate/plots/track_stack.py +653 -0
- rnavigate-1.2.1/rnavigate/plots/tracks.py +205 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plotting_functions.py +431 -16
- rnavigate-1.2.1/tests/test_data_loading.py +46 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/tests/test_helper_functions.py +25 -0
- rnavigate-1.1.4/rnavigate/plots/functions/circle.py +0 -74
- rnavigate-1.1.4/rnavigate/plots/functions/tracks.py +0 -227
- {rnavigate-1.1.4 → rnavigate-1.2.1}/LICENSE +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/README.md +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/RNAvigate.egg-info/dependency_links.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/RNAvigate.egg-info/top_level.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/analysis/__init__.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/analysis/auroc.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/analysis/check_sequence.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/analysis/deltashape.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/analysis/fragmapper.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/analysis/logcompare.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/analysis/lowss.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/__init__.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/alignments.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/annotation.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/colors.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/data.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/pdb.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/data/profile.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rmrp_data/RMRP-RNPMaP-Example_RESULTS.csv +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rmrp_data/__init__.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rmrp_data/hs-RMRP.nsd +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/3dhsCrystal_PlusLoops.pdb +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/RC_CRYSTAL_STRUCTURE.xrna +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/RNaseP-lit-like.nsd +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/RNaseP-noSC.fasta +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/RNaseP-withSC.fasta +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/RNaseP.ct +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/__init__.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example-rnasep-deletions.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example1-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example1-rnasep.corrs +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example1_rnasep_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example1_shapemapper_log.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example2-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example2-rnasep.corrs +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example2_rnasep_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example2_shapemapper_log.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example3-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example3-rnasep.corrs +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example3_rnasep_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example3_shapemapper_log.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example4-rnasep-pairmap.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example4-rnasep.corrs +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example4_rnasep_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/example4_shapemapper_log.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rnasep_data/rnasep.dp +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/2_Methyl_DMSO_subtracted_LSU_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/2_QN_DMSO_subtracted_LSU_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/2_ZLD_DMSO_subtracted_LSU_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.fasta +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.json +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.pdb +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/6HA1_LSU.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/6HA1_SSU.fasta +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/6HA1_SSU.json +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/6HA1_SSU.pdb +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/rrna_fragmap_data/__init__.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/tpp_data/2gdi.pdb +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/tpp_data/DMS_TPP_profile.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/tpp_data/DMS_TPP_rings.txt +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/tpp_data/TPP-2GDI.nsd +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/tpp_data/TPP-dms-bp.dp +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/examples/tpp_data/__init__.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/disthist.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/functions/ss.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/heatmap.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/linreg.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/mol.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/ntdist.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/qc.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/roc.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/plots/ss.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/rnavigate.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/styles.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/transcriptomics/__init__.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/transcriptomics/bed.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/transcriptomics/eclip.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/rnavigate/transcriptomics/transcriptome.py +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/setup.cfg +0 -0
- {rnavigate-1.1.4 → rnavigate-1.2.1}/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.2.1
|
|
4
4
|
Summary: RNA visualization and graphical analysis toolset
|
|
5
5
|
Author-email: Patrick Irving <psirving@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,7 +20,7 @@ Classifier: Intended Audience :: Science/Research
|
|
|
20
20
|
Requires-Python: >=3.9
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: biopython>=1.
|
|
23
|
+
Requires-Dist: biopython>=1.80
|
|
24
24
|
Requires-Dist: matplotlib>=3.8
|
|
25
25
|
Requires-Dist: numpy>=1.20.1
|
|
26
26
|
Requires-Dist: pandas>=1.4.4
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: RNAvigate
|
|
3
|
-
Version: 1.1
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: RNA visualization and graphical analysis toolset
|
|
5
5
|
Author-email: Patrick Irving <psirving@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -20,7 +20,7 @@ Classifier: Intended Audience :: Science/Research
|
|
|
20
20
|
Requires-Python: >=3.9
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
License-File: LICENSE
|
|
23
|
-
Requires-Dist: biopython>=1.
|
|
23
|
+
Requires-Dist: biopython>=1.80
|
|
24
24
|
Requires-Dist: matplotlib>=3.8
|
|
25
25
|
Requires-Dist: numpy>=1.20.1
|
|
26
26
|
Requires-Dist: pandas>=1.4.4
|
|
@@ -90,6 +90,8 @@ rnavigate/plots/roc.py
|
|
|
90
90
|
rnavigate/plots/skyline.py
|
|
91
91
|
rnavigate/plots/sm.py
|
|
92
92
|
rnavigate/plots/ss.py
|
|
93
|
+
rnavigate/plots/track_stack.py
|
|
94
|
+
rnavigate/plots/tracks.py
|
|
93
95
|
rnavigate/plots/functions/__init__.py
|
|
94
96
|
rnavigate/plots/functions/circle.py
|
|
95
97
|
rnavigate/plots/functions/functions.py
|
|
@@ -99,5 +101,6 @@ rnavigate/transcriptomics/__init__.py
|
|
|
99
101
|
rnavigate/transcriptomics/bed.py
|
|
100
102
|
rnavigate/transcriptomics/eclip.py
|
|
101
103
|
rnavigate/transcriptomics/transcriptome.py
|
|
104
|
+
tests/test_data_loading.py
|
|
102
105
|
tests/test_helper_functions.py
|
|
103
106
|
tests/test_import.py
|
|
@@ -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.2.1"
|
|
8
8
|
description = "RNA visualization and graphical analysis toolset"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -25,7 +25,7 @@ classifiers = [
|
|
|
25
25
|
]
|
|
26
26
|
requires-python = ">=3.9"
|
|
27
27
|
dependencies = [
|
|
28
|
-
"biopython>=1.
|
|
28
|
+
"biopython>=1.80",
|
|
29
29
|
"matplotlib>=3.8",
|
|
30
30
|
"numpy>=1.20.1",
|
|
31
31
|
"pandas>=1.4.4",
|
|
@@ -25,6 +25,7 @@ from rnavigate.plotting_functions import (
|
|
|
25
25
|
plot_shapemapper,
|
|
26
26
|
plot_skyline,
|
|
27
27
|
plot_ss,
|
|
28
|
+
plot_tracks,
|
|
28
29
|
)
|
|
29
30
|
from rnavigate import analysis
|
|
30
31
|
from rnavigate import data
|
|
@@ -56,6 +57,7 @@ __all__ = [
|
|
|
56
57
|
"plot_shapemapper",
|
|
57
58
|
"plot_skyline",
|
|
58
59
|
"plot_ss",
|
|
60
|
+
"plot_tracks",
|
|
59
61
|
# modules
|
|
60
62
|
"analysis",
|
|
61
63
|
"data",
|
|
@@ -654,7 +654,7 @@ class Interactions(data.Data):
|
|
|
654
654
|
ascending = self.metric not in ["Distance"] # high distance is bad
|
|
655
655
|
dataframe = self.data[["i", "j", self.metric]].copy()
|
|
656
656
|
dataframe = dataframe.sort_values(
|
|
657
|
-
by=self.metric, ascending=ascending, na_position="first"
|
|
657
|
+
by=self.metric, ascending=ascending, na_position="first", kind="stable"
|
|
658
658
|
)
|
|
659
659
|
return dataframe
|
|
660
660
|
|
|
@@ -1192,7 +1192,7 @@ class RINGMaP(Interactions):
|
|
|
1192
1192
|
columns = ["i", "j", self.metric]
|
|
1193
1193
|
dataframe = self.data[columns + ["Sign"]].copy()
|
|
1194
1194
|
dataframe[self.metric] = dataframe.eval(f"{self.metric} * Sign")
|
|
1195
|
-
dataframe = dataframe.sort_values(by=self.metric, ascending=True)
|
|
1195
|
+
dataframe = dataframe.sort_values(by=self.metric, ascending=True, kind="stable")
|
|
1196
1196
|
return dataframe[columns]
|
|
1197
1197
|
|
|
1198
1198
|
|
|
@@ -161,7 +161,8 @@ class SecondaryStructure(data.Sequence):
|
|
|
161
161
|
|
|
162
162
|
@property
|
|
163
163
|
def pair_nts(self):
|
|
164
|
-
|
|
164
|
+
# nullable Int32 becomes an object array in older pandas; a missing pair is 0
|
|
165
|
+
return self.data["Pair"].to_numpy(dtype=np.int64, na_value=0)
|
|
165
166
|
|
|
166
167
|
@property
|
|
167
168
|
def ycoordinates(self):
|
|
@@ -203,13 +203,19 @@ def get_sequence(sequence, sample=None, default=None):
|
|
|
203
203
|
raise ValueError("A sequence must be provided.")
|
|
204
204
|
elif sequence is None:
|
|
205
205
|
sequence = default
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
if sample is not None:
|
|
207
|
+
try:
|
|
208
|
+
sequence = sample.get_data(sequence)
|
|
209
|
+
except ValueError:
|
|
210
|
+
pass
|
|
210
211
|
if isinstance(sequence, data.Sequence):
|
|
211
212
|
return sequence
|
|
212
|
-
|
|
213
|
+
# a long sequence string is not a file name; checking it as one raises OSError
|
|
214
|
+
if (
|
|
215
|
+
isinstance(sequence, str)
|
|
216
|
+
and len(Path(sequence).name) < 255
|
|
217
|
+
and Path(sequence).exists()
|
|
218
|
+
):
|
|
213
219
|
return data.Sequence(sequence)
|
|
214
220
|
if isinstance(sequence, str) and all([nt.upper() in "AUCGT.-" for nt in sequence]):
|
|
215
221
|
return data.Sequence(sequence)
|
|
@@ -144,7 +144,7 @@ def __getattr__(name): # pylint: disable=invalid-name
|
|
|
144
144
|
pairmap=str(rnasep_dir / "example4-rnasep-pairmap.txt"),
|
|
145
145
|
ringmap=str(rnasep_dir / "example4-rnasep.corrs"),
|
|
146
146
|
)
|
|
147
|
-
if name in ["linezolid", "
|
|
147
|
+
if name in ["linezolid", "quinaxoline", "methyl"]:
|
|
148
148
|
global _rrna_fragmap_common
|
|
149
149
|
if _rrna_fragmap_common is None:
|
|
150
150
|
_rrna_fragmap_common = rnav.Sample(
|
|
@@ -2,11 +2,95 @@
|
|
|
2
2
|
retreiving aligned data objects, and resolve_data for resolving flexible
|
|
3
3
|
data-keyword arguments into fully-resolved Data objects."""
|
|
4
4
|
|
|
5
|
+
from numbers import Real
|
|
6
|
+
|
|
5
7
|
from rnavigate import Sample, data
|
|
6
8
|
from rnavigate.data_loading import get_sequence
|
|
9
|
+
from rnavigate.plots.functions.tracks import FONT_PROPERTIES
|
|
10
|
+
from rnavigate.plots.track_stack import TRACK_KEYS
|
|
7
11
|
|
|
8
12
|
__all__ = ["fit_data", "resolve_data", "PlottingArgumentParser"]
|
|
9
13
|
|
|
14
|
+
_TRACK_CLASSES = {
|
|
15
|
+
"profile": data.Profile,
|
|
16
|
+
"domains": list,
|
|
17
|
+
"annotations": data.Annotation,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _track_type_keys(track):
|
|
22
|
+
"""Return the type keys of a track dictionary (exactly one if it is valid)."""
|
|
23
|
+
return [key for key in track if key in TRACK_KEYS]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _is_track_data(track_type, value):
|
|
27
|
+
"""Whether a resolved type value is data a track of `track_type` can draw.
|
|
28
|
+
|
|
29
|
+
A profile track takes one Profile. Domain and annotation tracks take one
|
|
30
|
+
Annotation or a non-empty list of them.
|
|
31
|
+
"""
|
|
32
|
+
if track_type == "profile":
|
|
33
|
+
return isinstance(value, data.Profile)
|
|
34
|
+
annotations = value if isinstance(value, list) else [value]
|
|
35
|
+
return bool(annotations) and all(
|
|
36
|
+
isinstance(each, data.Annotation) for each in annotations
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _resolve_sequence_track(value, sample, alignment):
|
|
41
|
+
"""Resolve a sequence track's value to a string on the plotting sequence.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
value : True, str, or rnavigate.data.Sequence
|
|
46
|
+
True for the plotting sequence. Otherwise a data keyword, a sequence string
|
|
47
|
+
(or fasta file), or a data object, whose sequence is projected onto the
|
|
48
|
+
plotting sequence through the alignment.
|
|
49
|
+
sample : rnavigate.Sample
|
|
50
|
+
The sample that data keywords are looked up in.
|
|
51
|
+
alignment : rnavigate.data.SequenceAlignment
|
|
52
|
+
The alignment to the plotting sequence.
|
|
53
|
+
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
sequence : str
|
|
57
|
+
One character per plotting-sequence position: the source's nucleotide where
|
|
58
|
+
aligned (mismatches included), "." where unaligned.
|
|
59
|
+
label : str or None
|
|
60
|
+
The data keyword if `value` is one, else None (the track's default label).
|
|
61
|
+
|
|
62
|
+
Raises
|
|
63
|
+
------
|
|
64
|
+
ValueError
|
|
65
|
+
If there is no plotting sequence, or `value` does not resolve as a sequence.
|
|
66
|
+
"""
|
|
67
|
+
if alignment is None:
|
|
68
|
+
raise ValueError("A sequence track needs a plotting sequence.")
|
|
69
|
+
if value is True:
|
|
70
|
+
return alignment.target_sequence, None
|
|
71
|
+
expected = (
|
|
72
|
+
f"A sequence track's value must be True (the plotting sequence), a data "
|
|
73
|
+
f"keyword, a sequence string, or a data object, got {value!r}"
|
|
74
|
+
)
|
|
75
|
+
if isinstance(value, bool) or not isinstance(value, (str, data.Sequence)):
|
|
76
|
+
raise ValueError(f"{expected}.")
|
|
77
|
+
label = None
|
|
78
|
+
source = value
|
|
79
|
+
if isinstance(value, str):
|
|
80
|
+
try:
|
|
81
|
+
source = sample.get_data(value)
|
|
82
|
+
label = value
|
|
83
|
+
except ValueError:
|
|
84
|
+
pass
|
|
85
|
+
try:
|
|
86
|
+
source = get_sequence(source, sample)
|
|
87
|
+
except ValueError as exception:
|
|
88
|
+
raise ValueError(
|
|
89
|
+
f"{expected}, which did not resolve as a sequence in {sample.sample}."
|
|
90
|
+
) from exception
|
|
91
|
+
projected = fit_data(data.Sequence(source.sequence), alignment)
|
|
92
|
+
return projected.sequence, label
|
|
93
|
+
|
|
10
94
|
|
|
11
95
|
def _parse_plot_kwargs(plot_kwargs, plot):
|
|
12
96
|
if plot_kwargs is None:
|
|
@@ -126,6 +210,7 @@ def resolve_data(value, data_class=data.Sequence, sample=None, alignment=None):
|
|
|
126
210
|
if not isinstance(value, data_class):
|
|
127
211
|
raise ValueError(f"{value} is not {data_class}")
|
|
128
212
|
elif isinstance(value, dict):
|
|
213
|
+
value = dict(value)
|
|
129
214
|
if "sequence" in value:
|
|
130
215
|
value["sequence"] = get_sequence(value["sequence"], sample)
|
|
131
216
|
value = data_class.resolve_from_dict(value, sample)
|
|
@@ -159,6 +244,8 @@ class PlottingArgumentParser:
|
|
|
159
244
|
data_dict[key] = self._parse_interactions(value, False)
|
|
160
245
|
elif key == "annotations":
|
|
161
246
|
data_dict[key] = self._parse_annotations(value)
|
|
247
|
+
elif key == "tracks":
|
|
248
|
+
data_dict[key] = self._parse_tracks(value)
|
|
162
249
|
self.data_dicts = []
|
|
163
250
|
classes = {
|
|
164
251
|
# in order of approximate usage
|
|
@@ -168,9 +255,16 @@ class PlottingArgumentParser:
|
|
|
168
255
|
"interactions": data.Interactions,
|
|
169
256
|
"domains": list,
|
|
170
257
|
}
|
|
258
|
+
shared_tracks = {}
|
|
171
259
|
for sample, label in zip(self.samples, self.labels):
|
|
172
260
|
this_data_dict = {"label": label}
|
|
173
261
|
for key, value in data_dict.items():
|
|
262
|
+
if key == "tracks":
|
|
263
|
+
this_data_dict[key] = [
|
|
264
|
+
self._resolve_track(track, sample, alignment, shared_tracks, i)
|
|
265
|
+
for i, track in enumerate(value)
|
|
266
|
+
]
|
|
267
|
+
continue
|
|
174
268
|
if key == "sequence":
|
|
175
269
|
new_value = get_sequence(value, sample)
|
|
176
270
|
new_value = fit_data(new_value, alignment)
|
|
@@ -257,6 +351,136 @@ class PlottingArgumentParser:
|
|
|
257
351
|
return [annotations]
|
|
258
352
|
raise error
|
|
259
353
|
|
|
354
|
+
def _parse_tracks(self, tracks):
|
|
355
|
+
"""Check the shape of every track dictionary, before any data is resolved.
|
|
356
|
+
|
|
357
|
+
Parameters
|
|
358
|
+
----------
|
|
359
|
+
tracks : None or list of dict
|
|
360
|
+
Track dictionaries. None is converted to [].
|
|
361
|
+
|
|
362
|
+
Returns
|
|
363
|
+
-------
|
|
364
|
+
list of dict
|
|
365
|
+
The track dictionaries, unresolved.
|
|
366
|
+
|
|
367
|
+
Raises
|
|
368
|
+
------
|
|
369
|
+
ValueError
|
|
370
|
+
If `tracks` is not a list of dictionaries, or a track dictionary breaks
|
|
371
|
+
the schema: not exactly one type key, a key its type does not allow, a
|
|
372
|
+
`height` or gap that is not a positive number, a `shared` that is not a
|
|
373
|
+
bool, or a `font` that is not a dictionary of known font properties.
|
|
374
|
+
"""
|
|
375
|
+
if tracks is None:
|
|
376
|
+
return []
|
|
377
|
+
expected = (
|
|
378
|
+
"tracks must be a list of track dictionaries, e.g. "
|
|
379
|
+
'[{"profile": "shapemap"}, {"gap": 1}]'
|
|
380
|
+
)
|
|
381
|
+
if not isinstance(tracks, list):
|
|
382
|
+
raise ValueError(f"{expected}, got {tracks!r}.")
|
|
383
|
+
for track in tracks:
|
|
384
|
+
if not isinstance(track, dict):
|
|
385
|
+
raise ValueError(f"{expected}, got an entry {track!r}.")
|
|
386
|
+
type_keys = _track_type_keys(track)
|
|
387
|
+
if len(type_keys) != 1:
|
|
388
|
+
raise ValueError(
|
|
389
|
+
f"Track dictionary {track!r} must have exactly one type key, got "
|
|
390
|
+
f"{len(type_keys)}. Type keys: {', '.join(TRACK_KEYS)}."
|
|
391
|
+
)
|
|
392
|
+
(track_type,) = type_keys
|
|
393
|
+
allowed = TRACK_KEYS[track_type]
|
|
394
|
+
for key in track:
|
|
395
|
+
if key == track_type or key in allowed:
|
|
396
|
+
continue
|
|
397
|
+
if key == "font":
|
|
398
|
+
accepting = [t for t, keys in TRACK_KEYS.items() if "font" in keys]
|
|
399
|
+
raise ValueError(
|
|
400
|
+
f'"font" is not allowed on a {track_type!r} track. Track '
|
|
401
|
+
f"types that accept it: {', '.join(accepting)}."
|
|
402
|
+
)
|
|
403
|
+
if track_type == "gap":
|
|
404
|
+
raise ValueError(
|
|
405
|
+
f'A gap track takes only its height, e.g. {{"gap": 1}}, got '
|
|
406
|
+
f"key {key!r}."
|
|
407
|
+
)
|
|
408
|
+
raise ValueError(
|
|
409
|
+
f"Unknown key {key!r} in {track_type!r} track dictionary. Allowed "
|
|
410
|
+
f"keys: {', '.join((track_type, *allowed))}."
|
|
411
|
+
)
|
|
412
|
+
if track_type == "gap":
|
|
413
|
+
self._check_track_height(track["gap"], "gap")
|
|
414
|
+
if "height" in track:
|
|
415
|
+
self._check_track_height(track["height"], "height")
|
|
416
|
+
label = track.get("label")
|
|
417
|
+
if not isinstance(label, (str, type(None))) and label is not False:
|
|
418
|
+
raise ValueError(
|
|
419
|
+
f'"label" must be a string, or False to hide it, got {label!r}.'
|
|
420
|
+
)
|
|
421
|
+
if "shared" in track and not isinstance(track["shared"], bool):
|
|
422
|
+
raise ValueError(
|
|
423
|
+
f'"shared" must be True or False, got {track["shared"]!r}.'
|
|
424
|
+
)
|
|
425
|
+
if "font" in track:
|
|
426
|
+
self._check_track_font(track["font"])
|
|
427
|
+
return tracks
|
|
428
|
+
|
|
429
|
+
@staticmethod
|
|
430
|
+
def _check_track_height(height, key):
|
|
431
|
+
if isinstance(height, bool) or not isinstance(height, Real) or height <= 0:
|
|
432
|
+
raise ValueError(
|
|
433
|
+
f"{key!r} must be a positive number of track height units, got "
|
|
434
|
+
f"{height!r}."
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
@staticmethod
|
|
438
|
+
def _check_track_font(font):
|
|
439
|
+
if not isinstance(font, dict):
|
|
440
|
+
raise ValueError(
|
|
441
|
+
f'"font" must be a dictionary of font properties, got {font!r}. '
|
|
442
|
+
f"Allowed properties: {', '.join(FONT_PROPERTIES)}."
|
|
443
|
+
)
|
|
444
|
+
for key in font:
|
|
445
|
+
if key not in FONT_PROPERTIES:
|
|
446
|
+
raise ValueError(
|
|
447
|
+
f"Unknown font property {key!r}. "
|
|
448
|
+
f"Allowed properties: {', '.join(FONT_PROPERTIES)}."
|
|
449
|
+
)
|
|
450
|
+
|
|
451
|
+
def _resolve_track(self, track, sample, alignment, shared_tracks, index):
|
|
452
|
+
"""Return `track` with its type value resolved and aligned for `sample`.
|
|
453
|
+
|
|
454
|
+
A shared track is resolved once, from the first sample it is resolved for,
|
|
455
|
+
and the same dictionary is returned for every sample.
|
|
456
|
+
"""
|
|
457
|
+
if track.get("shared", False) and index in shared_tracks:
|
|
458
|
+
return shared_tracks[index]
|
|
459
|
+
(track_type,) = _track_type_keys(track)
|
|
460
|
+
value = track[track_type]
|
|
461
|
+
default_label = None
|
|
462
|
+
if track_type == "sequence":
|
|
463
|
+
value, default_label = _resolve_sequence_track(value, sample, alignment)
|
|
464
|
+
elif track_type in _TRACK_CLASSES:
|
|
465
|
+
if value is None:
|
|
466
|
+
raise ValueError(
|
|
467
|
+
f"A {track_type!r} track's value must name its data, got None."
|
|
468
|
+
)
|
|
469
|
+
value = resolve_data(
|
|
470
|
+
value, _TRACK_CLASSES[track_type], sample=sample, alignment=alignment
|
|
471
|
+
)
|
|
472
|
+
if not _is_track_data(track_type, value):
|
|
473
|
+
raise ValueError(
|
|
474
|
+
f"{track[track_type]!r} did not resolve to {track_type} data "
|
|
475
|
+
f"in {sample.sample}."
|
|
476
|
+
)
|
|
477
|
+
resolved = track | {track_type: value}
|
|
478
|
+
if default_label is not None and "label" not in track:
|
|
479
|
+
resolved["label"] = default_label
|
|
480
|
+
if track.get("shared", False):
|
|
481
|
+
shared_tracks[index] = resolved
|
|
482
|
+
return resolved
|
|
483
|
+
|
|
260
484
|
def _parse_interactions(self, interactions, return_list=True):
|
|
261
485
|
"""Ensure interactions is the expected format.
|
|
262
486
|
|
|
@@ -13,6 +13,7 @@ from rnavigate.plots.roc import ROC
|
|
|
13
13
|
from rnavigate.plots.skyline import Skyline
|
|
14
14
|
from rnavigate.plots.sm import SM
|
|
15
15
|
from rnavigate.plots.ss import SS
|
|
16
|
+
from rnavigate.plots.tracks import Tracks
|
|
16
17
|
|
|
17
18
|
from rnavigate.plots.functions import (
|
|
18
19
|
get_contrasting_colors,
|
|
@@ -21,13 +22,18 @@ from rnavigate.plots.functions import (
|
|
|
21
22
|
get_nt_ticks,
|
|
22
23
|
set_nt_ticks,
|
|
23
24
|
box_xtick_labels,
|
|
25
|
+
get_arc_height,
|
|
26
|
+
get_arc_shape,
|
|
24
27
|
plot_interactions_arcs,
|
|
25
28
|
plot_profile_bars,
|
|
26
29
|
plot_profile_skyline,
|
|
27
30
|
plot_sequence_alignment,
|
|
31
|
+
plot_annotation_bars,
|
|
28
32
|
plot_annotation_track,
|
|
29
33
|
plot_domain_track,
|
|
34
|
+
plot_profile_track,
|
|
30
35
|
plot_sequence_track,
|
|
36
|
+
track_transform,
|
|
31
37
|
plot_annotation_ss,
|
|
32
38
|
plot_basepairs_ss,
|
|
33
39
|
plot_interactions_ss,
|
|
@@ -35,7 +41,11 @@ from rnavigate.plots.functions import (
|
|
|
35
41
|
plot_positions_ss,
|
|
36
42
|
plot_sequence_ss,
|
|
37
43
|
plot_structure_ss,
|
|
38
|
-
|
|
44
|
+
circle_track_transform,
|
|
45
|
+
plot_annotation_track_circle,
|
|
46
|
+
plot_domain_track_circle,
|
|
47
|
+
plot_profile_track_circle,
|
|
48
|
+
plot_sequence_track_circle,
|
|
39
49
|
plot_interactions_circle,
|
|
40
50
|
)
|
|
41
51
|
|
|
@@ -56,19 +66,25 @@ __all__ = [
|
|
|
56
66
|
"Skyline",
|
|
57
67
|
"SM",
|
|
58
68
|
"SS",
|
|
69
|
+
"Tracks",
|
|
59
70
|
"get_contrasting_colors",
|
|
60
71
|
"adjust_spines",
|
|
61
72
|
"clip_spines",
|
|
62
73
|
"get_nt_ticks",
|
|
63
74
|
"set_nt_ticks",
|
|
64
75
|
"box_xtick_labels",
|
|
76
|
+
"get_arc_height",
|
|
77
|
+
"get_arc_shape",
|
|
65
78
|
"plot_interactions_arcs",
|
|
66
79
|
"plot_profile_bars",
|
|
67
80
|
"plot_profile_skyline",
|
|
68
81
|
"plot_sequence_alignment",
|
|
82
|
+
"plot_annotation_bars",
|
|
69
83
|
"plot_annotation_track",
|
|
70
84
|
"plot_domain_track",
|
|
85
|
+
"plot_profile_track",
|
|
71
86
|
"plot_sequence_track",
|
|
87
|
+
"track_transform",
|
|
72
88
|
"plot_annotation_ss",
|
|
73
89
|
"plot_basepairs_ss",
|
|
74
90
|
"plot_interactions_ss",
|
|
@@ -76,6 +92,10 @@ __all__ = [
|
|
|
76
92
|
"plot_positions_ss",
|
|
77
93
|
"plot_sequence_ss",
|
|
78
94
|
"plot_structure_ss",
|
|
79
|
-
"
|
|
95
|
+
"circle_track_transform",
|
|
96
|
+
"plot_annotation_track_circle",
|
|
97
|
+
"plot_domain_track_circle",
|
|
98
|
+
"plot_profile_track_circle",
|
|
99
|
+
"plot_sequence_track_circle",
|
|
80
100
|
"plot_interactions_circle",
|
|
81
101
|
]
|
|
@@ -49,7 +49,14 @@ class Alignment(plots.Plot):
|
|
|
49
49
|
alignment1 = alignment.alignment1
|
|
50
50
|
self.region = (1, len(alignment1))
|
|
51
51
|
ax.set(xlim=(0, len(alignment1) + 1), ylim=(-5, 5), yticks=[])
|
|
52
|
-
plots.plot_sequence_alignment(
|
|
52
|
+
plots.plot_sequence_alignment(
|
|
53
|
+
ax,
|
|
54
|
+
alignment,
|
|
55
|
+
label,
|
|
56
|
+
plots.track_transform(ax, 0, coords="data", unit="data"),
|
|
57
|
+
offset=-5,
|
|
58
|
+
height=10,
|
|
59
|
+
)
|
|
53
60
|
for spine in ["top", "bottom", "left", "right"]:
|
|
54
61
|
ax.spines[spine].set_color(None)
|
|
55
62
|
|