% if(n_total > 0) { %>
Dependency plot
<% tmp_file = tempfile(fileext = ".png")
if(nrow(downstream_tb) > 0) {
png(tmp_file, width = 1200*1.5, height = 500*1.5, res = 72*2)
l = df$package == pkg$package
repo = ifelse(grepl("bioconductor", df$repository), "Bioconductor", "CRAN")
color = ifelse(l, "highlight", "others")
suppressMessages(suppressWarnings({
p1 = ggplot2::ggplot(df, ggplot2::aes(n_downstream, heaviness_on_downstream, pch = repo, color = color, label = ifelse(l, df$package, ""))) +
ggplot2::geom_point() +
ggplot2::scale_color_manual(values = c("highlight" = "red", "others" = "grey")) +
ggplot2::scale_shape_manual(values = c("Bioconductor" = 16, "CRAN" = 4)) +
ggplot2::scale_x_continuous(trans='log10') +
ggrepel::geom_text_repel(min.segment.length = 0, box.padding = 0.5, max.overlaps = Inf, show.legend = FALSE, size =3) +
ggplot2::labs(x = "Number of downstream packages", y = "Heaviness") +
ggplot2::ggtitle("Heaviness on downstream packages for all CRAN/Bioconductor packages")
p2 = ggplot2::ggplot(mapping = ggplot2::aes(all_heaviness)) + geom_histogram() +
ggplot2::labs(x = "Heaviness on downstream packages", y = "Frequency") +
ggplot2::ggtitle(qq("Histogram of heaviness of '@{pkg$package}' on its downstream packages"))
print(cowplot::plot_grid(p1, p2, rel_widths = c(1.2, 1)))
}))
dev.off()
} else {
png(tmp_file, width = 600*1.5, height = 500*1.5, res = 72*2)
l = df$package == pkg$package
repo = ifelse(grepl("bioconductor", df$repository), "Bioconductor", "CRAN")
color = ifelse(l, "highlight", "others")
suppressWarnings({
p1 = ggplot2::ggplot(df, ggplot2::aes(n_downstream, heaviness_on_downstream, pch = repo, color = color, label = ifelse(l, df$package, ""))) +
ggplot2::geom_point() +
ggplot2::scale_color_manual(values = c("highlight" = "red", "others" = "grey")) +
ggplot2::scale_shape_manual(values = c("Bioconductor" = 16, "CRAN" = 4)) +
ggplot2::scale_x_continuous(trans='log10') +
ggrepel::geom_text_repel(min.segment.length = 0, box.padding = 0.5, max.overlaps = Inf, show.legend = FALSE, size =3) +
ggplot2::labs(x = "Number of downstream packages", y = "Heaviness") +
ggplot2::ggtitle("Heaviness on downstream packages for all CRAN/Bioconductor packages")
ggplot2:::print.ggplot(p1)
})
dev.off()
}
%>
<%= img(tmp_file, style="height:500px")%>
<% file.remove(tmp_file) %>
In total, <%=pkg$package%> has <%=n_total%> downstream dependency packages. Only <%=n_used%> downstream packages with heaviness on <%=pkg$package%> larger than 10
<% if( !( (min_depth == 0 && max_depth == 0) || (min_depth == global_min_depth && max_depth == global_max_depth) ) ) { %>
also with dependency path depth within [<%=min_depth%>, <%=max_depth%>]
,
<% } %>
are listed in the following table.
Dependency path: the shortest path from <%=pkg$package%> to a downstream package in the global dependency graph. The form of A→
kB means package A contributes a direct heaviness of k on package B.
Heaviness of <%=pkg$package%> on downstream package: Denote $n_{1k}$ as the number of strong dependencies of the downstream package. Since <%=pkg$package%> can affect the downstream pacakge in an indirect manner, we recalculate the global dependency relations for all packages after moving <%=pkg$package%> to all its child packages' Suggests
. Then we denote $n_{2k}$
as the number of strong dependencies of the downstream pacakge in the reduced dependency graph. The heaviness from <%=pkg$package%> on that downstream pacakge is calculated as $n_{1k} - n_{2k}$.
The full table can be obtained by downstream_dependency('<%=pkg$package%>')
.
Depth = @{names(depth_tb)[i]}: @{strrep(" ", max(1, round(depth_tb[i]/max(depth_tb)*20)))} @{depth_tb[i]} path@{ifelse(depth_tb[i] == 1, "", "s")}') } %> <%=kable(depth_html_tb, format = "html", row.names = FALSE, escape = FALSE, table.attr = "id='depth-table'")%>
Dependency paths in the table are merged into the following graph with <%=n_nodes%> nodes and <%=nrow(nt)%> edges. <% if(!(min_depth == global_min_depth && max_depth == global_max_depth)) { %> Dependency depth ranges between <%=min_depth%> and <%=max_depth%>. <% } %> <% if(n_nodes <= 30) { %> Reset graph | Vertical layout <% } else { %> Reset graph <% } %>
<% knee_finder2 = function (x) { if(length(x) < 2) { return(c(NA, NA)) } y = sort(x) x = seq_along(y) n = length(x) a = (y[n] - y[1])/(x[n] - x[1]) b = y[1] - a * x[1] d = a * x + b - y x1 = x[which.min(d)] x2 = max(x[d >= max(d) - diff(range(d))*0.01]) if (all(d >= 0)) x1 = NA if (all(d <= 0)) x2 = NA return(c(x1, x2)) } betweenness = sort(nt[, "betweenness"]) ind = knee_finder2(betweenness) if(is.na(ind[2])) { betweenness_cutoff = 9999999999 } else { betweenness_cutoff = betweenness[ind[2]] if(betweenness_cutoff/(min(betweenness)+2) < 3) { betweenness_cutoff = 9999999999 } } # if n_nodes is too high, > 500, child nodes are grouped if(n_nodes > 500) { l = !nt[, 2] %in% nt[, 1] leaves = length(unique(nt[l, 2])) nt2 = nt[!l, , drop = FALSE] n_leaves = tapply(nt[l, 2], nt[l, 1], length) n_leaves_mean_heaviness = round(tapply(nt[l, 3], nt[l, 1], mean)) n_leaves_mean_betweenness = round(tapply(nt[l, 4], nt[l, 1], mean)) l = n_leaves > 1 nt2 = rbind(nt2, data.frame(from = names(n_leaves)[l], to = paste0(names(n_leaves), ": ", n_leaves, " leaves")[l], heaviness = n_leaves_mean_heaviness[l], betweenness = n_leaves_mean_betweenness[l])) if(any(!l)) { single_leaf_parents = names(n_leaves[!l]) nt2 = rbind(nt2, nt[ nt[, 1] %in% single_leaf_parents, , drop = FALSE]) } nt = nt2 } %>Legends (if there are such):
k1
heaviness from A to B is not necessarily all passed to package C, because it might be diluted by C's other parents.In total there are <%=n_total%> downstream dependencies, but no package on which <%=pkg$package%> has heaviness larger than 10.
<% } %> <% } else { %>No downstream dependency found.
<% } %>