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

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?

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

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

From the UMAP documentation, 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

``````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()` function applies the first argument (`hcat`) as a function iteratively to subsequent entries of `values(d)`. The function `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:

``````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)
``````