Repository navigation
Fix tpca() when there are more samples than features (n > p) - #13
Open
kimanh-lecao wants to merge 3 commits into
Open
kimanh-lecao wants to merge 3 commits into
kimanh-lecao wants to merge 3 commits into
Conversation
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.
Builds on #12; only the last commit is new.
tpca()fails whenever the number of samples exceeds the number of features:This is a common shape for targeted panels, for example a few dozen metabolites or antibody titres
measured on more subjects.
Cause.
tsvdm()returns the economy-size decomposition:uhatis n x k x t withk = min(n, p).
tpca()then builds the singular values tensor as n x p x t foruhat %fp% S. When n <= p, k = n and the product conforms; when n > p,uhathas only p columnsagainst n rows of
S, and.binary_facewise()stops.Fix. Build the singular values tensor with k rows:
dim = c(k, p, t)instead ofc(n, p, t).For n <= p this is the same call as before.
Checks.
tpca()fits (n < p and n = p; matrix and tensor output; with andwithout centring; several
ncomp) areidentical()before and after, as aretpls(),tplsda(),block_tpls()andblock_tplsda()results.46 x 26 and 90 x 31, the tensor
variatesequal the transformed, centred data timesvhatface byface to within 2e-14.
test-tens.tpca.R, mirroring "tpca agrees with mixOmics pca" with n = 10 > p = 3:loadings and variates match
mixOmics::pca(). It fails on the current main and passes with thefix.
Closes #3.