Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood committed Sep 22, 2023
2 parents 6c10e4c + 34de8c4 commit 7625100
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 43 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Authors@R: c(
)
)
Description:
Landmark Multi-Dimensional Scaling ('LMDS') is an extension of classical 'Torgerson MDS'.
'LMDS' aims to produce the same dimensionality reduction as `cmdscale()`, but scale
linearly with respect to the number of samples.
A fast dimensionality reduction method scaleable to large numbers of samples.
Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS,
but rather than calculating a complete distance matrix between all pairs of samples,
only the distances between a set of landmarks and the samples are calculated.
License: GPL-3
Encoding: UTF-8
Imports:
Expand All @@ -29,7 +30,7 @@ Imports:
Suggests:
Matrix,
testthat
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
Roxygen: list(markdown = TRUE)
URL: http://github.com/dynverse/lmds
BugReports: https://github.com/dynverse/lmds/issues
Expand Down
7 changes: 4 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Initial release of lmds.

* Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS.
LMDS aims to produce the same dimensionality reduction as `cmdscale()`, but scale
linearly with respect to the number of samples.
* A fast dimensionality reduction method scaleable to large numbers of samples.
Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS,
but rather than calculating a complete distance matrix between all pairs of samples,
only the distances between a set of landmarks and the samples are calculated.
4 changes: 4 additions & 0 deletions R/cmdscale_landmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#' @importFrom irlba partial_eigen
#' @importFrom dynutils scale_uniform
#'
#' @return The dimensionality reduction in the form of a `ncol(dist_2lm)` by `ndim` matrix.
#'
#' @export
#'
#' @examples
Expand Down Expand Up @@ -65,5 +67,7 @@ cmdscale_landmarks <- function(dist_2lm, ndim = 3, rescale = TRUE, ...) {
dimred <- dynutils::scale_uniform(dimred)
}

colnames(dimred) <- paste0("comp_", seq_len(ndim))

dimred
}
16 changes: 7 additions & 9 deletions R/lmds.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#' Landmark MDS
#'
#' Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical 'Torgerson' MDS.
#' LMDS scales to significantly larger data sets since it only computes the distances between
#' a set of landmarks and all samples. Has built-in support for sparse matrices.
#' A fast dimensionality reduction method scaleable to large numbers of samples.
#' Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical 'Torgerson MDS',
#' but rather than calculating a complete distance matrix between all pairs of samples,
#' only the distances between a set of landmarks and the samples are calculated.
#'
#' @inheritParams select_landmarks
#' @inheritParams cmdscale_landmarks
Expand All @@ -11,6 +12,8 @@
#'
#' @include cmdscale_landmarks.R select_landmarks.R
#'
#' @return The dimensionality reduction in the form of a `nrow(x)` by `ndim` matrix.
#'
#' @examples
#' library(Matrix)
#' x <- Matrix::rsparsematrix(1000, 1000, .01)
Expand Down Expand Up @@ -40,13 +43,8 @@ lmds <- dynutils::inherit_default_params(
)

rownames(dimred) <- rownames(x)
colnames(dimred) <- paste0("comp_", seq_len(ndim))


dimred
}
)





7 changes: 4 additions & 3 deletions R/package.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#' Landmark Multi-Dimensional Scalng
#'
#' Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS.
#' LMDS aims to produce the same dimensionality reduction as `cmdscale()`, but scale
#' linearly with respect to the number of samples.
#' A fast dimensionality reduction method scaleable to large numbers of samples.
#' Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS´,
#' but rather than calculating a complete distance matrix between all pairs of samples,
#' only the distances between a set of landmarks and the samples are calculated.
#'
#' @importFrom assertthat assert_that
#' @importFrom dynutils calculate_distance is_sparse
Expand Down
3 changes: 2 additions & 1 deletion R/select_landmarks.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' select_landmarks(x)
select_landmarks <- function(
x,
distance_method = c("euclidean", "pearson", "spearman", "cosine", "manhattan"),
distance_method,
landmark_method = c("sample"),
num_landmarks = 500
) {
Expand Down Expand Up @@ -46,3 +46,4 @@ select_landmarks <- function(

dist_2lm
}
formals(select_landmarks)$distance_method <- unique(c("euclidean", dynutils::list_distance_methods())) # prioritise euclidean
7 changes: 4 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ library(tidyverse)

# `lmds`: Landmark Multi-Dimensional Scaling

Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS.
LMDS aims to produce the same dimensionality reduction as `cmdscale()`, but scale
linearly with respect to the number of samples.
A fast dimensionality reduction method scaleable to large numbers of samples.
Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS,
but rather than calculating a complete distance matrix between all pairs of samples,
only the distances between a set of landmarks and the samples are calculated.

```{r compare}
library(lmds)
Expand Down
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ Status](https://travis-ci.org/dynverse/lmds.svg?branch=master)](https://travis-c

# `lmds`: Landmark Multi-Dimensional Scaling

Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical
Torgerson MDS. LMDS aims to produce the same dimensionality reduction as
`cmdscale()`, but scale linearly with respect to the number of samples.
A fast dimensionality reduction method scaleable to large numbers of
samples. Landmark Multi-Dimensional Scaling (LMDS) is an extension of
classical Torgerson MDS, but rather than calculating a complete distance
matrix between all pairs of samples, only the distances between a set of
landmarks and the samples are calculated.

``` r
library(lmds)
Expand Down Expand Up @@ -44,7 +46,8 @@ changes.

Initial release of lmds.

- Landmark Multi-Dimensional Scaling (LMDS) is an extension of
classical Torgerson MDS. LMDS aims to produce the same
dimensionality reduction as `cmdscale()`, but scale linearly with
respect to the number of samples.
- A fast dimensionality reduction method scaleable to large numbers of
samples. Landmark Multi-Dimensional Scaling (LMDS) is an extension
of classical Torgerson MDS, but rather than calculating a complete
distance matrix between all pairs of samples, only the distances
between a set of landmarks and the samples are calculated.
6 changes: 6 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Initial release
* Landmark Multi-Dimensional Scaling (LMDS) is an extension of classical Torgerson MDS.
LMDS aims to produce the same dimensionality reduction as `cmdscale()`, but scale
linearly with respect to the number of samples.

Resubmission:
* I extended the description field in the DESCRIPTION to better reflect the purpose of
the package. I did not add a reference, as there is no corresponding manuscript.

* I added `\value{}` fields to each of the functions.

# Test environments

Expand Down
3 changes: 3 additions & 0 deletions man/cmdscale_landmarks.Rd

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

Binary file modified man/figures/timings-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 19 additions & 10 deletions man/lmds.Rd

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

10 changes: 7 additions & 3 deletions man/select_landmarks.Rd

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

0 comments on commit 7625100

Please sign in to comment.