Elaborate a report on the dependency burden of a given package.

pkgDepMetrics(pkg, depdf)

Arguments

pkg

character() name of the package for which we want to obtain metrics on its dependency burden.

depdf

a tidy data frame with package dependency information obtained through the function buildPkgDependencyDataFrame.

Value

A tidy data frame with different metrics on the package dependency burden. More concretely, the following columns:

  • ImportedAndUsed: number of functionality calls imported and used in the package.

  • Exported: number of functionality calls exported by the dependency.

  • Usage: (ImportedAndUsedx 100) / Exported. This value provides an estimate of what fraction of the functionality of the dependency is actually used in the given package.

  • DepOverlap: Similarity between the dependency graph structure of the given package and the one of the dependency in the corresponding row, estimated as the Jaccard index between the two sets of vertices of the corresponding graphs. Its values goes between 0 and 1, where 0 indicates that no dependency is shared, while 1 indicates that the given package and the corresponding dependency depend on an identical subset of packages.

  • DepGainIfExcluded: The 'dependency gain' (decrease in the total number of dependencies) that would be obtained if this package was excluded from the list of direct dependencies.

The reported information is ordered by the Usage column to facilitate the identification of dependencies for which the analyzed package is using a small fraction of their functionality and therefore, it could be easier remove them. To aid in that decision, the column DepOverlap reports the overlap of the dependency graph of each dependency with the one of the analyzed package. Here a value above, e.g., 0.5, could, albeit not necessarily, imply that removing that dependency could substantially lighten the dependency burden of the analyzed package.

An NA value in the ImportedAndUsed column indicates that the function pkgDepMetrics() could not identify what functionality calls in the analyzed package are made to the dependency.

Author

Robert Castelo

Charlotte Soneson

Examples

depdf <- buildPkgDependencyDataFrame(
  dependencies=c("Depends", "Imports"), 
  repo=c("BioCsoft", "CRAN")
)
#> 'getOption("repos")' replaces Bioconductor standard repositories, see
#> 'help("repositories", package = "BiocManager")' for details.
#> Replacement repositories:
#>     CRAN: https://cloud.r-project.org
pkgDepMetrics('BiocPkgTools', depdf)
#>               ImportedAndUsed Exported Usage DepOverlap DepGainIfExcluded
#> graph                       1      116  0.86       0.06                 0
#> utils                       2      228  0.88       0.01                 0
#> rlang                       4      438  0.91       0.02                 0
#> igraph                      9      800  1.12       0.11                 4
#> RBGL                        1       77  1.30       0.07                 0
#> htmltools                   1       76  1.32       0.08                 0
#> xml2                        1       66  1.52       0.01                 0
#> tools                       2      120  1.67       0.01                 0
#> stringr                     1       59  1.69       0.11                 0
#> tibble                      1       45  2.22       0.12                 0
#> DT                          1       42  2.38       0.40                 5
#> magrittr                    1       42  2.38       0.01                 0
#> rvest                       1       40  2.50       0.29                 2
#> dplyr                       8      292  2.74       0.19                 0
#> rorcid                      1       32  3.12       0.31                 8
#> httr                        5       91  5.49       0.09                 0
#> htmlwidgets                 1       14  7.14       0.35                 0
#> jsonlite                    2       23  8.70       0.01                 0
#> gh                          1       11  9.09       0.19                 4
#> BiocFileCache               4       29 13.79       0.41                 8
#> BiocManager                 3        6 50.00       0.02                 0
#> biocViews                  NA       31    NA       0.14                 6
#> readr                      NA      115    NA       0.25                 6