Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flipping coordinates for biplot ordination #258

Closed
mortonjt opened this issue Aug 2, 2019 · 3 comments
Closed

Flipping coordinates for biplot ordination #258

mortonjt opened this issue Aug 2, 2019 · 3 comments

Comments

@mortonjt
Copy link
Contributor

mortonjt commented Aug 2, 2019

Addition Description
One thing that could become increasing helpful with the introduction of feature-specific stats (i.e. songbird, aldex2, rhapsody, qurro) is the ability to flip ordinations.

For example, if someone wants to analyze their metabolites in a qurro rank plot, they would need to first flip their ordination coordinates (i.e. swap sample coordinates with feature coordinates) so that they can have metabolites as "features".

Another use case is if someone wants to visualize the microbe co-occurrences learned from DEICODE - it'll require the features to be plotted instead of the samples.

Given that this will likely be a recurring pattern, it may make sense to have this "flipping" operation further upstream.

Current Behavior
Doesn't exist at the moment.

Proposed Behavior
I've written a simple CLI script that can do this at the moment - but if there is interest, I'll be happy to make a contribution to q2-diversity

from skbio import OrdinationResults
import sys

res = OrdinationResults.read(sys.argv[1])
samples = res.samples.copy()
features = res.features.copy()
res.samples = features
res.features = samples
res.write(sys.argv[2])

References
https://github.com/biocore/qurro
https://github.com/biocore/DEICODE
https://msystems.asm.org/content/4/1/e00016-19

CC @fedarko @cameronmartino @ElDeveloper

@mortonjt mortonjt mentioned this issue Aug 19, 2019
5 tasks
@nbokulich
Copy link
Member

Wouldn't it make more sense for the visualizers to do the flipping as appropriate? Otherwise I worry that this could enable "illicit" actions, e.g., if passing those ordination results to a method that should not operate on flipped samples/loadings.

I see that this makes more sense for feature-specific stats, but keep in mind that rhapsody is currently making use of the PCoAResults % Properties('biplot') type. Should we be allowing samples/loadings to be flipped for all biplot results? Maybe we need to define a new OrdinationResults % Properties('FeaturesBiplot') type that rhapsody and other plugins use when they make microbe/metabolite biplots?

@mortonjt
Copy link
Contributor Author

mortonjt commented Aug 20, 2019

Good point @nbokulich . One option along those lines is to have an --p-invert option for each of the visualizers that flips the assignment of points vs arrows or vice versa.
There is a similar issue raised here.

I'm not sure how I feel about defining a OrdinationResults % Properties('FeaturesBiplot') - how would a FeaturesBiplot be different just a Biplot? There are definitely use cases for allowing for all biplots to be flipped -- for instance, if the coordinates in DEICODE were flipped (where points now represent microbes), the distances between points would directly map to microbe-microbe co-occurrence strengths.

@mortonjt
Copy link
Contributor Author

@thermokarst @nbokulich moving this to emperor and eventually qurro, since it is probably a better place to put this

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

No branches or pull requests

2 participants