---
title: "Dependency graph" 
author: "<h4>Authors: <i>`r auths <- eval(parse(text = gsub('person','c',read.dcf('../DESCRIPTION', fields = 'Authors@R'))));paste(auths[names(auths)=='given'],auths[names(auths)=='family'], collapse = ', ')`</i></h4>" 
date: "<h4>Vignette updated: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
output:
  rmarkdown::html_vignette
vignette: >
    %\VignetteIndexEntry{depgraph} 
    %\usepackage[utf8]{inputenc}
    %\VignetteEngine{knitr::rmarkdown}
---

```{r}
library(data.table)
```

A dependency graph for all GitHub repos that use the `rworkflows` GitHub Action.

# Create

Here is the code for creating the plot.

## Install required packages

``` r
if(!require("echodeps"))remotes::install_github("RajLabMSSM/echodeps",
                                                dependencies = TRUE)
```

## Create graph

``` r
res <- echodeps::dep_graph(pkg = "rworkflows",
                           method_seed = "github",
                           exclude = c("neurogenomics_rworkflows",
                                       "neurogenomics_r_workflows"),
                           #node_size = "total_downloads", 
                           reverse = TRUE,
                           save_path = here::here("reports","rworkflows_depgraph.html")) 
```

## Save data

``` r
## Save network plot as PNG
echodeps::visnet_save(res$save_path)

## Save all data and plots
saveRDS(res, here::here("reports","dep_graph_res.rds"))
```

## Count stars/clones/views

```r
knitr::kable(res$report)
```

# Show

## [rworkflow depgraph](https://github.com/neurogenomics/rworkflows/raw/master/reports/rworkflows_depgraph.png)

Hover over each node to show additional metadata.


<!-- ```{r fig.height=20, fig.width=20} -->
<!-- htmltools::includeHTML("https://github.com/neurogenomics/rworkflows/raw/master/reports/rworkflows_depgraph.html") -->

<!-- ``` -->

# Identify highly downloaded packages

Identify the CRAN/Bioc R packages with the most number of downloads. This guides which packages would be the most useful to focus on implementing `rworkflows` in.

```r
pkgs <- echogithub::r_repos_downloads(which = c("CRAN","Bioc"))

#### Get top 10 per R repository ####
pkgs_top <- pkgs[, tail(.SD, 10), by="r_repo"] 
methods::show(pkgs_top)
```

# Assess R repository usage

This demonstrates the need for using `rworkflows`, as there are 25,000 R packages that are exclusively distributes via GitHub (which may or may not have code/documentation checks).

```r
r_repos_res <- echogithub::r_repos(save_path = here::here("reports","r_repos_upset.pdf"), width=12)
```

# Session Info

<details>

```{r Session Info}
utils::sessionInfo()
```

</details>

<hr>
