Skip to content

Commit

Permalink
Fixes to pass check.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jul 20, 2023
1 parent 38f85f3 commit 48aa8f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ FetchContent_MakeAvailable(umappp)
FetchContent_Declare(
scran
GIT_REPOSITORY https://github.com/LTLA/libscran
GIT_TAG 591bd6fabd573ad5762c8efea257a114821c92c9
GIT_TAG da495dad607bed894cbcbb7ed811fa8d4983d576
)
FetchContent_MakeAvailable(scran)

FetchContent_Declare(
kmeans
GIT_REPOSITORY https://github.com/LTLA/CppKmeans
GIT_TAG master
GIT_TAG 4c5aca44bffd8ed7d7243b2451105b572028e9d4
)
FetchContent_MakeAvailable(kmeans)

Expand Down
2 changes: 1 addition & 1 deletion js/quickAdtSizeFactors.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function quickAdtSizeFactors(x, { numberOfClusters = 20, numberOfPCs = 25
let norm, pcs;
try {
norm = logNormCounts(x, { sizeFactors: totals, block: block });
pcs = runPca(norm, { numberOfPCs: Math.min(norm.numberOfRows() - 1, numberOfPCs), numberOfThreads: numberOfThreads, block: block, blockMethod: "weight" });
pcs = runPca(norm, { numberOfPCs: Math.min(norm.numberOfRows() - 1, numberOfPCs), numberOfThreads: numberOfThreads, block: block, blockMethod: "project" });
} finally {
utils.free(norm);
}
Expand Down
20 changes: 9 additions & 11 deletions tests/runPca.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ test("PCA works as expected with blocking", () => {

var block = new Int32Array(ncells);
var nblocks = 4;
for (var i = 0; i < ncells; i++) {
block[i] = Math.floor(Math.random() * nblocks);
}
for (var j = 0; j < nblocks; j++) {
block[j] = j;
var i = 0;
while (i < ncells) {
for (var b = 0; b < nblocks; b++) {
for (var j = 0; j <= b && i < ncells; j++) {
block[i] = b;
++i;
}
}
}

var pca = scran.runPca(mat, { features: feat, numberOfPCs: 15 });
Expand All @@ -71,15 +74,10 @@ test("PCA works as expected with blocking", () => {
expect(pca.numberOfCells()).toBe(weighted.numberOfCells());
expect(compare.equalFloatArrays(pca.principalComponents(), weighted.principalComponents())).toBe(false);

var none = scran.runPca(mat, { features: feat, numberOfPCs: 15, block: block, blockMethod: "none" });
expect(pca.numberOfPCs()).toBe(none.numberOfPCs());
expect(pca.numberOfCells()).toBe(none.numberOfCells());
expect(compare.equalFloatArrays(pca.principalComponents(), none.principalComponents())).toBe(false);

var none2 = scran.runPca(mat, { features: feat, numberOfPCs: 15, block: block, blockMethod: "none", blockWeights: false });
expect(pca.numberOfPCs()).toBe(none2.numberOfPCs());
expect(pca.numberOfCells()).toBe(none2.numberOfCells());
expect(compare.equalFloatArrays(pca.principalComponents(), none2.principalComponents())).toBe(true);
expect(compare.equalArrays(pca.principalComponents(), none2.principalComponents())).toBe(true); // should be exactly equal.

expect(() => scran.runPca(mat, { features: feat, numberOfPCs: 15, block: block, blockMethod: "foobar" })).toThrow("should be one of");
});

0 comments on commit 48aa8f1

Please sign in to comment.