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

Reticulate backend #48

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft

Reticulate backend #48

wants to merge 12 commits into from

Conversation

rcannood
Copy link
Collaborator

@rcannood rcannood commented May 1, 2023

This PR intends to add a reticulate backend to the package. If done correctly, it could be used to better test our own HDF5 AnnData reader, since it'll allow to create h5ad files from within R.

Status

Working:

  • Constructor: X, obs, var, var_names, obs_names, layers
  • Getter: X, obs, var, var_names, obs_names, layers
  • Setters: X, obs, var, var_names, obs_names, layers

Example

X <- Matrix::rsparsematrix(nrow = 10, ncol = 20, density = .1)
obs <- data.frame(
  cell_type = sample(c("tcell", "bcell"), 10, replace = TRUE),
  cluster = sample.int(3, 10, replace = TRUE)
)
obs_names <- paste0("cell_", seq_len(10))
var <- data.frame(
  geneinfo = sample(c("a", "b", "c"), 20, replace = TRUE)
)
var_names <- paste0("gene", seq_len(20))
layers <- list(
  X2 = matrix(2L, nrow = 10, ncol = 20),
  X3 = matrix(2.5, nrow = 10, ncol = 20),
  X4 = Matrix::rsparsematrix(10, 20, .2)
)
ad <- ReticulateAnnData$new(
  X = X,
  obs = obs,
  var = var,
  obs_names = obs_names,
  var_names = var_names,
  layers = layers
)
ad
class: ReticulateAnnData
dim: 10 obs x 20 var
X: dgCMatrix
layers: X2 X3 X4
obs: cell_type cluster
var: geneinfo

@rcannood rcannood mentioned this pull request May 3, 2023
@lazappi
Copy link
Collaborator

lazappi commented May 5, 2023

I'm not sure how I feel about this, probably mostly because it is similar to what {zellkonverter} and {anndata} already do. Maybe we need to discuss how they fit together.

@rcannood
Copy link
Collaborator Author

rcannood commented May 5, 2023

If this backend would be integrated into anndataR, I'd be able to start deprecating {anndata} ☺️

The ReticulateAnnData can also be used to validate HDF5AnnData and vice versa.

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