Repository navigation
Conversation
_expand_indices used node IDs as row indices into the weight matrix, which has one row per sample in ts.samples() order, so pca raised IndexError whenever the samples were not nodes 0..n-1. Fixes tskit-dev#3443 Fixes tskit-dev#3365
This branch has not been deployed
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.
Description
TreeSequence.pcaraisedIndexErrorwhenever the sample nodes were not0, ..., n - 1, e.g. the census-node case in #3365 or the relabelled example in #3443._expand_indiceswrote each row of the weight matrix at the node ID, butgenetic_relatedness_vectorexpects the rows ints.samples()order.This maps the node IDs to their position in
ts.samples()first, and raises aValueErrorif a node passed in is not a sample.Tested with a new
TestPCA::test_samples_not_first_nodes: it renumbers the nodes of a simulated tree sequence so the samples start at node 5 and checks that the PCA (all samples, a subset of samples, and individuals) matches the original. It fails onmainwith theIndexErrorand passes with the change.pytest testspasses and ruff check/format are clean.Fixes #3443
Fixes #3365
PR Checklist: