Skip to content

Commit

Permalink
Update scripts to summarize TADs and insulation scores
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Aug 29, 2023
1 parent db23952 commit fcee2e7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
24 changes: 15 additions & 9 deletions bin/generate_insulation_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Dict, Tuple

import bioframe as bf
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -158,8 +159,8 @@ def plot_scatters(fig, axs, lb, ub, scores: pd.DataFrame):
cond1, cond2 = scores.columns[i], scores.columns[j]
sns.regplot(
scores,
x=cond1,
y=cond2,
x=cond2,
y=cond1,
ci=False,
color="blue",
scatter_kws={"alpha": 0.1},
Expand All @@ -170,10 +171,6 @@ def plot_scatters(fig, axs, lb, ub, scores: pd.DataFrame):
for i in range(num_cols):
for j in range(num_cols):
ax = axs[i][j]

if j == i + 1:
ax.set(ylabel=scores.columns[i], xlabel=scores.columns[j])

if i >= j:
fig.delaxes(ax)
else:
Expand Down Expand Up @@ -204,21 +201,30 @@ def main():
ax.hist(scores["std"], bins=25, log=True)
ax.set(title="Insulation score STD", xlabel="std", ylabel="frequency")
outprefix = pathlib.Path(str(args["output_prefix"]) + "_hist")
plt.tight_layout()
fig.tight_layout()
save_plot_to_file(fig, outprefix, args["force"])

scores = map_insulation_to_tads(domains, scores)

grid_size = len(scores.columns) - 1
fig, axs = plt.subplots(grid_size, grid_size, figsize=(grid_size * 6.4, grid_size * 6.4))
fig, axs = plt.subplots(grid_size, grid_size, figsize=(grid_size * 3, grid_size * 3))
lb, ub = compute_axis_scale(scores)
plot_scatters(fig, axs, lb, ub, scores.drop(columns=["std"]))

plt.tight_layout()
fig.tight_layout()

outprefix = pathlib.Path(str(args["output_prefix"]) + "_scatter")
save_plot_to_file(fig, outprefix, args["force"])


if __name__ == "__main__":
mpl.rcParams.update(
{
"axes.titlesize": 10,
"axes.labelsize": 22,
"legend.fontsize": 17,
"xtick.labelsize": 18,
"ytick.labelsize": 18,
}
)
main()
22 changes: 14 additions & 8 deletions bin/generate_tad_interaction_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import bioframe as bf
import cooler
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -111,8 +112,8 @@ def plot_scatters(fig, axs, lb, ub, scores: pd.DataFrame):
cond1, cond2 = scores.columns[i], scores.columns[j]
sns.regplot(
scores,
x=cond1,
y=cond2,
x=cond2,
y=cond1,
ci=False,
color="blue",
scatter_kws={"alpha": 0.1},
Expand All @@ -123,10 +124,6 @@ def plot_scatters(fig, axs, lb, ub, scores: pd.DataFrame):
for i in range(num_cols):
for j in range(num_cols):
ax = axs[i][j]

if j == i + 1:
ax.set(ylabel=scores.columns[i], xlabel=scores.columns[j])

if i >= j:
fig.delaxes(ax)
else:
Expand Down Expand Up @@ -170,15 +167,24 @@ def main():
axis="columns",
)
grid_size = len(domains.columns)
fig, axs = plt.subplots(grid_size, grid_size, figsize=(grid_size * 6.4, grid_size * 6.4))
fig, axs = plt.subplots(grid_size, grid_size, figsize=(grid_size * 3, grid_size * 3))
lb, ub = compute_axis_scale(domains)
plot_scatters(fig, axs, lb, ub, domains)

plt.tight_layout()
fig.tight_layout()

outprefix = pathlib.Path(str(args["output_prefix"]) + "_scatter")
save_plot_to_file(fig, outprefix, args["force"])


if __name__ == "__main__":
mpl.rcParams.update(
{
"axes.titlesize": 10,
"axes.labelsize": 22,
"legend.fontsize": 17,
"xtick.labelsize": 18,
"ytick.labelsize": 18,
}
)
main()
10 changes: 10 additions & 0 deletions bin/generate_tad_overlap_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Dict, List

import bioframe as bf
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -165,4 +166,13 @@ def main():


if __name__ == "__main__":
mpl.rcParams.update(
{
"axes.titlesize": 10,
"axes.labelsize": 22,
"legend.fontsize": 17,
"xtick.labelsize": 18,
"ytick.labelsize": 18,
}
)
main()

0 comments on commit fcee2e7

Please sign in to comment.