From 1a31bfc2c084cef0c941748ae5a23b5bca9e5968 Mon Sep 17 00:00:00 2001 From: monty Date: Thu, 2 Jan 2025 09:41:59 -0700 Subject: [PATCH] various fixes --- src/NMFkPlotMap.jl | 81 +++++++++++++++++++++++++++--------------- src/NMFkPostprocess.jl | 70 ++++++++++++++++++++---------------- 2 files changed, 92 insertions(+), 59 deletions(-) diff --git a/src/NMFkPlotMap.jl b/src/NMFkPlotMap.jl index 9aa375b..5fa3705 100644 --- a/src/NMFkPlotMap.jl +++ b/src/NMFkPlotMap.jl @@ -229,17 +229,6 @@ function plotmap(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::Abstra return p end -function plotly_title_length(title::AbstractString, length::Number) - if length <= 0 - return title - else - title_vector = split(title, ' ') - pushfirst!(title_vector, repeat(" ", length)) # adding nonbreaking spaces to control the colorbar size/position - title_adjusted = join(title_vector, "
") - return title_adjusted - end -end - function mapbox(df::DataFrames.DataFrame; column::Union{Symbol,AbstractString}="", filename::AbstractString="", title_length::Number=0, kw...) regex_lon = r"^[Xx]$|^[Ll]on" # regex for longitude regex_lat = r"^[Yy]$|^[Ll]at" # regex for latitude @@ -288,7 +277,7 @@ function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, M::AbstractMat end end -function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::AbstractVector{T2}; title::AbstractString="", text::AbstractVector=repeat([""], length(lon)), dot_size::Number=3, dot_size_fig::Number=dot_size, lonc::AbstractFloat=minimum(lon)+(maximum(lon)-minimum(lon))/2, font_size::Number=14, font_size_fig::Number=font_size, font_color_fig::AbstractString="black", line_color::AbstractString="black", latc::AbstractFloat=minimum(lat)+(maximum(lat)-minimum(lat))/2, zoom::Number=4, zoom_fig::Number=zoom, style="mapbox://styles/mapbox/satellite-streets-v12", mapbox_token=NMFk.mapbox_token, filename::AbstractString="", figuredir::AbstractString=".", format::AbstractString=splitext(filename)[end][2:end], width::Union{Nothing,Int}=nothing, height::Union{Nothing,Int}=nothing, scale::Real=1, legend::Bool=true, colorscale::Symbol=:rainbow, paper_bgcolor::AbstractString="#FFF", showcount::Bool=true, title_length::Number=0) where {T1 <: AbstractFloat, T2 <: AbstractFloat} +function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::AbstractVector{T2}; title::AbstractString="", text::AbstractVector=repeat([""], length(lon)), dot_size::Number=3, dot_size_fig::Number=dot_size, lonc::AbstractFloat=minimum(lon)+(maximum(lon)-minimum(lon))/2, font_size::Number=14, font_size_fig::Number=font_size, font_color::AbstractString="black", font_color_fig::AbstractString=font_color, line_color::AbstractString="black", latc::AbstractFloat=minimum(lat)+(maximum(lat)-minimum(lat))/2, zoom::Number=4, zoom_fig::Number=zoom, style="mapbox://styles/mapbox/satellite-streets-v12", mapbox_token=NMFk.mapbox_token, filename::AbstractString="", figuredir::AbstractString=".", format::AbstractString=splitext(filename)[end][2:end], width::Union{Nothing,Int}=nothing, height::Union{Nothing,Int}=nothing, scale::Real=1, legend::Bool=true, colorscale::Symbol=:rainbow, paper_bgcolor::AbstractString="#FFF", showcount::Bool=true, title_length::Number=0) where {T1 <: AbstractFloat, T2 <: AbstractFloat} @assert length(lon) == length(lat) @assert length(lon) == length(color) @assert length(lon) == length(text) @@ -321,13 +310,13 @@ function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::Abstrac end if legend marker = PlotlyJS.attr(; - size=dot_size, - line_width=0, - line_color=line_color, - color=color, - colorscale=NMFk.colorscale(colorscale), - colorbar=PlotlyJS.attr(; thicknessmode="pixels", thickness=30, len=0.5, title=plotly_title_length(title, title_length), titlefont=PlotlyJS.attr(size=font_size, color=font_color_fig), tickfont=PlotlyJS.attr(size=font_size, color=font_color_fig)) - ) + size=dot_size, + line_width=0, + line_color=line_color, + color=color, + colorscale=NMFk.colorscale(colorscale), + colorbar=PlotlyJS.attr(; thicknessmode="pixels", thickness=30, len=0.5, title=plotly_title_length(title, title_length), titlefont=PlotlyJS.attr(size=font_size, color=font_color), tickfont=PlotlyJS.attr(size=font_size, color=font_color)) + ) else marker = PlotlyJS.attr(; size=dot_size, color=color) end @@ -345,17 +334,43 @@ function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::Abstrac return p end -function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::AbstractVector{T2}; title::AbstractString="", text::AbstractVector=repeat([""], length(lon)), dot_size::Number=3, dot_size_fig::Number=dot_size, lonc::AbstractFloat=minimum(lon)+(maximum(lon)-minimum(lon))/2, font_size::Number=14, font_size_fig::Number=font_size, font_color_fig::AbstractString="black", line_color::AbstractString="black", latc::AbstractFloat=minimum(lat)+(maximum(lat)-minimum(lat))/2, zoom::Number=4, zoom_fig::Number=zoom, style="mapbox://styles/mapbox/satellite-streets-v12", mapbox_token=NMFk.mapbox_token, filename::AbstractString="", figuredir::AbstractString=".", format::AbstractString=splitext(filename)[end][2:end], width::Union{Nothing,Int}=nothing, height::Union{Nothing,Int}=nothing, scale::Real=1, legend::Bool=true, colorscale::Symbol=:rainbow, paper_bgcolor::AbstractString="#FFF", showcount::Bool=true, title_length::Number=0) where {T1 <: AbstractFloat, T2 <: Union{Number,Symbol,AbstractString,AbstractChar}} +function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::AbstractVector{T2}; title::AbstractString="", text::AbstractVector=repeat([""], length(lon)), dot_size::Number=3, dot_size_fig::Number=dot_size, lonc::AbstractFloat=minimum(lon)+(maximum(lon)-minimum(lon))/2, font_size::Number=14, font_size_fig::Number=font_size, font_color::AbstractString="black", font_color_fig::AbstractString=font_color, line_color::AbstractString="black", latc::AbstractFloat=minimum(lat)+(maximum(lat)-minimum(lat))/2, zoom::Number=4, zoom_fig::Number=zoom, style="mapbox://styles/mapbox/satellite-streets-v12", mapbox_token=NMFk.mapbox_token, filename::AbstractString="", figuredir::AbstractString=".", format::AbstractString=splitext(filename)[end][2:end], width::Union{Nothing,Int}=nothing, height::Union{Nothing,Int}=nothing, scale::Real=1, legend::Bool=true, colorscale::Symbol=:rainbow, paper_bgcolor::AbstractString="white", showcount::Bool=true, title_length::Number=0) where {T1 <: AbstractFloat, T2 <: Union{Number,Symbol,AbstractString,AbstractChar}} @assert length(lon) == length(lat) @assert length(lon) == length(color) @assert length(lon) == length(text) + if filename != "" + traces = [] + for (j, i) in enumerate(unique(sort(color))) + iz = color .== i + jj = j % length(NMFk.colors) + k = jj == 0 ? length(NMFk.colors) : jj + marker = PlotlyJS.attr(; size=dot_size_fig, color=NMFk.colors[k], colorbar=PlotlyJS.attr(; thicknessmode="pixels", thickness=30, len=0.5, title=plotly_title_length(repeat(" ", title_length) * " colorbar " * title, title_length), titlefont=PlotlyJS.attr(size=font_size_fig, color=paper_bgcolor), tickfont=PlotlyJS.attr(size=font_size_fig, color=paper_bgcolor))) + name = showcount ? "$(string(i)) [$(sum(iz))]" : "$(string(i))" + trace = PlotlyJS.scattermapbox(; + lon=lon[iz], + lat=lat[iz], + text=text[iz], + hoverinfo="text", + name=name, + marker=marker, + line_color=line_color, + showlegend=legend, + attributionControl=false) + push!(traces, trace) + end + traces = convert(Vector{typeof(traces[1])}, traces) + layout = plotly_layout(lonc, latc, zoom_fig; paper_bgcolor=paper_bgcolor, font_size=font_size_fig, font_color=font_color_fig, title=title, style=style, mapbox_token=mapbox_token) + p = PlotlyJS.plot(traces, layout; config=PlotlyJS.PlotConfig(; scrollZoom=true, staticPlot=false, displayModeBar=false, responsive=true)) + fn = joinpathcheck(figuredir, filename) + PlotlyJS.savefig(p, fn; format=format, width=width, height=height, scale=scale) + end traces = [] for (j, i) in enumerate(unique(sort(color))) iz = color .== i jj = j % length(NMFk.colors) k = jj == 0 ? length(NMFk.colors) : jj - marker = PlotlyJS.attr(; size=dot_size, color=NMFk.colors[k]) - name = plotly_title_length(showcount ? "$(string(i)) [$(sum(iz))]" : "$(string(i))", title_length) + marker = PlotlyJS.attr(; size=dot_size, color=NMFk.colors[k], colorbar=PlotlyJS.attr(; thicknessmode="pixels", thickness=30, len=0.5, title=plotly_title_length(repeat(" ", title_length) * " colorbar " * title, title_length), titlefont=PlotlyJS.attr(size=font_size, color=paper_bgcolor), tickfont=PlotlyJS.attr(size=font_size, color=paper_bgcolor))) + name = showcount ? "$(string(i)) [$(sum(iz))]" : "$(string(i))" trace = PlotlyJS.scattermapbox(; lon=lon[iz], lat=lat[iz], @@ -363,17 +378,13 @@ function mapbox(lon::AbstractVector{T1}, lat::AbstractVector{T1}, color::Abstrac hoverinfo="text", name=name, marker=marker, - showlegend=legend, + showlegend=true, attributionControl=false) push!(traces, trace) end traces = convert(Vector{typeof(traces[1])}, traces) - layout = plotly_layout(lonc, latc, zoom; paper_bgcolor=paper_bgcolor, title=title, style=style, mapbox_token=mapbox_token) + layout = plotly_layout(lonc, latc, zoom; paper_bgcolor=paper_bgcolor, title=title, font_size=font_size, font_color=font_color, style=style, mapbox_token=mapbox_token) p = PlotlyJS.plot(traces, layout; config=PlotlyJS.PlotConfig(; scrollZoom=true, staticPlot=false, displayModeBar=false, responsive=true)) - if filename != "" - fn = joinpathcheck(figuredir, filename) - PlotlyJS.savefig(p, fn; format=format, width=width, height=height, scale=scale) - end return p end @@ -382,13 +393,14 @@ function mapbox(lon::AbstractFloat=-105.9378, lat::AbstractFloat=35.6870; color: end # Plotly map layout -function plotly_layout(lonc::Number=-105.9378, latc::Number=35.6870, zoom::Number=4; paper_bgcolor::AbstractString="#FFF", width::Union{Nothing,Int}=nothing, height::Union{Nothing,Int}=nothing, title::AbstractString="", style="mapbox://styles/mapbox/satellite-streets-v12", mapbox_token=NMFk.mapbox_token) +function plotly_layout(lonc::Number=-105.9378, latc::Number=35.6870, zoom::Number=4; paper_bgcolor::AbstractString="white", width::Union{Nothing,Int}=nothing, height::Union{Nothing,Int}=nothing, title::AbstractString="", font_size::Number=14, font_color="black", style="mapbox://styles/mapbox/satellite-streets-v12", mapbox_token=NMFk.mapbox_token) layout = PlotlyJS.Layout( margin = PlotlyJS.attr(r=0, t=0, b=0, l=0), title = title, autosize = true, width = width, height = height, + legend = PlotlyJS.attr(; title_text=title, title_font_size=font_size, itemsizing="constant", font=PlotlyJS.attr(size=font_size, color=font_color), bgcolor=paper_bgcolor), paper_bgcolor = paper_bgcolor, mapbox = PlotlyJS.attr( accesstoken = mapbox_token, @@ -398,4 +410,15 @@ function plotly_layout(lonc::Number=-105.9378, latc::Number=35.6870, zoom::Numbe ) ) return layout +end + +function plotly_title_length(title::AbstractString, length::Number) + if length <= 0 + return title + else + title_vector = split(title, ' ') + pushfirst!(title_vector, repeat(" ", length)) # adding nonbreaking spaces to control the colorbar size/position + title_adjusted = join(title_vector, "
") + return title_adjusted + end end \ No newline at end of file diff --git a/src/NMFkPostprocess.jl b/src/NMFkPostprocess.jl index e43f3fe..cd35040 100644 --- a/src/NMFkPostprocess.jl +++ b/src/NMFkPostprocess.jl @@ -218,7 +218,7 @@ function postprocess(krange::Union{AbstractRange{Int},AbstractVector{Int64},Inte resultdir::AbstractString=".", figuredir::AbstractString=resultdir, Wcasefilename::AbstractString="locations", Hcasefilename::AbstractString="attributes", Wtypes::AbstractVector=[], Htypes::AbstractVector=[], - Wcolors=NMFk.colors, Hcolors=NMFk.colors, background_color="black", + Wcolors=NMFk.colors, Hcolors=NMFk.colors, background_color="white", createdendrogramsonly::Bool=false, createplots::Bool=!createdendrogramsonly, createbiplots::Bool=createplots, Wbiplotlabel::Bool=!(length(Wnames) > 20), Hbiplotlabel::Bool=!(length(Hnames) > 20), adjustbiplotlabel::Bool=true, biplotlabel::Symbol=:none, biplotcolor::Symbol=:WH, @@ -501,20 +501,25 @@ function postprocess(krange::Union{AbstractRange{Int},AbstractVector{Int64},Inte end cs = sortperm(chnew) if createplots - xticks = ["S$i" for i=1:k] - yticks = ["$(Hnames[i]) $(chnew[i])" for i=1:length(chnew)] - NMFk.plotmatrix(Hm; filename="$figuredir/$(Hcasefilename)-$(k)-original.$(plotmatrixformat)", xticks=xticks, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) - NMFk.plotmatrix(Hm[:,signalmap]; filename="$figuredir/$(Hcasefilename)-$(k)-labeled.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) - if length(Htypes) > 0 - yticks = ["$(Hnametypes[i]) $(chnew[i])" for i=1:length(chnew)] - NMFk.plotmatrix(Hm[:,signalmap]; filename="$figuredir/$(Hcasefilename)-$(k)-labeled-types.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) + if length(chnew) >= 100 + @warn("H ($(Hcasefilename)) matrix has too many attributes to plot as a matrix!") + else + xticks = ["S$i" for i=1:k] + yticks = ["$(Hnames[i]) $(chnew[i])" for i=1:length(chnew)] + NMFk.plotmatrix(Hm; filename="$figuredir/$(Hcasefilename)-$(k)-original.$(plotmatrixformat)", xticks=xticks, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) + NMFk.plotmatrix(Hm[:,signalmap]; filename="$figuredir/$(Hcasefilename)-$(k)-labeled.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) + if length(Htypes) > 0 + yticks = ["$(Hnametypes[i]) $(chnew[i])" for i=1:length(chnew)] + NMFk.plotmatrix(Hm[:,signalmap]; filename="$figuredir/$(Hcasefilename)-$(k)-labeled-types.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) + end + NMFk.plotmatrix(Hm[cs,signalmap]; filename="$figuredir/$(Hcasefilename)-$(k)-labeled-sorted.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) end - NMFk.plotmatrix(Hm[cs,signalmap]; filename="$figuredir/$(Hcasefilename)-$(k)-labeled-sorted.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Hmatrix_vsize, hsize=Hmatrix_hsize, background_color=background_color, quiet=quiet) if plottimeseries == :H || plottimeseries == :WH Mads.plotseries(Hm, "$figuredir/$(Hcasefilename)-$(k)-timeseries.$(plotseriesformat)"; xaxis=Hnames) end end - if createdendrogramsonly || createplots + if (createdendrogramsonly || createplots) && length(chnew) < 100 + @info("Dendrogram ploting ...") try yticks = ["$(Hnames[cs][i]) $(chnew[cs][i])" for i=1:length(chnew)] NMFk.plotdendrogram(Hm[cs,signalmap]; filename="$figuredir/$(Hcasefilename)-$(k)-labeled-sorted-dendrogram.$(plotmatrixformat)", metricheat=nothing, xticks=clusterlabels, yticks=yticks, minor_label_font_size=Hmatrix_font_size, vsize=Hdendrogram_vsize, hsize=Hdendrogram_hsize, background_color=background_color, quiet=quiet) @@ -613,31 +618,36 @@ function postprocess(krange::Union{AbstractRange{Int},AbstractVector{Int64},Inte end cs = sortperm(cwnew) if createplots - xticks = ["S$i" for i=1:k] - yticks = ["$(Wnames[i]) $(cw[i])" for i=1:length(cw)] - NMFk.plotmatrix(Wm; filename="$figuredir/$(Wcasefilename)-$(k)-original.$(plotmatrixformat)", xticks=xticks, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color) - # sorted by Wa magnitude - # ws = sortperm(vec(sum(Wa; dims=1)); rev=true) - # NMFk.plotmatrix(Wm[:,ws]; filename="$figuredir/$(Wcasefilename)-$(k)-original-sorted.$(plotmatrixformat)", xticks=["S$i" for i=1:k], yticks=["$(Wnames[i]) $(cw[i])" for i=1:length(cw)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) - cws = sortperm(cw) - yticks = ["$(Wnames[cws][i]) $(cw[cws][i])" for i=1:length(cw)] - NMFk.plotmatrix(Wm[cws,:]; filename="$figuredir/$(Wcasefilename)-$(k)-original-sorted.$(plotmatrixformat)", xticks=xticks, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color, quiet=quiet) - yticks = ["$(Wnames[i]) $(cwnew[i])" for i=1:length(cwnew)] - NMFk.plotmatrix(Wm[:,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-remappped.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color, quiet=quiet) - if length(Wtypes) > 0 - yticks = ["$(Wnametypes[i]) $(cwnew[i])" for i=1:length(cwnew)] - NMFk.plotmatrix(Wm[:,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-remappped-types.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, quiet=quiet) + if length(cw) >= 100 + @warn("W ($(Wcasefilename)) matrix has too many attributes to plot as a matrix!") + else + xticks = ["S$i" for i=1:k] + yticks = ["$(Wnames[i]) $(cw[i])" for i=1:length(cw)] + NMFk.plotmatrix(Wm; filename="$figuredir/$(Wcasefilename)-$(k)-original.$(plotmatrixformat)", xticks=xticks, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color) + # sorted by Wa magnitude + # ws = sortperm(vec(sum(Wa; dims=1)); rev=true) + # NMFk.plotmatrix(Wm[:,ws]; filename="$figuredir/$(Wcasefilename)-$(k)-original-sorted.$(plotmatrixformat)", xticks=["S$i" for i=1:k], yticks=["$(Wnames[i]) $(cw[i])" for i=1:length(cw)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) + cws = sortperm(cw) + yticks = ["$(Wnames[cws][i]) $(cw[cws][i])" for i=1:length(cw)] + NMFk.plotmatrix(Wm[cws,:]; filename="$figuredir/$(Wcasefilename)-$(k)-original-sorted.$(plotmatrixformat)", xticks=xticks, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color, quiet=quiet) + yticks = ["$(Wnames[i]) $(cwnew[i])" for i=1:length(cwnew)] + NMFk.plotmatrix(Wm[:,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-remappped.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color, quiet=quiet) + if length(Wtypes) > 0 + yticks = ["$(Wnametypes[i]) $(cwnew[i])" for i=1:length(cwnew)] + NMFk.plotmatrix(Wm[:,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-remappped-types.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Hmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, quiet=quiet) + end + yticks = ["$(Wnames[cs][i]) $(cwnew[cs][i])" for i=1:length(cwnew)] + NMFk.plotmatrix(Wm[cs,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-remappped-sorted.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color, quiet=quiet) + # NMFk.plotmatrix(Wa./sum(Wa; dims=1); filename="$figuredir/$(Wcasefilename)-$(k)-sum.$(plotmatrixformat)", xticks=["S$i" for i=1:k], yticks=["$(Wnames[i]) $(cw[i])" for i=1:length(cols)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) + # NMFk.plotmatrix((Wa./sum(Wa; dims=1))[cs,:]; filename="$figuredir/$(Wcasefilename)-$(k)-sum2.$(plotmatrixformat)", xticks=["S$i" for i=1:k], yticks=["$(Wnames[cs][i]) $(cw[cs][i])" for i=1:length(cols)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) + # NMFk.plotmatrix((Wa ./ sum(Wa; dims=1))[cs,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-labeled-sorted-sumrows.$(plotmatrixformat)", xticks=clusterlabels, yticks=["$(Wnames[cs][i]) $(cwnew[cs][i])" for i=1:length(cwnew)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) end - yticks = ["$(Wnames[cs][i]) $(cwnew[cs][i])" for i=1:length(cwnew)] - NMFk.plotmatrix(Wm[cs,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-remappped-sorted.$(plotmatrixformat)", xticks=clusterlabels, yticks=yticks, colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize, background_color=background_color, quiet=quiet) - # NMFk.plotmatrix(Wa./sum(Wa; dims=1); filename="$figuredir/$(Wcasefilename)-$(k)-sum.$(plotmatrixformat)", xticks=["S$i" for i=1:k], yticks=["$(Wnames[i]) $(cw[i])" for i=1:length(cols)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) - # NMFk.plotmatrix((Wa./sum(Wa; dims=1))[cs,:]; filename="$figuredir/$(Wcasefilename)-$(k)-sum2.$(plotmatrixformat)", xticks=["S$i" for i=1:k], yticks=["$(Wnames[cs][i]) $(cw[cs][i])" for i=1:length(cols)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) - # NMFk.plotmatrix((Wa ./ sum(Wa; dims=1))[cs,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-labeled-sorted-sumrows.$(plotmatrixformat)", xticks=clusterlabels, yticks=["$(Wnames[cs][i]) $(cwnew[cs][i])" for i=1:length(cwnew)], colorkey=true, minor_label_font_size=Wmatrix_font_size, vsize=Wmatrix_vsize, hsize=Wmatrix_hsize) if plottimeseries == :W || plottimeseries == :WH Mads.plotseries(Wa ./ maximum(Wa), "$figuredir/$(Wcasefilename)-$(k)-timeseries.$(plotseriesformat)"; xaxis=Wnames) end end - if createdendrogramsonly || createplots + if (createdendrogramsonly || createplots) && length(cw) < 100 + @info("Dendrogram ploting ...") try yticks = ["$(Wnames[cs][i]) $(cwnew[cs][i])" for i=1:length(cwnew)] NMFk.plotdendrogram(Wm[cs,signalmap]; filename="$figuredir/$(Wcasefilename)-$(k)-remappped-sorted-dendrogram.$(plotmatrixformat)", metricheat=nothing, xticks=clusterlabels, yticks=yticks, minor_label_font_size=Wmatrix_font_size, vsize=Wdendrogram_vsize, hsize=Wdendrogram_hsize, background_color=background_color, quiet=quiet)