Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
^appveyor\.yml$
^doc$
^Meta$
^\.github$
^\.lintr
^docs$
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
with:
extra-packages: |
any::devtools
any::covr

- name: Document
run: devtools::document()
Expand All @@ -62,14 +61,10 @@ jobs:
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 commit -m "Update documentation (bot)" || echo "No changes to commit"
git pull --ff-only
git push origin

- name: Check package
- name: Check package with devtools
run: devtools::check()
shell: Rscript {0}

- name: Check coverage
run: covr::codecov(quiet = FALSE)
shell: Rscript {0}
40 changes: 40 additions & 0 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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]

name: Quality checks

jobs:
lint-project:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@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::covr
any::lintr
any::styler

- name: Styler
run: styler::style_pkg(filetype = c('R', 'Rprofile', 'Rmd'), dry='fail')
shell: Rscript {0}

- name: Lintr
run: lintr::lint_package()
shell: Rscript {0}

- name: Coverage
run: covr::codecov(quiet = FALSE)
shell: Rscript {0}
7 changes: 7 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error_on_lint: TRUE
linters: with_defaults(
open_curly_linter = NULL,
closed_curly_linter = NULL,
spaces_left_parentheses_linter = NULL,
seq_linter = NULL
)
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ export(min_emd_exhaustive)
export(min_emd_optimise)
export(min_emd_optimise_fast)
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_plot)
export(netdis_subtract_exp_counts)
export(netdis_uptok)
export(netemd.plot)
export(netemd_many_to_many)
export(netemd_one_to_one)
export(netemd_plot)
export(netemd_single_pair)
export(normalise_dhist_mass)
export(normalise_dhist_variance)
Expand Down
110 changes: 81 additions & 29 deletions R/PlottingFunctions.R
Original file line number Diff line number Diff line change
@@ -1,56 +1,108 @@

#' Heatmap of Netdis many-to-many comparisons
#'
#' Provides a heatmap and dendrogram for the network comparisons via \code{pheatmap}.
#'
#' 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 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 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}.
#'
#' @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)
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)

legend1 <- seq(min(adjmat), max(adjmat), length.out = 5)
levels1 <- round(legend1, digits = 2)
pheatmap::pheatmap(
mat = stats::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}.
#'
#' 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 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 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}.
#'
#' @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)
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)


legend1 <- seq(min(adjmat), max(adjmat), length.out = 5)
levels1 <- round(legend1, digits = 2)
pheatmap::pheatmap(
mat = stats::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
)
}
11 changes: 8 additions & 3 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ counts_from_observations <- function(features) {
}

#' @title
#' Compute Earth Mover's Distance (EMD) between two Empirical Cumulative
#' Compute Earth Mover's Distance (EMD) between two Empirical Cumulative
#' Density Functions (ECDFs)
#'
#' @param locations1 Locations for ECDF 1
Expand All @@ -22,6 +22,11 @@ counts_from_observations <- function(features) {
#'
#' @export
emd_fast_no_smoothing <- function(locations1, values1, locations2, values2) {
.Call(`_netdist_emd_fast_no_smoothing`, locations1, values1, locations2, values2)
.Call(
`_netdist_emd_fast_no_smoothing`,
locations1,
values1,
locations2,
values2
)
}

45 changes: 32 additions & 13 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@
#' }
#'
#' @format A list of \code{igraph} objects.
#' @source \strong{PPI data (EBV, HSV-1, KSHV, VZV):} Fossum E, Friedel CC, Rajagopala SV, Titz B, Baiker A, Schmidt T, et al. (2009) Evolutionarily Conserved Herpesviral Protein Interaction Networks. PLoS Pathog 5(9): e1000570. \url{https://doi.org/10.1371/journal.ppat.1000570}. Data from Table S2 in the supporting information.
#' @source \strong{PPI data (ECL):} Peregrín-Alvarez JM, Xiong X, Su C, Parkinson J (2009) The Modular Organization of Protein Interactions in Escherichia coli. PLoS Comput Biol 5(10): e1000523. \url{https://doi.org/10.1371/journal.pcbi.1000523}
#' @source \strong{Taxonomy ground truth:} NCBI taxonomy database. \url{https://www.ncbi.nlm.nih.gov/taxonomy}
#' @source \strong{PPI data (EBV, HSV-1, KSHV, VZV):} Fossum E, Friedel CC,
#' Rajagopala SV, Titz B, Baiker A, Schmidt T, et al. (2009) Evolutionarily
#' Conserved Herpesviral Protein Interaction Networks. PLoS Pathog 5(9):
#' e1000570. \url{https://doi.org/10.1371/journal.ppat.1000570}. Data from Table
#' S2 in the supporting information.
#' @source \strong{PPI data (ECL):} Peregrín-Alvarez JM, Xiong X, Su C,
#' Parkinson J (2009) The Modular Organization of Protein Interactions in
#' Escherichia coli. PLoS Comput Biol 5(10): e1000523.
#' \url{https://doi.org/10.1371/journal.pcbi.1000523}
#' @source \strong{Taxonomy ground truth:} NCBI taxonomy database.
#' \url{https://www.ncbi.nlm.nih.gov/taxonomy}
#' @encoding UTF-8
"virusppi"

Expand All @@ -47,18 +55,29 @@


#' 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.
#'
#' 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.
#' \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).
#'
#'
#' @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"

Loading