## ----init, include=FALSE------------------------------------------------------
library(knitr)
opts_chunk$set(warning = FALSE, message = FALSE, cache=FALSE)

## ----style, echo = FALSE, results = 'asis'------------------------------------
BiocStyle::markdown()

## ----biocBuildReport----------------------------------------------------------
library(BiocPkgTools)
head(biocBuildReport())

## ----problemPage, eval=FALSE--------------------------------------------------
# problemPage(authorPattern = "V.*Carey")

## ----problemPageDepends, eval=FALSE-------------------------------------------
# problemPage(dependsOn = "limma")

## ----biocDownloadStats--------------------------------------------------------
stats <- try(biocDownloadStats(), silent=TRUE)
if (!inherits(stats, "try-error")) {
    head(stats)
} else {
    message("Download stats not available at this time.")
}

## ----anacondaDownloadStats----------------------------------------------------
head(anacondaDownloadStats())

## ----biocPkgList--------------------------------------------------------------
bpi = biocPkgList()
colnames(bpi)

## ----biocPkgListHead----------------------------------------------------------
head(bpi)

## ----GEOqueryImports----------------------------------------------------------
require(dplyr)
bpi = biocPkgList()
bpi |> 
    filter(Package=="GEOquery") |>
    pull(importsMe) |>
    unlist()

## ----biocExplore--------------------------------------------------------------
biocExplore()

## ----dependencyGraph----------------------------------------------------------
dep_df = buildPkgDependencyDataFrame()
g = buildPkgDependencyIgraph(dep_df)
g
library(igraph)
head(V(g))
head(E(g))

## ----visNetworkIgraph---------------------------------------------------------
igraph_network = buildPkgDependencyIgraph(buildPkgDependencyDataFrame())

## ----geoquerySubgraph---------------------------------------------------------
igraph_geoquery_network = subgraphByDegree(igraph_network, "GEOquery")

## ----toVisNetworkData---------------------------------------------------------
library(visNetwork)
data <- toVisNetworkData(igraph_geoquery_network)

## ----visNetworkPlot-----------------------------------------------------------
visNetwork(nodes = data$nodes, edges = data$edges, height = "500px")

## ----visNetworkStabilization--------------------------------------------------
visNetwork(nodes = data$nodes, edges = data$edges, height = "500px") |>
    visPhysics(stabilization=FALSE)

## ----visNetworkArrows---------------------------------------------------------
data$edges$color='lightblue'
data$edges[data$edges$edgetype=='Imports','color']= 'red'
data$edges[data$edges$edgetype=='Depends','color']= 'green'

visNetwork(nodes = data$nodes, edges = data$edges, height = "500px") |>
    visEdges(arrows='from') 

## ----visNetworkLegend---------------------------------------------------------
ledges <- data.frame(color = c("green", "lightblue", "red"),
  label = c("Depends", "Suggests", "Imports"), arrows =c("from", "from", "from"))
visNetwork(nodes = data$nodes, edges = data$edges, height = "500px") |>
  visEdges(arrows='from') |>
  visLegend(addEdges=ledges)

## ----biocViews----------------------------------------------------------------
library(biocViews)
data(biocViewsVocab)
biocViewsVocab
library(igraph)
g = graph_from_graphnel(biocViewsVocab)
library(visNetwork)
gv <- toVisNetworkData(g)
visNetwork(gv$nodes, gv$edges, width="100%") |>
    visIgraphLayout(layout = "layout_as_tree", circular=TRUE) |>
    visNodes(size=20) |>
    visPhysics(stabilization=FALSE)

## ----dependencyBurden---------------------------------------------------------

depdf <- buildPkgDependencyDataFrame(repo=c("BioCsoft", "CRAN"),
                                     dependencies=c("Depends", "Imports"))
dim(depdf)
head(depdf)  # too big to show all

## ----pkgDepMetrics------------------------------------------------------------
pkgDepMetrics("BiocPkgTools", depdf)

## ----pkgDepImports------------------------------------------------------------
imp <- pkgDepImports("BiocPkgTools")
imp |> filter(pkg == "DT")

## ----demoorc------------------------------------------------------------------
inst = rownames(installed.packages())
cands = c("devtools", "evaluate", "ggplot2", "GEOquery", "gert", "utils")
totry = intersect(cands, inst)
oids = get_cre_orcids(totry)
oids

## ----lktab,eval=FALSE---------------------------------------------------------
# orcid_table(oids)

## ----sessionInfo--------------------------------------------------------------
sessionInfo()

