Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kchu25 committed Sep 11, 2024
1 parent cbc37f0 commit dc240b7
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/plot_logo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@ end



@userplot ArrowPlot
@recipe function f(data::ArrowPlot)
coords = data.args[1]
color --> :grey
for coord in coords
for v in coord
@series begin
fill := 0
lw --> 0
# label --> k
v.x, v.y
end
end
end
end



@userplot LogoPlot
@recipe function f(data::LogoPlot;
rna=false,
Expand Down
59 changes: 59 additions & 0 deletions src/plot_logo_w_arr_gaps.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

@userplot ArrowPlot
@recipe function f(data::ArrowPlot)
coords = data.args[1]
color --> :grey
for coord in coords
for v in coord
@series begin
fill := 0
lw --> 0
# label --> k
v.x, v.y
end
end
end
end

"""
ds_mat: Matrix of distances between the pfms
e.g. 12 6
32 8
number of rows = number of "modes" of distances
number of columns = number of distance in between the pfms
weights: weights for each mode of distances
optional parameters:
given_num_cols: the total number of columns that will be occupied for all the arrow-shapes
arrow_shape_scale_ratio: the ratio by which the width of the arrow-shapes will be scaled
height_top: the maximum height of the arrow-shapes
"""
function logoplot_with_arrow_gaps(pfms,
ds_mats::Matrix{T},
weights::Vector{T};
given_num_cols::Int=15,
arrow_shape_scale_ratio::Real=0.7,
height_top::Real=1.7
) where T<:Real

@assert length(pfms)-1 == size(ds_mats, 2) "The number of columns in ds_mats should be equal to the length of pfms - 1"
@assert length(weights) == size(ds_mats, 1) "The number of rows in ds_mats should be equal to the length of weights"

coords_mat, pfm_starts, total_pfm_cols, total_d_cols =
make_arrow_shapes(ds_mats, weights, given_num_cols, pfms;
arrow_shape_scale_ratio=arrow_shape_scale_ratio, height_top=height_top)

p = nothinglogo(total_pfm_cols + total_d_cols);

for (ind, pfm) in enumerate(pfms)
logo_x_offset = pfm_starts[ind]
logoplot!(p, pfm, PlotPWM.bg;
dpi=65,
setup_off=true,
logo_x_offset=logo_x_offset)
end

for col in eachcol(coords_mat)
arrowplot!(p, col)
end
return p
end
44 changes: 44 additions & 0 deletions tmp3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,50 @@ inds_sorted = sortperm(weights)
weights = weights[inds_sorted]
ds_mats = @view ds_mats[inds_sorted, :]

"""
ds_mat: Matrix of distances between the pfms
e.g. 12 6
32 8
number of rows = number of "modes" of distances
number of columns = number of distance in between the pfms
weights: weights for each mode of distances
optional parameters:
given_num_cols: the total number of columns that will be occupied for all the arrow-shapes
arrow_shape_scale_ratio: the ratio by which the width of the arrow-shapes will be scaled
height_top: the maximum height of the arrow-shapes
"""
function logoplot_with_arrow_gaps(pfms,
ds_mats::Matrix{T},
weights::Vector{T};
given_num_cols::Int=15,
arrow_shape_scale_ratio::Real=0.7,
height_top::Real=1.7
) where T<:Real

@assert length(pfms)-1 == size(ds_mats, 2) "The number of columns in ds_mats should be equal to the length of pfms - 1"
@assert length(weights) == size(ds_mats, 1) "The number of rows in ds_mats should be equal to the length of weights"

coords_mat, pfm_starts, total_pfm_cols, total_d_cols =
make_arrow_shapes(ds_mats, weights, given_num_cols, pfms;
arrow_shape_scale_ratio=arrow_shape_scale_ratio, height_top=height_top)

p = nothinglogo(total_pfm_cols + total_d_cols);

for (ind, pfm) in enumerate(pfms)
logo_x_offset = pfm_starts[ind]
logoplot!(p, pfm, PlotPWM.bg;
dpi=65,
setup_off=true,
logo_x_offset=logo_x_offset)
end

for col in eachcol(coords_mat)
arrowplot!(p, col)
end
return p
end


coords_mat, pfm_starts, total_pfm_cols, total_d_cols =
make_arrow_shapes(ds_mats, weights, 15, pfms;
arrow_shape_scale_ratio=0.7, height_top=1.7)
Expand Down

0 comments on commit dc240b7

Please sign in to comment.