Releases: jlmelville/uwot
Releases · jlmelville/uwot
CRAN release 0.2.4
uwot 0.2.4
Bug fixes and minor improvements
- The installation status of optional dependencies were not being detected correctly. This meant that different packages could be used for initialization in unpredictable ways depending on whether they had been explicitly loaded or not. Thank you hsuknowledge for the report (#134).
- Users of the bbknnR package were suffering from a not-helpful error message when the custom neighbor data contained missing values. An explicit check has been added and although this is still a fatal error, the message should be more informative (#135).
- Fixed a partially-specified parameter name being passed to irlba. Thank you Hugo Gruson for the fix (#136).
- Development-only: fixed an incorrect use of
testthat::expectin a unit test. Thank you Hadley Wickham for the fix (#138).
CRAN release 0.2.3
uwot 0.2.3
New features:
- New parameter:
rng_type. This will be used in favor of the booleanpcg_randparameter, althoughpcg_randwill still work for
backwards compatibility. - New negative sampling option: set
rng_type = "deterministic"to use a deterministic sampling of vertices during the optimization
phase. This should give qualitatively similar results to using a real PRNG, but has the advantage of being faster and giving more
reproducible output. This feature was inspired by a comment by Leland McInnes on Reddit.
Bug fixes and minor improvements
- Setting
num_threadsdirectly inumap2did not result in the number of SGD threads being updated to that value whenbatch = TRUE,
which it should have been. - Despite assertions to the contrary in version 0.2.1,
umap_transformcontinued to return the fuzzy graph in transposed form. Thank you
PedroMilanezAlmeida for reopening the issue (#118). - Relative paths could not be used to save a model. Thank you Wouter van der Bijl for the bug report (#131) and the suggested fix.
repulsion_strengthwas silently ignored if used withtumaporumap2witha = 1, b = 1. Ignoring the setting was on purpose, but it
was not documented anywhere.repulsion_strengthis now compatible with these settings.- It's no longer an error to provide a
pcaargument if the input data has a maximum rank smaller than the value ofpca. No PCA is
applied in this case. Ifverbose = TRUE, a message will be printed to inform the user.
CRAN release 0.2.2
uwot 0.2.2
Bug fixes and minor improvements
RSpectrais now a required dependency (again). It was a required dependency up until version 0.1.12, when it became optional (irlbawas used in its place). However, problems with interactions of the current version ofirlbawith an ABI change in theMatrixpackage means that it's hard for downstream packages and users to builduwotwithout re-installingMatrixandirlbafrom source, which may not be an option for some people. Also it was causing a CRAN check error. I have changed some tests, examples and vignettes to useRSpectraexplicitly, and to only testirlbacode-paths where necessary. See #115 and links therein for more details.
CRAN release 0.2.1
uwot 0.2.1
New features:
- The HNSW approximate nearest neighbor search algorithm is now supported via the RcppHNSW package. Set
nn_method = "hnsw"to use it. The behavior of the method can be controlled by the newnn_argsparameter, a list which may containM,ef_constructionandef. See the hnswlib library's ALGO_PARAMS documentation for details on these parameters. Although typically faster than Annoy (for a given accuracy), be aware that the only supportedmetricvalues are"euclidean","cosine"and"correlation". Finally, RcppHNSW is only a suggested package, not a requirement, so you need to install it yourself (e.g. viainstall.packages("RcppHNSW")). Also see the article on HNSW in uwot in the documentation. - The nearest neighbor descent approximate nearest neighbor search algorithm is now supported via the rnndescent package. Set
nn_method = "nndescent"to use it. The behavior of the method can be controlled by the newnn_argsparameter. There are many supported metrics and possible parameters that can be set innn_args, so please see the article on nearest neighbor descent in uwot in the documentation, and also the rnndescent package's documentation for details.rnndescentis only a suggested package, not a requirement, so you need to install it yourself (e.g. viainstall.packages("rnndescent")). - New function:
umap2, which acts likeumapbut with modified defaults, reflecting my experience with UMAP and correcting some small mistakes. See the umap2 article for more details.
Bug fixes and minor improvements
init_sdev = "range"caused an error with a user-suppliedinitmatrix.- Transforming new data with the
correlationmetric was actually using thecosinemetric if you saved and reloaded the model. Thank you Holly Hall for the report and helpful detective work (#117). umap_transformcould fail if the new data to be transformed had thescaled:centerandscaled:scaleattributes set (e.g. from applying thescalefunction).- If you asked
umap_transformto return the fuzzy graph (ret_extra = c("fgraph")), it was transposed whenbatch = TRUE, n_epochs = 0.
Thank you PedroMilanezAlmeida for reporting (#118). - Setting
n_sgd_threads = "auto"withumap_transformcaused a crash. - A warning was being emitted due to not being specific enough about what
distclass was meant that may have been particularly affecting Seurat users. Thank you AndiMunteanu for reporting (and suggesting a solution) (#121).
CRAN release 0.1.16
uwot 0.1.16
Bug fixes and minor improvements
- A small change to a header file was required to fully support the next version of RcppAnnoy. Thank you Dirk Eddelbuettel for the PR (#112).
CRAN release 0.1.15
New features
- New function:
optimize_graph_layout. Use this to produce optimized output coordinates that
reflect an input similarity graph (such as that produced by thesimilarity_graphfunction.
similarity_graphfollowed byoptimize_graph_layoutis the same as runningumap, so the
purpose of these functions is to allow for more flexibility and decoupling between generating the
nearest neighbor graph and optimizing the low-dimensional approximation to it. Based on a request
by user Chengwei94 (#98). - New functions:
simplicial_set_unionandsimplicial_set_intersect. These allow for the
combination of different fuzzy graph representations of a dataset into a single fuzzy graph using
the UMAP simplicial set operations. Based on a request in the Python UMAP issues tracker by user
Dhar xion. - New parameter for
umap_transform:ret_extra. This works like the equivalent parameter for
umap, and should be a character vector specifying the extra information you would like returned
in addition to the embedding, in which case a list will be returned with anembeddingmember
containing the optimized coordinates. Supported values are"fgraph","nn","sigma"and
"localr". Based on a request by user PedroMilanezAlmeida (#104). - New parameter from
umap,tumapandumap_transform:seed. This will do the equivalent of
callingset.seedinternally, and hence will help with reproducibility. The chosen seed is
exported ifret_model = TRUEandumap_transformwill use that seed if present, so you only
need to specify it inumap_transformif you want to change the seed. The default behavior remains
to not modify the random number state. Based on a request by
SuhasSrinivasan (#110).
Bug fixes and minor improvements
- A new setting for
init_sdev: setinit_sdev = "range"and initial coordinates will be
range-scaled so each column takes values between 0-10. This pre-processing was added to the Python
UMAP package at some point afteruwotbegan development and so should probably always be used
with the defaultinit = "spectral"setting. However, it is not set by default to maintain
backwards compatibility with older versions ofuwot. ret_extra = c("sigma")is now supported bylvish. The Gaussian bandwidths are returned in a
sigmavector. In addition, a vector of intrinsic dimensionalities estimated for each point using
an analytical expression of the finite difference method given by
Lee and co-workers is returned in thedintvector.- The
min_distandspreadparameters are now returned in the model whenumapis run with
ret_model = TRUE. This is just for documentation purposes, these values are not used directly by
the model inumap_transform. If the parametersaandbare set directly when invokingumap,
then bothmin_distandspreadwill be set toNULLin the returned model. This feature was
added in response to a question from kjiang18 (#95). - Some new checks for NA values in input data have been added. Also a warning will be emitted if
n_componentsseems to have been set too high. - If
n_componentswas greater thann_neighborsthenumap_transformwould crash the R session.
Thank you to ChVav for reporting this (#102). - Using
umap_transformwith a model wheredens_scalewas set could cause a segmentation fault,
destroying the session. Even if it didn't it could give an entirely artifactual "ring" structure.
Thank you FemkeSmit for reporting this and providing
assistance in diagnosing the underlying cause (#103). - If you set
binary_edge_weights = TRUE, this setting was not exported whenret_model = TRUE,
and was therefore not respected byumap_transform. This has now been fixed, but you will need to
regenerate any models that used binary edge weights. - The rdoc for the
initparam said that if there were multiple disconnected components, a
spectral initialization would attempt to merge multiple sub-graphs. Not true: actually, spectral
initialization is abandoned in favor of PCA. The documentation has been updated to reflect the true
state of affairs. No idea what I was thinking of there. load_modelandsave_modeldidn't work on Windows 7 due to how the version oftarthere
handles drive letters. Thank you mytarmail for the report (#109).- Warn if the initial coordinates have a very large scale (a standard deviation > 10.0), because
this can lead to small gradients and poor optimization. Thank you SuhasSrinivasan for the
report (#110). - A change to accommodate a forthcoming version of RcppAnnoy. Thank you Dirk Eddelbuettel for
the PR (#111). - A test was failing on Arm architectures. Problem has been "solved" by removing the test, but it
was testing a floating point value resulting from a failure due to numerical issues, so it's a bit
of a corner case. Thank you Lucas Kanashiro for reporting (#100).
CRAN release 0.1.14
uwot 0.1.14
New features
- New function:
similarity_graph. If you are more interested in the high-dimensional graph/fuzzy simplicial set representation of your input data, and don't care about the low dimensional approximation, thesimilarity_graphfunction offers a similar API toumap, but neither the initialization nor optimization of low-dimensional coordinates will be performed. The return value is the same as that which would be returned in the results list as thefgraphmember if you had providedret_extra = c("fgraph"). Compared to getting the same result via runningumap, this function is a bit more convenient to use, makes your intention clearer if you would be discarding the embedding, and saves a small amount of time. A t-SNE/LargeVis similarity graph can be returned by settingmethod = "largevis".
Bug fixes and minor improvements
- If a model was generated without using pre-generated nearest neighbors, you couldn't use
umap_transformwith pre-generated nearest neighbors (also the error message was completely useless).Thank you to AustinHartman for reporting this (#97).
CRAN release 0.1.13
uwot 0.1.13
- This is a resubmission of 0.1.12 but with an internal function (
fuzzy_simplicial_set) refactored to behave more like that of previous versions. This change was breaking the behavior of the CRAN package bbknnR.
It would be pointless to release 0.1.12 as well as 0.1.13 as they are so similar. So here are the releases notes for 0.1.12:
uwot 0.1.12
New features
- New parameter:
dens_weight. If set to a value between 0 and 1, an attempt is made to include the relative local densities of the input data in the output coordinates. This is an approximation to the densMAP method. A large value ofdens_weightwill use a larger range of output densities to reflect the input data. If the data is too spread out, reduce the value ofdens_weight. For more information see the documentation at the uwot repo. - New parameter:
binary_edge_weights. If set toTRUE, instead of smoothed knn distances, non-zero edge weights all have a value of 1. This is how PaCMAP works and there is practical and theoretical reasons to believe this won't have a big effect on UMAP but you can try it yourself. - New options for
ret_extra:"sigma": the return value will contain asigmaentry, a vector of the smooth knn distance scaling normalization factors, one for each observation in the input data. A small value indicates a high density of points in the local neighborhood of that observation. Forlvishthe equivalent bandwidths calculated for the input perplexity is returned.- also, a vector
rhowill be exported, which is the distance to the nearest neighbor after the number of neighbors specified by thelocal_connectivity. Only applies forumapandtumap. "localr": exports a vector of the local radii, the sum ofsigmaandrhoand used to scale the output coordinates whendens_weightis set. Even if not usingdens_weight, visualizing the output coordinates using a color scale based on the value oflocalrcan reveal regions of the input data with different densities.
- For functions
umapandtumaponly: new data type for precomputed nearest neighbor data passed as thenn_methodparameter: you may use a sparse distance matrix of formatdgCMatrixwith dimensionsN x NwhereNis the number of observations in the input data. Distances should be arranged by column, i.e. a non-zero entry in rowjof theith column indicates that thejth observation in the input data is a nearest neighbor of theith observation with the distance given by the value of that element. Note that this is a different format to the sparse distance matrix that can be passed as input toX: notably, the matrix is not assumed to be symmetric. Unlike other input formats, you may have a different number of neighbors for each observation (but there must be at least one neighbor defined per observation). umap_transformcan also take a sparse distance matrix as itsnn_methodparameter if precomputed nearest neighbor data is used to generate an initial model. The format is the same as for thenn_methodwithumap. Because distances are arranged by columns, the expected dimensions of the sparse matrix isN_model x N_newwhereN_modelis the number of observations in the original data andN_newis the number of observations in the data to be transformed.
Bug fixes and minor improvements
- Models couldn't be re-saved after loading. Thank you to ilyakorsunsky for reporting this (#88).
- RSpectra is now a 'Suggests', rather than an 'Imports'. If you have RSpectra installed, it will be used automatically where previous versions required it (for spectral initialization). Otherwise, irlba will be used. For two-dimensional output, you are unlikely to notice much difference in speed or accuracy with real-world data. For highly-structured simulation datasets (e.g. spectral initialization of a 1D line) then RSpectra will give much better, faster initializations, but these are not the typical use cases envisaged for this package. For embedding into higher dimensions (e.g.
n_components = 100or higher), RSpectra is recommended and will likely out-perform irlba even if you have installed a good linear algebra library. init = "laplacian"returned the wrong coordinates because of a slightly subtle issue around how to order the eigenvectors when using the random walk transition matrix rather than normalized graph laplacians.- The
init_sdevparameter was ignored when theinitparameter was a user-supplied matrix. Now the input will be scaled. - Matrix input was being converted to and from a data frame during pre-processing, causing R to allocate memory that it was disinclined to ever give up even after the function exited. This unnecessary manipulation is now avoided.
- The behavior of the
bandwidthparameter has been changed to give results more like the current version (0.5.2) of the Python UMAP implementation. This is likely to be a breaking change for non-default settings ofbandwidth, but this is not a parameter which is actually exposed by the Python UMAP public API any more, so is on the road to deprecation in uwot too and I don't recommend you change this. - Transforming data with multiple blocks would give an error if the number of rows of the new data did not equal the number of number of rows in the original data.
CRAN release 0.1.11
uwot 0.1.11
New features
- New parameter:
batch. IfTRUE, then results are reproducible whenn_sgd_threads > 1(as long as you useset.seed). The price to be paid is that the optimization is slightly less efficient (because coordinates are not updated as quickly and hence gradients are staler for longer), so it is highly recommended to setn_epochs = 500or higher. Thank you to Aaron Lun who not only came up with a way to implement this feature, but also wrote an entire C++ implementation of UMAP which does it
(#83). - New parameter:
opt_args. The default optimization method whenbatch = TRUEis Adam. You can control its parameters by passing them in theopt_argslist. As Adam is a momentum-based method it requires extra storage of previous gradient data. To avoid the extra memory overhead you can also useopt_args = list(method = "sgd")to use a stochastic gradient descent method like that used whenbatch = FALSE. - New parameter:
epoch_callback. You may now pass a function which will be invoked at the end of each epoch. Mainly useful for producing an image of the state of the embedding at different points during the optimization. This is another feature taken from umappp. - New parameter:
pca_method, used when thepcaparameter is supplied to reduce the initial dimensionality of the data. This controls which method is used to carry out the PCA and can be set to one of:"irlba"which usesirlba::irlbato calculate a truncated SVD. If this routine deems that you are trying to extract 50% or more of the singular vectors, you will see a warning to that effect logged to the console."rsvd", which usesirlba::svdrfor truncated SVD. This method uses a small number of iterations which should give an accuracy/speed up trade-off similar to that of the scikit-learn TruncatedSVD method. This can be much faster than using"irlba"but potentially at a cost in accuracy. However, for the purposes of dimensionality reduction as input to nearest neighbor search, this doesn't seem to matter much."bigstatsr", which uses the bigstatsr package will be used. Note: that this is not a dependency ofuwot. If you want to usebigstatsr, you must install it yourself. On platforms without easy access to fast linear algebra libraries (e.g. Windows), usingbigstatsrmay give a speed up to PCA calculations."svd", which usesbase::svd. Warning: this is likely to be very slow for most datasets and exists as a fallback for small datasets where
the"irlba"method would print a warning."auto"(the default) which uses"irlba"to calculate a truncated SVD, unless you are attempting to extract 50% or more of the singular vectors, in which case"svd"is used.
Bug fixes and minor improvements
- If row names are provided in the input data (or nearest neighbor data, or initialization data if it's a matrix), this will be used to name the rows of the output embedding (#81), and also the nearest neighbor data if you set
ret_nn = TRUE. If the names exist in more than one of the input data parameters listed above, but are inconsistent, no guarantees are made about which names will be used. Thank you jwijffels for reporting this. - In
umap_transform, the learning rate is now down-scaled by a factor of 4, consistent with the Python implementation of UMAP. If you need the old behavior back, use the (newly added)learning_rateparameter inumap_transformto set it explicitly. If you used the default value inumapwhen creating the model, the correct setting inumap_transformislearning_rate = 1.0. - Setting
nn_method = "annoy"andverbose = TRUEwould lead to an error with datasets with fewer than 50 items in them. - Using multiple pre-computed nearest neighbors blocks is now supported with
umap_transform(this was incorrectly documented to work). - Documentation around pre-calculated nearest neighbor data for
umap_transformwas wrong in other ways: it has now been corrected to indicate that there should be neighbor data for each item in the test data, but the neighbors and distances should refer to items in training data (i.e. the data used to build the model). n_neighborsparameter is now correctly ignored in model generation if pre-calculated nearest neighbor data is provided.- Documentation incorrectly said
grain_sizedidn't do anything.
CRAN release 0.1.10
uwot 0.1.10
This release is mainly to allow for some internal changes to keep compatibility with RcppAnnoy, used for the nearest neighbor calculations.
Bug fixes and minor improvements
- Passing in data with missing values will now raise an error early. Missing data in factor columns intended for supervised UMAP is still ok. Thank you David McGaughey for tweeting about this issue.
- The documentation for the return value of
umapandtumapnow note that the contents of themodellist are subject to change and not intended to be part of the uwot public API. I recommend not relying on the structure of themodel, especially if your package is intended to appear on CRAN or Bioconductor, as any breakages will delay future releases of uwot to CRAN.