Skip to content

Commit

Permalink
genetic correlation plot
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkim1210 committed Mar 19, 2022
1 parent fca72b9 commit 98dad6b
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/plotrg.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function plotrg!(
ax::Axis,
r::AbstractMatrix,
cols::AbstractVector;
colnames::AbstractVector;
p::Union{AbstractMatrix, Nothing} = nothing,
circle::Bool = true
)
Expand Down Expand Up @@ -37,8 +37,8 @@ function plotrg!(
counter = 1
for i in 1:n
for j in (i + 1):n
csl[counter] = Circle(Point2f(i - 0.5, 0.5 - j), r[i, j] * 0.45)
csu[counter] = Circle(Point2f(j - 0.5, 0.5 - i), r[j, i] * 0.45)
csl[counter] = Circle(Point2f(j - 0.5, 0.5 - i), r[i, j] * 0.45)
csu[counter] = Circle(Point2f(i - 0.5, 0.5 - j), r[j, i] * 0.45)
colorl[counter] = r[i, j]
coloru[counter] = r[j, i]
counter += 1
Expand All @@ -54,24 +54,38 @@ function plotrg!(
for j in (i + 1):n
widthl = r[i, j] * 0.95
widthu = r[j, i] * 0.95
csl[counter] = Rect(i - 1 + (1 - widthl) / 2, 1 - j - (1 - widthl) / 2, widthl, -widthl)
csu[counter] = Rect(j - 1 + (1 - widthu) / 2, 1 - i - (1 - widthu) / 2, widthu, -widthu)
csl[counter] = Rect(j - 1 + (1 - widthl) / 2, 1 - i - (1 - widthl) / 2, widthl, -widthl)
csu[counter] = Rect(i - 1 + (1 - widthu) / 2, 1 - j - (1 - widthu) / 2, widthu, -widthu)
colorl[counter] = r[i, j]
coloru[counter] = r[j, i]
counter += 1
end
end
end
poly!(ax, ps, color = :white, strokewidth = 0.75, strokecolor = "#C3C3C3")
poly!(ax, psd, color = "#C3C3C3", strokewidth = 0.75, strokecolor = "#C3C3C3")
poly!(ax, ps, color = :white, strokewidth = 0.5, strokecolor = "#C3C3C3")
# poly!(ax, psd, color = "#C3C3C3", strokewidth = 0.5, strokecolor = "#C3C3C3")
poly!(ax, csl, color = colorl, colorrange = (-1, 1), colormap = :RdBu_10)
poly!(ax, csu, color = coloru, colorrange = (-1, 1), colormap = :RdBu_10)
ax.xticks = (0.5:(n - 0.5), cols)
ax.yticks = (-0.5:-1:-(n - 0.5), cols)
if !isnothing(p)
pvalues = Matrix{Float64}(undef, n^2, 3)
counter = 1
for i in 1:n
for j in 1:n
j == i ? pvalues[counter, 1] = 1 : pvalues[counter, 1] = p[j, i]
pvalues[counter, 2] = i - 0.5
pvalues[counter, 3] = -j + 0.5
counter += 1
end
end
ind = findall(x -> x < 0.05, pvalues[:, 1])
scatter!(ax, pvalues[ind, 2], pvalues[ind, 3], marker = '', markersize = 7, color = :black)
end
ax.xticks = (0.5:(n - 0.5), colnames)
ax.yticks = (-0.5:-1:-(n - 0.5), colnames)
ax.xticklabelsize = 6
ax.yticklabelsize = 6
ax.xticklabelpad = 1
ax.yticklabelpad = 2
ax.xticklabelpad = 0
ax.yticklabelpad = 0
ax.xaxisposition = :top
ax.yaxisposition = :left
hidespines!(ax)
Expand Down

2 comments on commit 98dad6b

@mmkim1210
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: "Tag with name v0.1.2 already exists and points to a different commit"

Please sign in to comment.