Skip to content

add reticulate-based tests for the hdf5 backend - #69

Merged
rcannood merged 9 commits into
hdf5-structurefrom
add_hdf5_reticulate_test
May 8, 2023
Merged

rcannood merged 9 commits into
hdf5-structurefrom
add_hdf5_reticulate_test

Conversation

@rcannood

@rcannood rcannood commented May 5, 2023 •

Copy link
Copy Markdown
Member

In discussing with @LouiseDck yesterday, I'm thinking that the only way to properly make sure that anndataR is able to read files created by anndata and vice versa, is to use reticulate to implement tests with data going back and forth.

Even without the extra checks, seeing if the python anndata is able to read files produced by anndataR is already very valuable.

These tests won't work yet since some of the functions it calls don't exist yet

@rcannood rcannood changed the title add hdf5 test which uses reticulate add reticulate-based tests for the hdf5 backend May 5, 2023
@lazappi

lazappi commented May 5, 2023

Copy link
Copy Markdown
Collaborator

I think you're right this is the only way to test stuff but I'm not entirely sure doing it as a normal test will work in practice. I'm not sure you can guarantee that Python/anndata will be available without using something like {basilisk}. It may be we need a separate CI or something that does this round trip (I think @ivirshup was interested in that anyway). Happy to have this for now though if it works.

@rcannood

rcannood commented May 8, 2023

Copy link
Copy Markdown
Member Author

It should be just a matter of making sure that anndata::install_anndata() or reticulate::install_miniconda(); reticulate::py_install("anndata", pip = TRUE) is called in the CI to make this work.

Happy to give basilisk a shot as well :)

@rcannood
rcannood changed the base branch from main to hdf5-structure May 8, 2023 11:55
@rcannood

rcannood commented May 8, 2023

Copy link
Copy Markdown
Member Author

If the tests succeed, this test could be merged to the hdf5-structure branch and then extended

@rcannood
rcannood marked this pull request as ready for review May 8, 2023 11:56
@rcannood
rcannood requested a review from lazappi May 8, 2023 13:47
@rcannood

rcannood commented May 8, 2023

Copy link
Copy Markdown
Member Author

@lazappi Ok to merge?

@lazappi

lazappi commented May 8, 2023

Copy link
Copy Markdown
Collaborator

I think it's probably fine for now. I think we will want to tidy up the tests at some point but probably better to wait until we have more stuff there.

Comment on lines +4 to +26
X <- Matrix::rsparsematrix(nrow = 10, ncol = 20, density = .1)

# construct dummy obs
obs <- data.frame(
cell_type = sample(c("tcell", "bcell"), 10, replace = TRUE),
cluster = sample.int(3, 10, replace = TRUE)
)

# construct dummy obs names
obs_names <- paste0("cell_", seq_len(10))

# construct dummy var
var <- data.frame(
geneinfo = sample(c("a", "b", "c"), 20, replace = TRUE)
)

# construct dummy var names
var_names <- paste0("gene", seq_len(20))

layers <- list(
X2 = X * 2,
X3 = X * 3
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want some kind of "mock" function to use across tests but this is probably fine for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree :)

@rcannood
rcannood merged commit 8f2ebbe into hdf5-structure May 8, 2023
@rcannood
rcannood deleted the add_hdf5_reticulate_test branch May 8, 2023 14:07
lazappi added a commit that referenced this pull request May 10, 2023
* origin/main: (74 commits)
  make sure path is printed
  ignore complexity
  fix typo in docs
  update roxygen
  implement get_generator class
  improve test
  redesign HDF5AnnData constructor based on #51
  rename write h5ad encoding function
  move validation functions
  move check
  fix tests
  improve roundtrip test
  wip fix write functions
  fix read functions
  check data frame first
  fix write_encoding_attribute function
  refactor tests using helper functions
  fix abstract method error
  fix issues
  add reticulate-based tests for the hdf5 backend (#69)
  ...
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.

2 participants