Skip to content

Commit 8cf9dc2

Browse files
authored
Merge pull request #15 from domonik/dev
style changes and plot update
2 parents 74ff82c + 37ac036 commit 8cf9dc2

File tree

7 files changed

+102
-16
lines changed

7 files changed

+102
-16
lines changed

RNAdist/dashboard/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def get_navbar():
7474

7575
dbc.Collapse(
7676
[
77-
dbc.NavItem(dbc.NavLink(f"{page['name']}", href=page["relative_path"], id={"type": f"nav-item", "index": idx}), className="p-1") for
77+
dbc.NavItem(dbc.NavLink(f"{page['name']}", href=page["relative_path"], id={"type": f"nav-item", "index": idx}), className="p-1 nav-link-white") for
7878
idx, page in enumerate(dash.page_registry.values())
7979
],
8080
is_open=False,

RNAdist/dashboard/assets/custom.css

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RNAdist/dashboard/assets/tableFix.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
background: #fff;
55
}
66

7+
.nav-link {
8+
color: white !important;
9+
}
10+
11+
.warning {
12+
border-left: 4px solid var(--bs-info);
13+
background-color: var(--bs-info-bg);
14+
padding: 10px;
15+
margin: 10px 0;
16+
border-radius: 4px;
17+
}
18+
719

820
.dash-spreadsheet-container .dash-spreadsheet-inner table .dash-cell.active {
921
background-color: inherit !important;

RNAdist/dashboard/index.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,29 @@
22

33
This is the RNAdist Webserver used to calculate nucleotide distances on the ensemble of RNA secondary structures.
44

5-
In the Navbar at the top you can find and Input field to set your session token. Everything you compute here will be
6-
stored using this token. If you want to access your data later store your token somewhere.
5+
## What does it do
6+
The thermodynamic ensemble of RNA secondary structures refers to the collection of all possible conformations an RNA
7+
molecule can adopt, each associated with a specific probability determined by its free energy.
78

8-
Note that data will be stored no longer than 7 days and there is the possibility that it gets deleted even earlier
9-
depending on website traffic. Further all our jobs will be public. Meaning everyone that knows your token can access it.
9+
Each RNA secondary structure can be represented as a graph, where nucleotides are nodes and connections are edges.
10+
For simplicity, both backbone links and hydrogen bonds between base pairs are assigned an edge distance of 1, allowing
11+
the structure to be analyzed using standard graph-theoretical methods.
12+
13+
By sampling structures from the RNA thermodynamic ensemble, one can compute the distances between any two nucleotides
14+
$i$ and $j$ across the sampled graphs. This generates a distribution of distances, reflecting how often different spatial
15+
separations occur in the ensemble and providing insights into the flexibility and connectivity of the RNA molecule.
16+
17+
18+
## How to use
19+
Use the Navbar at the top to enter your session token. All computations will be associated with this token, so make
20+
sure to save it if you want to access your data later.
21+
22+
Next, go to the [**Submission**](/submission) page to enter your RNA sequence and folding/sampling parameters.
23+
Once your job is complete, it will appear as "finished" in the submissions table.
24+
25+
Finally, visit the [**Visualization**](/visualization) page to explore nucleotide distance distributions and view the
26+
sampled RNA structures.
27+
<div class="warning">
28+
<strong>Warning:</strong> Note that data will be stored no longer than 7 days and there is the possibility that it gets deleted even earlier
29+
depending on website traffic. Further all our jobs will be public. Meaning everyone that knows your token can access it.
30+
</div>

RNAdist/dashboard/pages/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def welcome_layout(text):
2121
[
2222
html.Div(
2323
[
24-
dcc.Markdown(text, dangerously_allow_html=True, ),
24+
dcc.Markdown(text, dangerously_allow_html=True, mathjax=True),
2525
]
2626
)
2727
]

RNAdist/dashboard/pages/visualization.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ def plot_histo(seq_hash, i, j, switch):
487487
fig = plot_distances_with_running_j(matrix, i-1, mfe=mfe)
488488
fig.update_layout(legend=dict(orientation="h"))
489489
else:
490-
fig = distance_histo_from_matrix(matrix, i-1, j-1)
490+
fig = distance_histo_from_matrix(matrix, i-1, j-1, vertical_spacing=0, row_heights=[0.8, 0.2])
491+
fig.update_layout(showlegend=False)
491492
fig.update_layout({"margin": {"b": 20, "r": 10, "t": 10, "l": 10}})
492493
if not switch:
493494
fig.update_layout(DARK_LAYOUT)

RNAdist/plots/sampling_plots.py

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import re
44
import time
55

6+
from plotly.subplots import make_subplots
7+
68

79
def empty_figure(annotation: str = None):
810
fig = go.Figure()
@@ -39,18 +41,52 @@ def empty_figure(annotation: str = None):
3941
)
4042
return fig
4143

42-
def distance_histo_from_matrix(distances, i, j, color:str ="#00a082"):
43-
fig = go.Figure()
44+
def distance_histo_from_matrix(distances, i, j, color:str ="#00a082", **kwargs):
45+
total_counts = distances[0, 0, 0]
46+
47+
hist = distances[i, j]
48+
q1 = histogram_quantile(hist, 0.25, total_counts)
49+
median = histogram_quantile(hist, 0.5, total_counts)
50+
q3 = histogram_quantile(hist, 0.75, total_counts)
51+
iqr = q3 - q1
52+
d_min = hist.nonzero()[0].min()
53+
d_max = hist.nonzero()[0].max()
54+
lower_whisker = max(d_min, q1 - 1.5 * iqr)
55+
upper_whisker = min(d_max, q3 + 1.5 * iqr)
56+
x = np.arange(hist.shape[-1])
57+
weighted_sum = np.sum(hist * x)
58+
ed = weighted_sum / total_counts
59+
60+
fig = make_subplots(rows=2, shared_xaxes=True, **kwargs)
4461
fig.add_trace(
4562
go.Bar(
46-
x=np.arange(distances.shape[-1]),
47-
y=distances[i, j] / distances[i, j].sum(),
63+
x=x,
64+
y=hist / hist.sum(),
4865
marker=dict(color=color),
49-
)
66+
name="Histogram",
67+
),
68+
row=1, col=1
69+
)
70+
fig.add_trace(
71+
go.Box(
72+
lowerfence=[float(lower_whisker)],
73+
q1=[float(q1)],
74+
median=[float(median)],
75+
q3=[float(q3)],
76+
upperfence=[float(upper_whisker)],
77+
mean=[float(ed)],
78+
name=f'Box',
79+
marker=dict(color=color),
80+
y=["Distribution"],
81+
boxpoints=False # hide individual points
82+
),
83+
row=2, col=1
5084
)
5185
fig.update_layout(
52-
xaxis=dict(title="Distance [nt]"),
53-
yaxis=dict(title="Probability")
86+
xaxis2=dict(title="Distance [nt]", showgrid=True),
87+
xaxis=dict(showgrid=True),
88+
yaxis=dict(title="Probability", showgrid=True),
89+
yaxis2=dict(showticklabels=False),
5490
)
5591
return fig
5692

0 commit comments

Comments
 (0)