Skip to content

Conversation

kescobo
Copy link
Contributor

@kescobo kescobo commented May 21, 2019

This is dependent on JuliaStats/MultivariateStats.jl#85, though I'm not quite sure how to indicate that in compat until it's tagged.

using StatsPlots
using Distances
using MultivariateStats

m = rand(100, 10)

dm = pairwise(BrayCurtis(), m)

mds = fit(MDS, dm, distances=true)

plot(mds)

mds

@mkborregaard
Copy link
Member

That looks sweet! Have you considered an interface for multiple dimensions? Either passing dimensions manually, or using subplots or possibly 3d?

@kescobo
Copy link
Contributor Author

kescobo commented May 21, 2019

@mkborregaard I have considered, but wasn't sure about the implementation. Since this is not a user recipe, can I add a keyword for that?

@mkborregaard
Copy link
Member

Sure :-)

@mkborregaard
Copy link
Member

(technically this is a user recipe)

@kescobo
Copy link
Contributor Author

kescobo commented May 22, 2019

I think I was mis-remembering the deal with keyword arguments...

In any case, this now allows a user to specify axes, and do a 3rd axis:

using StatsPlots
using Distances
using MultivariateStats

m = rand(100, 10)
dm = pairwise(BrayCurtis(), m)
mds = fit(MDS, dm, distances=true)

plot(mds)

mds1

plot(mds, mds_axes=(3,5))

mds2

plot(mds, mds_axes=(1,2,3))

mds3

@mkborregaard
Copy link
Member

Love it ❤️

@mkborregaard mkborregaard merged commit 59254e3 into JuliaPlots:master May 22, 2019
@mkborregaard
Copy link
Member

Oh - I merged already, but only now realised - shouldn't aspect_ratio have been set to 1?

@@ -0,0 +1,22 @@
@recipe function f(mds::MDS{<:Real}; mds_axes=(1,2))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think you're missing a dep on MultivariateStats for this to work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, you do have that, I seem to have a local problem, sorry for the noise

@kescobo
Copy link
Contributor Author

kescobo commented May 22, 2019

Not sure, what does that do? Happy to add it in.

@mkborregaard
Copy link
Member

mkborregaard commented May 22, 2019

@kescobo I'm getting WARNING: could not import MultivariateStats.MDS into StatsPlots locally - is there something wrong with my setup/versions?

Also, could the signature be wider to allow for PCAs and other ordinations as well? Is the interface not general enough for this?

It would be awesome to have a readme example with this code

using MultivariateStats, RDatasets, StatsPlots

iris = dataset("datasets", "iris")
Xtr = convert(Matrix, iris[:, 1:4])'
M = fit(PCA, Xtr; maxoutdim=2)
plot(M, group = iris.Species)

or something like that. Compare the code here: https://multivariatestatsjl.readthedocs.io/en/latest/pca.html#data-analysis

@mkborregaard
Copy link
Member

Not sure, what does that do?

Forces the axes to have the same scale. Given that they are by definition on the same scale it gives a more correct representation of the spread on the axes.

@kescobo
Copy link
Contributor Author

kescobo commented May 22, 2019

@kescobo I'm getting WARNING: could not import MultivariateStats.MDS into StatsPlots locally - is there something wrong with my setup/versions?

You have to be on master of MultivariatStats (see the first comment in this thread=). The PR introducing this API hasn't been tagged, so I can't add it to [compat] in the Project.toml yet (I asked on slack)

Also, could the signature be wider to allow for PCAs and other ordinations as well? Is the interface not general enough for this?

I haven't looked into it, but I thought about the same thing. I will happily do a separate PR.

It would be awesome to have a readme example with this code

Sure - should this be a separate PR since this one is already merged?

@kescobo
Copy link
Contributor Author

kescobo commented May 22, 2019

Forces the axes to have the same scale. Given that they are by definition on the same scale. Given that they are by definition on the same scale it gives a more correct representation of the spread on the axes.

My understanding was that for PCoA at least, the scales are essentially unitless and so scaling is meaningless. Entirely possible I misunderstood that though 😆

@mkborregaard
Copy link
Member

You have to be on master of MultivariatStats (see the first comment in this thread=)

Sorry 😂

I will happily do a separate PR.

Yay! 💖

should this be a separate PR

I think it has to be yeah.

scales are essentially unitless

AFAIK the PCoA transformation maintains distances among points. But if Plots chooses different scales for the x and y axis (based on the range of the data and the shape of the plotting window), the distances will not be correct.

@kescobo
Copy link
Contributor Author

kescobo commented May 22, 2019

AFAIK the PCoA transformation maintains distances among points.

But PCoA is for non-metric distances right? Maybe I'll ask on Slack...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants