anndataR
anndataR copied to clipboard
Do not copy items is mapping is empty vector `c()`
library(anndataR)
anndata <- generate_dataset(
n_obs = 10,
n_vars = 20,
format = "AnnData",
uns_types = c()
)
sce <- to_SingleCellExperiment(anndata)
#> Registered S3 method overwritten by 'future':
#> method from
#> all.equal.connection parallelly
ad2 <- from_SingleCellExperiment(
sce,
x_mapping = "numeric_matrix",
obs_mapping = c(),
var_mapping = c(),
obsm_mapping = list(),
obsp_mapping = list(),
varm_mapping = list(),
varp_mapping = list(),
uns_mapping = list(),
)
ad2
#> AnnData object with n_obs × n_vars = 10 × 20
#> obs: 'character', 'integer', 'factor', 'factor_ordered', 'logical', 'numeric', 'character_with_nas', 'integer_with_nas', 'factor_with_nas', 'factor_ordered_with_nas', 'logical_with_nas', 'numeric_with_nas'
#> var: 'character', 'integer', 'factor', 'factor_ordered', 'logical', 'numeric', 'character_with_nas', 'integer_with_nas', 'factor_with_nas', 'factor_ordered_with_nas', 'logical_with_nas', 'numeric_with_nas'
#> layers: 'counts', 'numeric_dense', 'numeric_csparse', 'numeric_rsparse', 'numeric_matrix_with_nas', 'numeric_dense_with_nas', 'numeric_csparse_with_nas', 'numeric_rsparse_with_nas', 'integer_matrix', 'integer_dense', 'integer_csparse', 'integer_rsparse', 'integer_matrix_with_nas', 'integer_dense_with_nas', 'integer_csparse_with_nas', 'integer_rsparse_with_nas'
We should update the documentation (probably after merging #253 )
Make sure we:
- Switch to using either lists or vectors to work the same way, or we switch to using either one of the other
Options for notations:
Going back to lists
ad2 <- from_SingleCellExperiment(
sce,
x_mapping = "numeric_matrix",
obs_mapping = list("foo", "bar"),
var_mapping = list(),
obsm_mapping = list(),
obsp_mapping = list(),
varm_mapping = list(),
varp_mapping = list(),
uns_mapping = list()
)
Update documentation
ad2 <- from_SingleCellExperiment(
sce,
x_mapping = "numeric_matrix",
obs_mapping = c("foo", "bar"),
var_mapping = character(0),
obsm_mapping = character(0),
obsp_mapping = character(0),
varm_mapping = character(0),
varp_mapping = character(0),
uns_mapping = character(0)
)
TRUE/FALSE
ad2 <- from_SingleCellExperiment(
sce,
x_mapping = "numeric_matrix",
obs_mapping = c("foo", "bar"),
var_mapping = TRUE,
obsm_mapping = TRUE,
obsp_mapping = FALSE,
varm_mapping = FALSE,
varp_mapping = FALSE,
uns_mapping = FALSE
)
Allow specifying the default
ad2 <- from_SingleCellExperiment(
sce,
x_mapping = "numeric_matrix",
obs_mapping = c("foo", "bar"),
var_mapping = character(0),
obsm_mapping = character(0),
obsp_mapping = character(0),
varm_mapping = character(0),
varp_mapping = character(0),
uns_mapping = character(0),
copy_all_by_default = TRUE # or whatever interface you want this to have
)
Or support something like tidyselect https://dplyr.tidyverse.org/reference/select.html
Let's go with TRUE / FALSE!
- TRUE: Copy everything
- FALSE: Copy nothing
- Empty vectors / empty lists / NULL means the same as FALSE
- Non-empty character vector: Copy just these items
- Named non-empty character vectors: Copy just these items and rename them
New default would be TRUE