-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example code for "Further examples" #37
Comments
Hey @songtaogui, The key is to use Here is an example code: using GeneticsMakie, CairoMakie, Statistics
begin
@info "Set up example parameters"
chr, range1, range2 = "2", 1500, 4000
ntraits = 3
nsnps = 600
traits = ["Example 1", "Example 2", "Example 3"]
geno = rand(nsnps, 5)
ld = cor(geno, dims = 2)
ld = ld.^2
textstart = 325
textend = 375
x = range(0.5, 9.5, length = nsnps)
y = range(0.5, ntraits - 0.5, length = ntraits)
p = rand(nsnps, ntraits)
signs = rand([-1, 1], nsnps, ntraits)
signedp = p .* signs
end
begin
@info "Plot example figure"
f = Figure(resolution = (306, 750))
axs = [Axis(f[i, 1]) for i in 1:2]
@info "Plot first axis"
colormax = ceil(max(abs.(extrema(p))...))
heatmap!(axs[1], x, y, signedp, colorrange = (-colormax, colormax), colormap = :RdBu_11)
axs[1].yticks = (y, reverse(traits))
axs[1].yticklabelsize = 6
axs[1].yticklabelpad = 3
hidexdecorations!(axs[1])
hideydecorations!(axs[1], ticklabels = false)
hidespines!(axs[1], :r, :l, :b)
axs[1].spinewidth = 0.5
rowsize!(f.layout, 1, 6 * (ntraits + 1))
lines!(axs[1], fill(x[textstart], 2), [0, 3], color = :black, linewidth = 1.0)
lines!(axs[1], fill(x[textend], 2), [0, 3], color = :black, linewidth = 1.0)
text!(axs[1], "start", position = (x[textstart], last(y) + step(y) / 2), align = (:center, :bottom), fontsize = 5)
text!(axs[1], "end", position = (x[textend], last(y) + step(y) / 2), align = (:center, :bottom), fontsize = 5)
ylims!(axs[1], 0, 4)
GeneticsMakie.labelgenome(f[1, 1, Top()], chr, range1, range2)
@info "Plot second axis"
GeneticsMakie.plotld!(axs[2], ld, color = "black")
rowsize!(f.layout, 2, Aspect(1, 0.5))
hidespines!(axs[2])
ylims!(axs[2], 0, 5)
rowgap!(f.layout, 0)
resize_to_layout!(f)
save("example.png", f, px_per_unit = 4)
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this wonderful pkg,
I would like to use GeneticsMakie to draw some gwas results similar to those in the "Patterns of association and LD" example in the README.md:
However, I have no idea how to start after reading the doc.
Could you please provide the example code for this example?
Thanks a lot!
All the best,
SongtaoGui
The text was updated successfully, but these errors were encountered: