Skip to content

Commit

Permalink
Update example figures.
Browse files Browse the repository at this point in the history
  • Loading branch information
emunozdc authored and emunozdc committed Jun 18, 2024
1 parent 3d58c2d commit 1380004
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 16 deletions.
15 changes: 11 additions & 4 deletions examples/pr_fig_a.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pyranges as pr
import pyranges_plot as prp
from pyranges_plot.plot_features import builtin_themes

# Load data
g = pr.PyRanges(
Expand Down Expand Up @@ -40,6 +41,10 @@
)

# Get plot
prp.set_engine("plt")
cmap = builtin_themes["Mariotti_lab"]["colormap"]
cmap += ["lightpink", "lightyellow"]
prp.set_options("colormap", cmap)
prp.plot(
[
g,
Expand All @@ -48,10 +53,12 @@
pr.concat([g_subseq, g_subseq_id]),
pr.concat([g_spl_subseq_for, g_spl_subseq_rev]),
],
engine="plt",
warnings=False,
id_col="transcript_id",
title_chr=" ",
limits=(-12, None),
to_file="fig3_1.png",
file_size=(7, 5),
limits=(-15, None),
to_file=("fig3_1.png", (700, 500)),
text=True,
text_pad=0.05,
theme="Mariotti_lab",
)
11 changes: 7 additions & 4 deletions examples/pr_fig_b.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
r_tile["transcript_id"] = ["r.tile(2)"] * len(r_tile) # rename for plot

# Get plot
prp.set_engine("plt")

prp.plot(
[r, r_window, tile_g, r_tile],
engine="plt",
id_col="transcript_id",
exon_border="black",
title_chr=" ",
limits=(-6, None),
to_file="fig3_2.png",
file_size=(7, 4),
limits=(-8, None),
to_file=("fig3_2.png", (700, 400)),
text=True,
text_pad=0.05,
theme="Mariotti_lab",
)
37 changes: 29 additions & 8 deletions examples/pr_fig_c.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pyranges as pr
import pyranges_plot as prp
import matplotlib.pyplot as plt

# Load data
a = pr.PyRanges(
Expand All @@ -8,6 +9,7 @@
"Start": [2, 12, 17, 22, 27, 32, 33],
"End": [5, 14, 20, 26, 29, 37, 36],
"Strand": ["+"] * 2 + ["-"] * 3 + ["+"] * 2,
"color_by": ["a"] * 7,
}
)

Expand All @@ -17,6 +19,7 @@
"Start": [6, 11, 18, 24, 34],
"End": [8, 13, 19, 28, 36],
"Strand": ["+"] * 3 + ["-"] * 1 + ["+"] * 1,
"color_by": ["b"] * 5,
}
)

Expand All @@ -25,15 +28,23 @@
a_ov_b_slack = a.overlap(b, slack=2)
a_ov_b_nostrand = a.overlap(b, strand_behavior="ignore")
a_ov_b_opstrand = a.overlap(b, strand_behavior="opposite")
for pr_obj in [a_ov_b, a_ov_b_slack, a_ov_b_nostrand, a_ov_b_opstrand]:
pr_obj["color_by"] = ["overlap"] * len(pr_obj)

# intersection
a_inters_b = a.intersect(b)
a_inters_b["color_by"] = ["intersect"] * len(a_inters_b)
a_setinters_b = a.set_intersect(b)
a_setinters_b["color_by"] = ["setintersect"] * len(a_setinters_b)


# subtract
a_subt_b = a.subtract_ranges(b) ## is this a.subtract(the slack one)
a_subt_b = a.subtract_ranges(b)
a_subt_b["color_by"] = ["subtract"] * len(a_subt_b)

# Get plot
prp.set_engine("plt")
plt.rcParams["figure.subplot.left"] = 0.4 # Adjust the left margin
prp.plot(
[
a,
Expand All @@ -46,13 +57,23 @@
a_setinters_b,
a_subt_b,
],
engine="plt",
y_labels=[
"a",
"b",
"a.overlap(b)",
"a.overlap(b, slack=2)",
"a.overlap(b, strand_behavior='ignore')",
"a.overlap(b, strand_behavior='opposite')",
"a.intersect(b)",
"a.set_intersect(b)",
"a.subtract_ranges(b)",
],
title_chr=" ",
text=False,
to_file="fig3_3.png",
file_size=(5, 4),
colormap=["#4169E1"],
warnings=False,
to_file=("fig3_3.png", (800, 400)),
color_col="color_by",
arrow_color="black",
arrow_line_width=0.6,
arrow_size_min=0.001,
arrow_line_width=0.5,
arrow_size=0.0005,
theme="Mariotti_lab",
)

0 comments on commit 1380004

Please sign in to comment.