# MethodError: no method matching UMAP\_(::Vector{Pair{Tuple{String, String}, Vector{Float64}}}, ::Int64)

**URL:** https://discourse.julialang.org/t/methoderror-no-method-matching-umap-vector-pair-tuple-string-string-vector-float64-int64/80986
**Category:** New to Julia
**Tags:** package
**Created:** [May 13, 2022, 2:09am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-umap-vector-pair-tuple-string-string-vector-float64-int64/80986 "2022-05-13T02:09:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JosieG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josieg/32/36221_2.png) [@JosieG](https://discourse.julialang.org/u/JosieG)
#### Post date: [May 13, 2022, 2:09am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-umap-vector-pair-tuple-string-string-vector-float64-int64/80986/1 "2022-05-13T02:09:46Z")

</div>

Hi, I’m very new to Julia. I want to do some dimension reduction. And I got a

d = Dict{Tuple{String, String}, Vector{Float64}}

first, which is supposed to be my distance matrix. And then in order to do umap, I do

> umap(d,2)

while got this error

> no method matching UMAP\_(::Dict{Tuple{String, String}, Vector{Float64}}, ::Int64)

I tried to use _collect(d)_ to convert the dictionary to other forms still got this error. How to convert the dictionary into the form that should be passed in umap?  
Thank you in advance!

---

<div class="post-metadata">

### Author: ![cjdoris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cjdoris/32/213133_2.png) [@cjdoris](https://discourse.julialang.org/u/cjdoris)
#### Post date: [May 13, 2022, 7:08am UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-umap-vector-pair-tuple-string-string-vector-float64-int64/80986/2 "2022-05-13T07:08:29Z")

</div>

I’d guess that if you’re passing in precomputed distances, it wants them as a matrix.

---

<div class="post-metadata">

### Author: ![JosieG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josieg/32/36221_2.png) [@JosieG](https://discourse.julialang.org/u/JosieG)
#### Post date: [May 13, 2022, 3:20pm UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-umap-vector-pair-tuple-string-string-vector-float64-int64/80986/3 "2022-05-13T15:20:00Z")

</div>

Then how to convert such dictionaries to matrix? I used “collect(d)” but it didn’t work.

---

<div class="post-metadata">

### Author: ![awasserman](https://avatars.discourse-cdn.com/v4/letter/a/9de0a6/32.png) [@awasserman](https://discourse.julialang.org/u/awasserman)
#### Post date: [May 13, 2022, 4:15pm UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-umap-vector-pair-tuple-string-string-vector-float64-int64/80986/4 "2022-05-13T16:15:40Z")

</div>

From the [UMAP documentation](https://github.com/dillondaudert/UMAP.jl), it looks like the `umap()` function expects its first argument to be a matrix where rows are different features and columns are different samples. So assuming that the dictionary you’re using has its values as the feature vector samples you wish to use, you could do

```julia
X = reduce(hcat, values(d))
embedding = umap(X, 2)

```

In that first line, the `values()` function creates an iterator of vectors from the dictionary. The [`reduce()`](https://docs.julialang.org/en/v1/base/collections/#Base.reduce-Tuple%7BAny,%20Any%7D) function applies the first argument (`hcat`) as a function iteratively to subsequent entries of `values(d)`. The function [`hcat`](https://docs.julialang.org/en/v1/base/arrays/#Base.hcat) is used to take two or more vectors and concatenate them horizontally (that is such that the vectors become columns of the resulting matrix).

So for instance, the following ways of constructing the matrix are equivalent:

```julia
d = Dict(:a => [1, 2, 3], :b => [4, 5, 6], :c => [7, 8, 9])
X1 = hcat(d[:a], d[:b], d[:c])
X2 = reduce(hcat, values(d))
@assert all(X1 .== X2)

```
