Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastSmoothEmd and style fixes #149

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
93ea66c
added smooth c++ file
andeElliott Jun 1, 2018
d4d7d84
fixed a few annoying bugs in the implementation.
andeElliott Jun 1, 2018
92d2abd
Modifications to add the c code into the function
andeElliott Jun 3, 2018
1dda134
removed 1 if statement out of the loop
andeElliott Jun 3, 2018
5ef89bd
added speed test for smooth version
andeElliott Jun 5, 2018
4496097
removed some of the print messages
andeElliott Jun 18, 2018
80cd6df
added the new methods to the namespace for exports
andeElliott Jun 18, 2018
c0a28e8
commented and removing unneeded code
andeElliott Nov 14, 2019
87bd247
Merge branch 'master' into fastSmoothEMD
andeElliott Nov 14, 2019
3e09482
figuring out what is wrong
andeElliott Nov 14, 2019
87d00b7
removing changes to see if it helps
andeElliott Nov 14, 2019
761898d
Inital working version of fastEmdSmooth
andeElliott Nov 20, 2019
b7a6674
fixed small bug
andeElliott Nov 20, 2019
6b64eb2
missed a few internal paths used for testing
andeElliott Nov 20, 2019
40dddeb
adding the V2 to namespace
andeElliott Nov 20, 2019
b19b6fe
updated versions of wrapper files
andeElliott Nov 20, 2019
15ee86b
stable version
andeElliott Nov 20, 2019
d959a79
updated iupdated
andeElliott Nov 21, 2019
c7b1cc2
updated test
andeElliott Nov 21, 2019
b5bc0a8
updated tests
andeElliott Nov 21, 2019
0cec4ed
Merge branch 'newBranch' into fastSmoothEMD
andeElliott Nov 21, 2019
5ed553e
added old failure case. as a test
andeElliott Nov 22, 2019
cac3bab
first real fast version
andeElliott Nov 22, 2019
deae045
working partially cleaned version
andeElliott Nov 22, 2019
f4c816a
current working version
andeElliott Nov 25, 2019
dc7e53d
updated file naming
andeElliott Nov 25, 2019
9c99088
new fast smooth file
andeElliott Nov 25, 2019
10d7de8
changed name of old version
andeElliott Nov 25, 2019
cc76a3b
removed sourceCpp
andeElliott Nov 25, 2019
aa1f6e8
fixed introduced bug
andeElliott Nov 25, 2019
6f7a515
updated the code
andeElliott Nov 26, 2019
8000fa1
replace missing file
andeElliott Nov 26, 2019
1f5d9d7
Formatting and whitespace
ots22 Apr 17, 2020
91c9561
Formatting
ots22 Apr 17, 2020
9151e52
Local for-loop index
ots22 Apr 17, 2020
b35563e
Combine some conditional cases in get_segment
ots22 Apr 17, 2020
0ca7c89
Combine cases for handling the leftmost segments (NetEmdSmoothV2)
ots22 Apr 17, 2020
c36c3f6
Remove unused function
ots22 Apr 17, 2020
4af238d
Rename loop counters
ots22 Apr 17, 2020
3feb0ae
added tests
andeElliott Apr 17, 2020
a398920
Iterable class to interleave two sequences in the required way
ots22 Apr 20, 2020
c302c43
added fast smooth header
andeElliott Apr 21, 2020
4b57f15
Merge branch 'fastSmoothEMD-review' of https://github.com/alan-turing…
andeElliott Apr 21, 2020
89bba30
updated tests
andeElliott Apr 21, 2020
5436310
remove browser
andeElliott Apr 21, 2020
ce8cbb3
Merge branch 'master' into fastSmoothEMD-review
andeElliott Apr 21, 2020
5c4dd42
Iterate over overlapping intervals
ots22 Apr 22, 2020
77b9338
Move overlapping segment iterator into fastSmoothV2.h
ots22 Apr 22, 2020
72de9ea
Use NumericVectors in tests
ots22 Apr 22, 2020
8e12200
Use overlapping interval iterator in NetEmdSmoothV2
ots22 Apr 22, 2020
857c91c
Small refactor of OverlappingSegments, and use for NetEmdSmoothV2
ots22 Apr 23, 2020
17ef75e
Small formatting changes
ots22 Apr 23, 2020
a67c2ce
Move begin() and end() after iterator class (fix breaking build)
ots22 Apr 23, 2020
a59cc6f
test
leospinaf Jun 23, 2020
1fd6fb7
removed the flag for sse to test if this will work on M1
andeElliott May 18, 2022
66f9f8f
attempt2 to fix the M1 issues
andeElliott May 18, 2022
dcff9a3
adding arg back in to see if it is needed
andeElliott May 18, 2022
e569025
Merge branch 'M1fix' into fastSmoothEMD-review-m1
andeElliott May 18, 2022
0a04e3b
updated Rcpp Exports
andeElliott May 18, 2022
474d895
update namespace to test if functions will export
andeElliott May 18, 2022
ebc0873
setup linting actions
jack89roberts Jun 6, 2022
1082d29
Update documentation
jack89roberts Jun 6, 2022
f44076c
move quality checks into separate workflow
jack89roberts Jun 6, 2022
61a7e01
Merge branch 'lint' of https://github.com/alan-turing-institute/netwo…
jack89roberts Jun 6, 2022
caff555
quality checks badge
jack89roberts Jun 6, 2022
7123f03
start fixing line lengths to 80 chars
jack89roberts Jun 6, 2022
ff2e549
styler
jack89roberts Jun 6, 2022
8726fe1
Update documentation
jack89roberts Jun 6, 2022
644ef11
fix line length R and tests directories
jack89roberts Jun 7, 2022
7c8055c
Merge branch 'master' into fastSmoothEMD-review
ots22 Jun 7, 2022
9c0a716
Update documentation
jack89roberts Jun 7, 2022
681106c
styler vignettes
jack89roberts Jun 7, 2022
d37bf58
Merge branch 'lint' of https://github.com/alan-turing-institute/netwo…
jack89roberts Jun 7, 2022
f11f068
Regenerated NAMESPACE and RcppExports.R after devtools::document()
ots22 Jun 7, 2022
f31de5b
vignette line length fixes
jack89roberts Jun 7, 2022
9321552
Update documentation (bot)
jack89roberts Jun 7, 2022
a3ddebc
linting fixes
jack89roberts Jun 7, 2022
c31823f
Merge branch 'lint' of https://github.com/alan-turing-institute/netwo…
jack89roberts Jun 7, 2022
1a98f23
revert breaking lint changes
jack89roberts Jun 7, 2022
2e9348f
ignore remaining lint errors where appropriate
jack89roberts Jun 7, 2022
fb0f92e
delete area_between_offset_ecmfs
jack89roberts Jun 7, 2022
d9d6f5f
update .Rbuildignore
jack89roberts Jun 7, 2022
8313127
Update documentation (bot)
jack89roberts Jun 7, 2022
13eba31
Update to renamed function in test case
ots22 Jun 8, 2022
d3ab662
Use Kahan summation in NetEmdSmoothV2
ots22 Jun 8, 2022
a543607
Remove old unused versions of fastSmooth
ots22 Jun 8, 2022
b0eb0a5
adding tests with previous version rather than integrate
andeElliott Jun 8, 2022
2abf918
Merge branch 'fastSmoothEMD-review' of github.com:alan-turing-institu…
andeElliott Jun 8, 2022
549b497
Merge branch 'lint' into fastSmoothEMD-review
jack89roberts Jun 9, 2022
2158ae5
linting
jack89roberts Jun 9, 2022
9fc4427
net_emd -> netemd throughout
jack89roberts Jun 9, 2022
de4a41a
more linting
jack89roberts Jun 9, 2022
5388779
update docs
jack89roberts Jun 9, 2022
fa187db
net_dis net_emd -> netdis netemd in file names
jack89roberts Jun 9, 2022
111bbed
styler
jack89roberts Jun 9, 2022
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
)
6 changes: 4 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ 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(netemd_smooth)
export(netemd_speed_test_smooth)
export(normalise_dhist_mass)
export(normalise_dhist_variance)
export(orbit_key)
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
)
}
10 changes: 10 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,13 @@ emd_fast_no_smoothing <- function(locations1, values1, locations2, values2) {
.Call(`_netdist_emd_fast_no_smoothing`, locations1, values1, locations2, values2)
}

#' @title
#' Compute EMD
NULL

#'
#' @export
netemd_smooth <- function(loc1, val1, binWidth1, loc2, val2, binWidth2) {
.Call(`_netdist_netemd_smooth`, loc1, val1, binWidth1, loc2, val2, binWidth2)
}

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