Skip to content

Feature: add pcoa project - #1

Open
tensulin wants to merge 8 commits into
mainfrom
feat/pcoa_project
Open

Feature: add pcoa project#1
tensulin wants to merge 8 commits into
mainfrom
feat/pcoa_project

Conversation

@tensulin

@tensulin tensulin commented Jul 6, 2026

Copy link
Copy Markdown
Member

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 licenses directory and add a comment in the code giving proper attribution. Ensure any other requirements set forth by the license and/or author are satisfied.

    • It is your responsibility to disclose code, documentation, or other content derived from external source(s). If you have questions about whether something can be included in the project or how to give proper attribution, include those questions in your pull request and a reviewer will assist you.
  • 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_project to project new points into an existing PCoA space using distances to the reference samples.
  • Export pcoa_project from skbio.stats.ordination via __init__.py.
  • Modify FSVD pcoa centering to use distmat.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.

Comment thread skbio/stats/ordination/_principal_coordinate_analysis.py Outdated
Comment thread skbio/stats/ordination/_principal_coordinate_analysis.py Outdated
Comment thread skbio/stats/ordination/_principal_coordinate_analysis.py Outdated
Comment thread skbio/stats/ordination/_principal_coordinate_analysis.py
Comment thread skbio/stats/ordination/_principal_coordinate_analysis.py Outdated
Comment thread skbio/stats/ordination/_principal_coordinate_analysis.py Outdated
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
tensulin and others added 7 commits July 6, 2026 17:14
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>
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