Skip to content

Commit

Permalink
Merge branch 'master' into fastSmoothEMD-review
Browse files Browse the repository at this point in the history
  • Loading branch information
ots22 committed Jun 7, 2022
2 parents 474d895 + ee67bd4 commit 7c8055c
Show file tree
Hide file tree
Showing 103 changed files with 6,143 additions and 1,880 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
^data-raw$
^.travis.yml
^appveyor\.yml$
^doc$
^Meta$
75 changes: 75 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
- cron: "5 5 5 * *" # run at 05:05 on 5th day of each month

name: Build

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel'}
- {os: ubuntu-latest, r: 'devel'}
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
# on PR set branch to be able to push back, see https://github.com/actions/checkout/issues/124
- uses: actions/checkout@v2
if: github.event_name == 'pull_request'
with:
ref: ${{ github.event.pull_request.head.ref }}

- uses: actions/checkout@v2
if: github.event_name != 'pull_request'

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-tinytex@v2

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::devtools
any::covr
- name: Document
run: devtools::document()
shell: Rscript {0}

- name: Commit and push documentation changes
if: ${{ (matrix.config.os == 'ubuntu-latest') && (matrix.config.r == 'release') }}
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git add man/\* NAMESPACE
git commit -m "Update documentation" || echo "No changes to commit"
git pull --ff-only
git push origin
- name: Check package
run: devtools::check()
shell: Rscript {0}

- name: Check coverage
run: covr::codecov(quiet = FALSE)
shell: Rscript {0}
41 changes: 41 additions & 0 deletions .github/workflows/pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
release:
types: [published]

name: Website

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
*.so
*.dll
vignettes/.build.timestamp
inst/doc
doc
Meta
docs/
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

11 changes: 6 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: netdist
Title: An implementation of the NetEMD alignment-free network distance measure
Version: 0.4.9000
Version: 0.4.9100
Authors@R: person("Martin", "O'Reilly",email = "[email protected]",
role = c("aut", "cre"))
Description: An implementation of the NetEMD alignment-free network
Expand All @@ -20,14 +20,15 @@ Imports:
purrr,
lpSolve,
plyr,
dplyr,
Rcpp
pheatmap,
Rcpp,
Suggests:
dplyr,
phangorn,
testthat,
knitr,
phangorn,
rmarkdown,
roxygen2
RoxygenNote: 6.1.1
RoxygenNote: 7.2.0
VignetteBuilder: knitr
Encoding: UTF-8
Binary file added Meta/vignette.rds
Binary file not shown.
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ export(netEMDSpeedTestSmooth)
export(net_emd)
export(net_emds_for_all_graphs)
export(netdis)
export(netdis.plot)
export(netdis_centred_graphlet_counts)
export(netdis_expected_counts)
export(netdis_many_to_many)
export(netdis_one_to_many)
export(netdis_one_to_one)
export(netdis_subtract_exp_counts)
export(netdis_uptok)
export(netemd.plot)
export(netemd_many_to_many)
export(netemd_one_to_one)
export(netemd_single_pair)
export(normalise_dhist_mass)
export(normalise_dhist_variance)
export(orbit_key)
Expand Down
56 changes: 56 additions & 0 deletions R/PlottingFunctions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

#' Heatmap of Netdis many-to-many comparisons
#'
#' Provides a heatmap and dendrogram for the network comparisons via \code{pheatmap}.
#'
#' @param netdislist Default output of \code{netdis_many_to_many}.
#'
#' @param whatrow Selection of the row in \code{netdis_many_to_many$comp_spec} to be used for plotting.
#'
#' @param clustering_method Clustering method as allowed in the \code{pheatmap} function from the \code{pheatmap} package. The dendrogram will appear if \code{docluster} is TRUE (default).
#'
#' @param main Title of the plot.
#'
#' @param docluster controls the order of the rows and columns. If TRUE (default) the rows and columns will be reordered to create the dendrogram. If FALSE, then only the heatmap is drawn.
#'
#' @return Provides a heatmap and dendrogram for the network comparisons via \code{pheatmap}.
#' @export

netdis.plot <- function(netdislist,whatrow=c(1,2)[2],clustering_method="ward.D",main="Nedis",docluster=TRUE){
adjmat <- cross_comp_to_matrix(measure = netdislist$netdis[whatrow,], cross_comparison_spec = netdislist$comp_spec)
vnames <- rownames(adjmat)

legend1 <- seq(min(adjmat),max(adjmat),length.out = 5)
levels1 <- round(legend1,digits = 2)
pheatmap::pheatmap(mat = as.dist(adjmat),cluster_rows = docluster,cluster_cols = docluster,clustering_method = clustering_method,angle_col=45,main = main,treeheight_row = 80,labels_row = vnames,labels_col = vnames,display_numbers = TRUE,legend_breaks = legend1,legend_labels = levels1)
}




#' Heatmap of NetEmd many-to-many comparisons
#'
#' Provides a heatmap and dendrogram for the network comparisons via \code{pheatmap}.
#'
#' @param netdislist Default output of \code{netdis_many_to_many}.
#'
#' @param whatrow Selection of the row in \code{netdis_many_to_many$comp_spec} to be used for plotting.
#'
#' @param clustering_method Clustering method as allowed in the \code{pheatmap} function from the \code{pheatmap} package. The dendrogram will appear if \code{docluster} is TRUE (default).
#'
#' @param main Title of the plot.
#'
#' @param docluster controls the order of the rows and columns. If TRUE (default) the rows and columns will be reordered to create the dendrogram. If FALSE, then only the heatmap is drawn.
#'
#' @return Provides a heat map and dendrogram for the network comparisons via \code{pheatmap}.
#' @export

netemd.plot <- function(netemdlist,clustering_method="ward.D",main="NetEmd",docluster=TRUE){
adjmat <- cross_comp_to_matrix(measure = netemdlist$netemds, cross_comparison_spec = netemdlist$comp_spec)
vnames <- rownames(adjmat)

legend1 <- seq(min(adjmat),max(adjmat),length.out = 5)
levels1 <- round(legend1,digits = 2)
pheatmap::pheatmap(mat = as.dist(adjmat),cluster_rows = docluster,cluster_cols = docluster,clustering_method = clustering_method,angle_col=45,main = main,treeheight_row = 80,labels_row = vnames,labels_col = vnames,display_numbers = TRUE,legend_breaks = legend1,legend_labels = levels1)

}
21 changes: 21 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,24 @@
#' @source \strong{Taxonomy ground truth:} NCBI taxonomy database. \url{https://www.ncbi.nlm.nih.gov/taxonomy}
#' @encoding UTF-8
"virusppi"





#' World trade networks from 1985–2014
#'
#' The world trade data set consists of a small sample of world trade networks for the years 2001-2014, and pre-computed subgraph counts of a larger set of world trade networks (1985–2014). The world trade networks are based on the data set from [Feenstra et al., 2005] for the years 1962- 2000 and on the United Nations division COMTRADE [Division, 2015] for the years 2001-2014.
#'
#' \itemize{
#' \item wtnets: List of \code{igraph} objects providing the world trade networks from 2001–2014.
#' \item Counts: Pre-computed graphlet counts for the world trade networks in the years 1985-2014.
#' }
#'
#' @format A list of two elements. The first element, 'wtnets', is a list of \code{igraph} objects providing a small sample of world trade networks from 2001–2014. The second element, 'Counts', is a list of pre-computed subgraph counts of world trade networks in the years 1985-2014.
#' @source \strong{World trade networks:}. United nations commodity trade statistics database (UN comtrade). http://comtrade.un.org/, 2015.
#' @source \strong{Subgraph Counts:} Feenstra RC,Lipsey RE, Deng H, Ma AC, and Mo H. (2005) World trade flows: 1962-2000. Technical report, National Bureau of Economic Research. (See also https://cid.econ.ucdavis.edu/wix.html).
#'
#' @encoding UTF-8
"worldtradesub"

4 changes: 2 additions & 2 deletions R/dhist.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ is_dhist <- function(x, fast_check = TRUE) {
return(has_class_attr)
}
# Otherwise check structure
has_locations <- purrr::contains(attr(x, "name"), "locations")
has_masses <- purrr::contains(attr(x, "name"), "masses")
has_locations <- purrr::has_element(attr(x, "name"), "locations")
has_masses <- purrr::has_element(attr(x, "name"), "masses")
# Require list with correct class and presence of 1D numeric vector named
# elements "locations" and "masses"
return(has_class_attr
Expand Down
1 change: 1 addition & 0 deletions R/graph_binning.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
binned_densities_adaptive <- function(densities,
min_counts_per_interval,
num_intervals) {
if( length(densities) < min_counts_per_interval) min_counts_per_interval <- length(densities)
breaks <- adaptive_breaks(densities,
min_count = min_counts_per_interval,
breaks = num_intervals
Expand Down
Loading

0 comments on commit 7c8055c

Please sign in to comment.