Feature: add pcoa project - #1
Open
tensulin wants to merge 8 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new public helper (pcoa_project) to project new sample(s) into an existing PCoA ordination (Gower projection), and exposes it from skbio.stats.ordination. It also changes the FSVD branch of pcoa to center a copied distance matrix.
Changes:
- Add
pcoa_projectto project new points into an existing PCoA space using distances to the reference samples. - Export
pcoa_projectfromskbio.stats.ordinationvia__init__.py. - Modify FSVD
pcoacentering to usedistmat.copy().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| skbio/stats/ordination/_principal_coordinate_analysis.py | Adds pcoa_project and adjusts FSVD centering behavior in pcoa. |
| skbio/stats/ordination/init.py | Exposes pcoa_project as part of the public ordination API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return eigenvalues, eigenvectors | ||
|
|
||
|
|
||
| def pcoa_project(ordination, distances_to_reference, reference_distmat=None, sample_squared_distance_to_centroid=None): |
Comment on lines
+719
to
+720
| q = sample_squared_distance_to_centroid - delta_squared | ||
| X_new_projected.append((q.T @ X) / (2 * eigvals_obj)) |
Comment on lines
+724
to
+727
| delta_squared = distances_to_reference ** 2 | ||
| q = sample_squared_distance_to_centroid - delta_squared | ||
| X_new = (q.T @ X) / (2 * eigvals_obj) | ||
| return pd.DataFrame(X_new, columns=[distances_to_reference.name]).T |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Attention
I have created a view with hmp and fmt samples visualised in qiime, see the files vor emperor plot here for comparision of projection:
https://next.hessenbox.de/index.php/f/708678537
10 random samples from the north part: pcoa_ten
First implementation of pcoa project, testbeds currently under: https://github.com/jlab/livepcoatestbed
Please complete the following checklist:
I have read the contribution guidelines.
I have documented all public-facing changes in the changelog.
This pull request includes code, documentation, or other content derived from external source(s). If this is the case, ensure the external source's license is compatible with scikit-bio's license. Include the license in the
licensesdirectory and add a comment in the code giving proper attribution. Ensure any other requirements set forth by the license and/or author are satisfied.This pull request does not include code, documentation, or other content derived from external source(s).
Note: This document may also be helpful to see some of the things code reviewers will be verifying when reviewing your pull request.