Skip to content

Commit

Permalink
version 1.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood authored and cran-robot committed Oct 11, 2022
1 parent 4e3f23f commit b710d62
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 34 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: dynutils
Type: Package
Title: Common Functionality for the 'dynverse' Packages
Version: 1.0.10
Version: 1.0.11
Authors@R: c(
person(
"Robrecht",
Expand All @@ -28,16 +28,16 @@ BugReports: https://github.com/dynverse/dynutils/issues
RoxygenNote: 7.2.1
Depends: R (>= 3.0.0)
Imports: assertthat, crayon, desc, dplyr, magrittr, Matrix, methods,
proxyC, purrr, Rcpp, remotes, stringr, tibble
proxyC (>= 0.3.3), purrr, Rcpp, remotes, stringr, tibble
Suggests: covr, ggplot2, hdf5r (>= 1.3.4), knitr, rmarkdown, testthat
LinkingTo: Rcpp
Encoding: UTF-8
VignetteBuilder: knitr
NeedsCompilation: yes
Packaged: 2022-09-23 04:19:47 UTC; rcannood
Packaged: 2022-10-11 10:32:40 UTC; rcannood
Author: Robrecht Cannoodt [aut, cre] (<https://orcid.org/0000-0003-3641-729X>,
rcannood),
Wouter Saelens [aut] (<https://orcid.org/0000-0002-7114-6248>, zouter)
Maintainer: Robrecht Cannoodt <rcannood@gmail.com>
Repository: CRAN
Date/Publication: 2022-09-23 04:50:03 UTC
Date/Publication: 2022-10-11 11:02:32 UTC
12 changes: 6 additions & 6 deletions MD5
@@ -1,11 +1,11 @@
01dc47de1066237723b4b980c2a50758 *DESCRIPTION
62759b17d20b9cf1f23a6ec9b7741b59 *DESCRIPTION
ef3d9f056adaa322680184035912700f *LICENSE
43a8cfbebd9b581c7f7fcb8451f7e549 *NAMESPACE
f1b5a8eee2c76519e68997f32d44e209 *NEWS.md
0ae13fab88d92acfa4f5fa07ee900a22 *NEWS.md
dcdf2491b0e62a545623862a87d55529 *R/RcppExports.R
6f7fc8ddd74f0326bf2b59a523681cf7 *R/add_class.R
93ee58dfa8e9d0165a0aadbc62cfb01a *R/assertions.R
3d9950e1017544b18c403d586e21b5ff *R/calculate_distance.R
4b065a50df4879e49ce958179446d7da *R/calculate_distance.R
d6aa6f13af04adf14f579e08fc13d984 *R/calculate_mean.R
e2b7b0caa56d6a39e5f74f05f1ba7546 *R/check_packages.R
cdbbf9a1f8aea5c2df485b414eed39ad *R/development.R
Expand All @@ -27,13 +27,13 @@ ed5a6e94e1159f1aafdcfc1c82c27d49 *R/spearman_rank_sparse.R
1e902dd0285e4faae21d79ab0bef21b8 *build/vignette.rds
4cb744174c2d40de083a580148109a16 *inst/doc/functionality.R
67a99a10f52ab86808d981449e524ff3 *inst/doc/functionality.Rmd
0a06c6493c907a0806a3fd9cfdea0d12 *inst/doc/functionality.html
600abce8be96d4b1f3c373601efe6ccb *inst/doc/functionality.html
c3db2b03d9fad3aa6837b3f565dfdebd *man/add_class.Rd
6bc340f4659bf12f836063f6dbdd2329 *man/all_in.Rd
b5ac523861808607b014847cb3797765 *man/apply_minmax_scale.Rd
64174b3e65b65ce84ce3293ae492f994 *man/apply_quantile_scale.Rd
3bef0a231eef2816e0a263a1e4a2242c *man/apply_uniform_scale.Rd
2aee4613e71cce116c03a5d95ed45b36 *man/calculate_distance.Rd
51edf5e4b58a2ff051c209e38356a1d4 *man/calculate_distance.Rd
5b35a6f332946299b91d087180993a29 *man/calculate_mean.Rd
3252699f0111548d1c5865b259fc6045 *man/check_packages.Rd
8119f54576526e375c65967172a35730 *man/deprecated.Rd
Expand Down Expand Up @@ -67,7 +67,7 @@ eab0faf9e93b86fab93ff7f4b4dc4234 *src/spearman_rank_sparse.cpp
e98edf1dd851bb968f099085613e1641 *tests/testthat.R
90070d56ee12b1460c344b2a4dd11d46 *tests/testthat/test-add_class.R
35e9b56c7825d520e904f7fefc4bc561 *tests/testthat/test-assertions.R
77862ea764c68eca8560c52543079cb4 *tests/testthat/test-calculate_distance.R
8777dca4c3bb00d087bdf1606fa16c6d *tests/testthat/test-calculate_distance.R
6361031d09fa22e6b4cc5e705e13c726 *tests/testthat/test-calculate_mean.R
dbb99d66a04da64c942eeb3d2aad76a4 *tests/testthat/test-check_packages.R
7485242237d66f602ee1126cbe4000c2 *tests/testthat/test-expand_matrix.R
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
@@ -1,6 +1,10 @@
# dynutils 1.0.11

* MINOR CHANGE: Always set `use_nan` to `TRUE`. Replace NaNs with 0 for `calculate_similarity()`.

# dynutils 1.0.10

* MINOR CHANGE: Add `use_nan` passthrough argument for proxyC.
* MINOR CHANGE: Add `use_nan` passthrough argument for `proxyC`.

# dynutils 1.0.9

Expand Down
12 changes: 6 additions & 6 deletions R/calculate_distance.R
Expand Up @@ -29,8 +29,7 @@ calculate_distance <- function(
"hamming", "kullback", "manhattan", "maximum", "canberra", "minkowski"),
margin = 1,
diag = FALSE,
drop0 = FALSE,
use_nan = FALSE
drop0 = FALSE
) {
method <- match.arg(method)
input <- .process_input_matrices(x = x, y = y, margin = margin)
Expand All @@ -47,7 +46,7 @@ calculate_distance <- function(
1 - (sim + 1) / 2
}
} else {
proxyC::dist(x = x, y = y, method = method, margin = 2, diag = diag, drop0 = drop0, use_nan = use_nan)
proxyC::dist(x = x, y = y, method = method, margin = 2, diag = diag, drop0 = drop0, use_nan = FALSE)
}

if (is.null(y)) {
Expand All @@ -70,8 +69,7 @@ calculate_similarity <- function(
margin = 1,
method = c("spearman", "pearson", "cosine"),
diag = FALSE,
drop0 = FALSE,
use_nan = FALSE
drop0 = FALSE
) {
method <- match.arg(method)
input <- .process_input_matrices(x = x, y = y, margin = margin)
Expand All @@ -89,7 +87,9 @@ calculate_similarity <- function(
method <- "correlation"
}

sim <- proxyC::simil(x = x, y = y, method = method, margin = 2, diag = diag, drop0 = drop0, use_nan = use_nan)
sim <- proxyC::simil(x = x, y = y, method = method, margin = 2, diag = diag, drop0 = drop0, use_nan = FALSE)
# set nans to 0
sim@x[is.nan(sim@x)] <- 0

# fixes due to rounding errors
if (method %in% c("pearson", "spearman", "cosine")) {
Expand Down
8 changes: 4 additions & 4 deletions inst/doc/functionality.html
Expand Up @@ -372,13 +372,13 @@ <h2>Manipulation of vectors</h2>
<div id="random_time_string-generates-a-string-very-likely-to-be-unique" class="section level3">
<h3><code>random_time_string</code>: Generates a string very likely to be unique</h3>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="fu">random_time_string</span>(<span class="st">&quot;test&quot;</span>)</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20220923_061947__test__syYeN626jT&quot;</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20221011_123239__test__syYeN626jT&quot;</span></span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="fu">random_time_string</span>(<span class="st">&quot;test&quot;</span>)</span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20220923_061947__test__e6MCnXcJM7&quot;</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20221011_123239__test__e6MCnXcJM7&quot;</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a><span class="fu">random_time_string</span>(<span class="st">&quot;test&quot;</span>)</span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20220923_061947__test__9pFJ5mxS3R&quot;</span></span></code></pre></div>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20221011_123239__test__9pFJ5mxS3R&quot;</span></span></code></pre></div>
</div>
</div>
<div id="tibble-helpers" class="section level2">
Expand Down Expand Up @@ -484,7 +484,7 @@ <h2>File helpers</h2>
<div id="safe_tempdir-create-an-empty-temporary-directory-and-return-its-path" class="section level3">
<h3><code>safe_tempdir</code>: Create an empty temporary directory and return its path</h3>
<div class="sourceCode" id="cb28"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="fu">safe_tempdir</span>(<span class="st">&quot;samson&quot;</span>)</span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;/tmp/RtmpsKiNj7/file28419731ffb2cf/samson&quot;</span></span></code></pre></div>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;/tmp/Rtmp2aL2UF/filef21d031cfe904/samson&quot;</span></span></code></pre></div>
</div>
</div>
<div id="assertion-helpers" class="section level2">
Expand Down
14 changes: 3 additions & 11 deletions man/calculate_distance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/testthat/test-calculate_distance.R
Expand Up @@ -111,11 +111,11 @@ test_that("calculate_distance works on matrices, data frames and sparse matrices
out2 <- calculate_distance(x = as.matrix(x), y = as.matrix(y), method = method)
expect_equal(nrow(out2), nrow(x))
expect_equal(ncol(out2), nrow(y))
expect_true(sum(abs(out2-out)) < 1e-10)
expect_true(sum(abs(na.omit(out2-out))) < 1e-10)

out3 <- calculate_distance(x = as.data.frame(as.matrix(x)), y = as.data.frame(as.matrix(y)), method = method)
expect_equal(nrow(out3), nrow(x))
expect_equal(ncol(out3), nrow(y))
expect_true(sum(abs(out3-out)) < 1e-10)
expect_true(sum(abs(na.omit(out3-out))) < 1e-10)
}
})

0 comments on commit b710d62

Please sign in to comment.