-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Test writing h5ad in Python & in R #207
Open
LouiseDck
wants to merge
21
commits into
main
Choose a base branch
from
test_h5diff
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6cb0657
Add h5diff tests for X
LouiseDck aabff05
Add h5diff tests for obs and var
LouiseDck 5b11189
Document X known issues
LouiseDck fbb4946
Add h5diff tests & known issues wrt obs & var
LouiseDck 60cda2f
Add h5diff tests wrt layers
LouiseDck 79d759f
Add h5diff tests wrt obsm and varm
LouiseDck b186128
Add h5diff tests wrt obsp and varp
LouiseDck 4665720
Fix off-by-one in integer_matrix
LouiseDck 8a49151
Fix linting
LouiseDck 809ef98
Add processx dependency
LouiseDck 2bc42bf
Skip if no h5diff
LouiseDck 4edee29
Install hdf5tools in workflow
LouiseDck 00ccda4
typo
LouiseDck 20b85b3
fix system command
LouiseDck 4a4790b
lintr
LouiseDck 2e8ae3e
Skip if no h5diff
LouiseDck d42fe66
Satisfy lintr
LouiseDck 0600009
Fix system2 call
LouiseDck 861526e
Fix linting
LouiseDck 4676901
Fix linting v2
LouiseDck 9825f53
Document issues with dgeMatrix
LouiseDck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# python, R | ||
# does not test numeric_dense, numeric_dense_with_nas or integer_dense | ||
matrix_equivalences <- list( | ||
c("float_matrix", "numeric_matrix"), | ||
c("float_matrix_nas", "numeric_matrix_with_nas"), | ||
c("integer_matrix", "integer_matrix"), | ||
c("float_csparse", "numeric_csparse"), | ||
c("float_csparse_nas", "numeric_csparse_with_nas"), | ||
c("float_rsparse", "numeric_rsparse"), | ||
c("float_rsparse_nas", "numeric_rsparse_with_nas") | ||
) | ||
|
||
# python, R | ||
vector_equivalences <- list( | ||
c("categorical", "factor"), | ||
c("categorical_ordered", "factor_ordered"), | ||
c("categorical_missing_values", "factor_with_nas"), | ||
c("categorical_ordered_missing_values", "factor_ordered_with_nas"), | ||
c("string_array", "character"), | ||
c("dense_array", "numeric"), | ||
c("integer_array", "integer"), | ||
c("boolean_array", "logical"), | ||
c("nullable_integer_array", "integer_with_nas"), | ||
c("nullable_boolean_array", "logical_with_nas") | ||
) | ||
|
||
all_equivalences <- c(matrix_equivalences, vector_equivalences) | ||
|
||
check_arg <- function(args, name, falseval) { | ||
if (name %in% names(args)) { | ||
args[[name]][[1]] | ||
} else { | ||
falseval | ||
} | ||
} | ||
|
||
r_generate_dataset <- function(n_obs, n_vars, write = FALSE, ...) { | ||
args <- list(...) | ||
|
||
data <- generate_dataset(n_obs, n_vars, | ||
x_type = check_arg(args, "x_type", "numeric_matrix"), | ||
layer_types = check_arg(args, "layer_types", character()), | ||
obs_types = ifelse("obs_types" %in% names(args), args$obs_types, "integer"), | ||
var_types = ifelse("var_types" %in% names(args), args$var_types, "integer"), | ||
obsm_types = check_arg(args, "obsm_types", character()), | ||
varm_types = check_arg(args, "varm_types", character()), | ||
obsp_types = check_arg(args, "obsp_types", character()), | ||
varp_types = check_arg(args, "varp_types", character()), | ||
uns_types = check_arg(args, "uns_types", character()), | ||
format = "AnnData") | ||
if (write) { | ||
r_write_dataset(data) | ||
} | ||
|
||
data | ||
} | ||
|
||
r_write_dataset <- function(dataset, file = NULL) { | ||
if (is.null(file)) { | ||
file <- tempfile(pattern = "hdf5_write_R_", fileext = ".h5ad") | ||
} | ||
write_h5ad(dataset, file) | ||
file | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# helper function to skip tests if h5diff is not available | ||
skip_if_no_h5diff <- function() { | ||
testthat::skip_if_not({ | ||
s <- system2(command = "which", args = "h5diff", stdout = TRUE, stderr = TRUE) | ||
is.null(attr(s, "status")) | ||
}, message = "h5diff not available for testing") | ||
} |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of issue #198
It might be better to just document this in the known_issues.yaml though