Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 2 issues with how the 'center' argument is handled #69

Merged
merged 1 commit into from
Nov 24, 2020
Merged

Fix 2 issues with how the 'center' argument is handled #69

merged 1 commit into from
Nov 24, 2020

Conversation

hpages
Copy link
Contributor

@hpages hpages commented Nov 24, 2020

See issue #68 for the details.

This patch fixes the 1st issue:

library(HDF5Array)
library(DelayedMatrixStats)

m <- matrix(1:30, nrow=6) * 10^(0:5)
M1 <- as(m, "HDF5Matrix")
M2 <- as(t(m), "HDF5Matrix")

# row/colVars():
current <- rowVars(M1, rows=5:6, center=rowMeans(M1))
stopifnot(all.equal(rowVars(M1)[5:6], current))

current <- colVars(M2, cols=5:6, center=colMeans(M2))
stopifnot(all.equal(colVars(M2)[5:6], current))

# row/colMads():
current <- rowMads(M1, rows=5:6, center=rowMedians(M1))
stopifnot(all.equal(rowMads(M1)[5:6], current))

current <- colMads(M2, cols=5:6, center=colMedians(M2))
stopifnot(all.equal(colMads(M2)[5:6], current))

# row/colSds():
current <- rowSds(M1, rows=5:6, center=rowMeans(M1))
stopifnot(all.equal(rowSds(M1)[5:6], current))

current <- colSds(M2, cols=5:6, center=colMeans(M2))
stopifnot(all.equal(colSds(M2)[5:6], current))

and the 2nd issue:

total_data_size <- length(M1) * get_type_size(type(M1))
setAutoBlockSize(total_data_size * 2/3)

# row/colVars():
current <- rowVars(M1, center=rowMeans(M1))
stopifnot(all.equal(rowVars(M1), current))

current <- colVars(M2, center=colMeans(M2))
stopifnot(all.equal(colVars(M2), current))

current <- rowVars(M1, center=0)
rs0 <- rowSums(M1^2) / (ncol(M1) - 1)
stopifnot(all.equal(rs0, current))

current <- colVars(M2, center=0)
cs0 <- colSums(M2^2) / (nrow(M2) - 1)
stopifnot(all.equal(cs0, current))

# row/colMads():
current <- rowMads(M1, center=rowMedians(M1))
stopifnot(all.equal(rowMads(M1), current))

current <- colMads(M2, center=colMedians(M2))
stopifnot(all.equal(colMads(M2), current))

# row/colSds():
current <- rowSds(M1, center=rowMeans(M1))
stopifnot(all.equal(rowSds(M1), current))

current <- colSds(M2, center=colMeans(M2))
stopifnot(all.equal(colSds(M2), current))

H.

@PeteHaitch PeteHaitch merged commit f2a05ae into PeteHaitch:master Nov 24, 2020
@PeteHaitch
Copy link
Owner

Thanks, Hervé. I've pushed to BioC

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.

None yet

2 participants