From 426f5ffb65cd352b55a5dbe981d5227a0b53147a Mon Sep 17 00:00:00 2001 From: minsoo Date: Tue, 4 Jun 2024 17:21:37 -0700 Subject: [PATCH] fix text! syntax --- Project.toml | 2 +- src/plotgenes.jl | 15 ++++++--------- src/plotisoforms.jl | 20 ++++++++------------ src/plotlocus.jl | 4 ++-- src/plotqq.jl | 2 +- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/Project.toml b/Project.toml index 2c46095..97f704e 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GeneticsMakie" uuid = "8ca62643-82d8-47b5-a233-a06d1654fb35" authors = ["Minsoo and contributors"] -version = "0.2.1" +version = "0.2.2" [deps] CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" diff --git a/src/plotgenes.jl b/src/plotgenes.jl index cc1ac13..dc6cc61 100644 --- a/src/plotgenes.jl +++ b/src/plotgenes.jl @@ -105,9 +105,8 @@ function plotgenes!( [1 - height / 2 - (rows[j] - 1) * (0.25 + height), 1 - height / 2 - (rows[j] - 1) * (0.25 + height)], color = genecolor, linewidth = 0.5) g = (strand[j] == "+" ? genes[j] * "→" : "←" * genes[j]) - text!(ax, "$g", - position = ((bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height)), - align = (:center, :bottom), fontsize = 6, color = textcolor) + text!(ax, (bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height), + text = "$g", align = (:center, :bottom), fontsize = 6, color = textcolor) end ax.spinewidth = 0.75 hidexdecorations!(ax) @@ -161,18 +160,16 @@ function plotgenes!( [1 - height / 2 - (rows[j] - 1) * (0.25 + height), 1 - height / 2 - (rows[j] - 1) * (0.25 + height)], color = highlight[2][ind], linewidth = 0.5) g = (strand[j] == "+" ? genes[j] * "→" : "←" * genes[j]) - text!(ax, "$g", - position = ((bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height)), - align = (:center, :bottom), fontsize = 6, color = highlight[2][ind]) + text!(ax, (bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height), + text = "$g", align = (:center, :bottom), fontsize = 6, color = highlight[2][ind]) else poly!(ax, ps[j], color = "gray60", strokewidth = 0) lines!(ax, [bs[j, 1], bs[j, 2]], [1 - height / 2 - (rows[j] - 1) * (0.25 + height), 1 - height / 2 - (rows[j] - 1) * (0.25 + height)], color = "gray60", linewidth = 0.5) g = (strand[j] == "+" ? genes[j] * "→" : "←" * genes[j]) - text!(ax, "$g", - position = ((bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height)), - align = (:center, :bottom), fontsize = 6, color = "gray60") + text!(ax, (bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height), + text = "$g", align = (:center, :bottom), fontsize = 6, color = "gray60") end end ax.spinewidth = 0.75 diff --git a/src/plotisoforms.jl b/src/plotisoforms.jl index a9bc1a2..72a3dcd 100644 --- a/src/plotisoforms.jl +++ b/src/plotisoforms.jl @@ -98,17 +98,15 @@ function plotisoforms!( lines!(ax, [bs[j, 1], bs[j, 2]], [1 - height / 2 - (rows[j] - 1) * (0.25 + height), 1 - height / 2 - (rows[j] - 1) * (0.25 + height)], color = isoformcolor, linewidth = 0.5) - text!(ax, "$(isoforms[j])", - position = ((bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height)), - align = (:center, :bottom), fontsize = 6, color = textcolor) + text!(ax, (bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height), + text = "$(isoforms[j])", align = (:center, :bottom), fontsize = 6, color = textcolor) else poly!(ax, ps[j], color = highlight[2][ind], strokewidth = 0) lines!(ax, [bs[j, 1], bs[j, 2]], [1 - height / 2 - (rows[j] - 1) * (0.25 + height), 1 - height / 2 - (rows[j] - 1) * (0.25 + height)], color = highlight[2][ind], linewidth = 0.5) - text!(ax, "$(isoforms[j])", - position = ((bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height)), - align = (:center, :bottom), fontsize = 6, color = textcolor) + text!(ax, (bs[j, 1] + bs[j, 2]) / 2, 1 - (rows[j] - 1) * (0.25 + height), + text = "$(isoforms[j])", align = (:center, :bottom), fontsize = 6, color = textcolor) end end elseif text == :bottom || text == :b @@ -119,17 +117,15 @@ function plotisoforms!( lines!(ax, [bs[j, 1], bs[j, 2]], [1 - height / 2 - (rows[j] - 1) * (0.25 + height), 1 - height / 2 - (rows[j] - 1) * (0.25 + height)], color = isoformcolor, linewidth = 0.5) - text!(ax, "$(isoforms[j])", - position = ((bs[j, 1] + bs[j, 2]) / 2, 1 - height - (rows[j] - 1) * (0.25 + height)), - align = (:center, :top), fontsize = 6, color = textcolor) + text!(ax, (bs[j, 1] + bs[j, 2]) / 2, 1 - height - (rows[j] - 1) * (0.25 + height), + text = "$(isoforms[j])", align = (:center, :top), fontsize = 6, color = textcolor) else poly!(ax, ps[j], color = highlight[2][ind], strokewidth = 0) lines!(ax, [bs[j, 1], bs[j, 2]], [1 - height / 2 - (rows[j] - 1) * (0.25 + height), 1 - height / 2 - (rows[j] - 1) * (0.25 + height)], color = highlight[2][ind], linewidth = 0.5) - text!(ax, "$(isoforms[j])", - position = ((bs[j, 1] + bs[j, 2]) / 2, 1 - height - (rows[j] - 1) * (0.25 + height)), - align = (:center, :top), fontsize = 6, color = textcolor) + text!(ax, (bs[j, 1] + bs[j, 2]) / 2, 1 - height - (rows[j] - 1) * (0.25 + height), + text = "$(isoforms[j])", align = (:center, :top), fontsize = 6, color = textcolor) end end else diff --git a/src/plotlocus.jl b/src/plotlocus.jl index 1f6de5a..c6b9984 100644 --- a/src/plotlocus.jl +++ b/src/plotlocus.jl @@ -114,12 +114,12 @@ function plotlocus!( bp = df.BP[ind] p = df.P[ind] scatter!(ax, [bp], [p], color = :purple1, markersize = 4.0, marker = '◆') - text!(ax, "$(df.index[1])", position = (bp, p), fontsize = 6, align = (:center, :bottom)) + text!(ax, bp, p, text = "$(df.index[1])", fontsize = 6, align = (:center, :bottom)) elseif length(df.index[1]) > 0 ind = findfirst(df.SNP .== df.index[1]) bp, p = df.BP[ind], df.P[ind] scatter!(ax, [bp], [p], color = :purple1, markersize = 4.0, marker = '◆') - text!(ax, "$(df.index[1])", position = (bp, p), fontsize = 6, align = (:center, :bottom)) + text!(ax, bp, p, text = "$(df.index[1])", fontsize = 6, align = (:center, :bottom)) end else scatter!(ax, df.BP, df.P, color = :gray60, markersize = 1.5) diff --git a/src/plotqq.jl b/src/plotqq.jl index 967cc0c..8fe8037 100644 --- a/src/plotqq.jl +++ b/src/plotqq.jl @@ -32,7 +32,7 @@ function plotqq!( band!(ax, expect, low, high, color = :gray90) scatter!(ax, expect, obs, markersize = 2, color = :black) lines!(ax, expect, expect, color = :red2, linewidth = 0.75) - text!(ax, "λgc = $(round(λgc, digits = 2))", position = (xmax - 0.5, 1), + text!(ax, xmax - 0.5, 1, text = "λgc = $(round(λgc, digits = 2))", fontsize = 6, align = (:right, :bottom)) xlims!(ax, 0, xmax) ylims!(ax, 0, ymax)