Repository navigation
Conversation
Also standardise argument names
Minor changes so it works with Seurat
|
The test/example stuff I would like to do but requires a working |
There was a problem hiding this comment.
I think most of these changes I can totally agree with.
The only thing that I don't fully agree with is using AnnData(...) to create AnnData objects as well as convert SCE or Seurat to an InMemoryAnnData.
- To me, this seems like two different functionalities which should be provided by different functions
- In doing so, we're not able to convert SCE or Seurat directly into an HDF5AnnData anymore, making the whole operation less memory efficient.
How about we create the following functions instead:
AnnData <- function(
obs_names = NULL,
var_names = NULL,
X = NULL,
varm = NULL,
obsp = NULL,
varp = NULL,
uns = NULL,
output_class = c("InMemoryAnnData", "HDF5AnnData",
...) {
fun <- get_anndata_constructor(output_class)
fun(
obs_names = obs_names,
var_names = var_names,
X = X,
obs = obs,
var = var,
layers = layers,
obsm = obsm,
varm = varm,
obsp = obsp,
varp = varp,
uns = uns,
...
)
}
as_AnnData <- function(obj, output_class = c("InMemoryAnnData", "HDF5AnnData")) {
UseMethod("as_AnnData")
}
as_AnnData.SingleCellExperiment <- function(obj, output_class = c("InMemoryAnnData", "HDF5AnnData")) {
from_SingleCellExperiment(obj, output_class)
}
as_AnnData.Seurat <- function(obj, output_class = c("InMemoryAnnData", "HDF5AnnData")) {
from_Seurat(obj, output_class)
}Or simply:
as_AnnData <- function(obj, output_class = c("InMemoryAnnData", "HDF5AnnData")) {
if (inherits(obj, "SingleCellExperiment")) {
from_SingleCellExperiment(obj, output_class)
} else if (inherits(obj, "Seurat")) {
from_Seurat(obj, output_class)
} else {{
stop("No implementation for converting object of class ", class(obj))
}
}WDYT?
|
|
@lazappi Just to confirm, after what we discussed, do you agree with the following?
I'd like to merge this PR because I agree that it'd be nice to clean up our list of exports. Would you be able to make the changes to |
|
Yes, I think so. I'll try to work on it, assuming I can work out how to implement |
|
Ok, so using Possible alternatives:
|
Good point, I hadn't considered that.
Would you be ok with splitting it up into: AnnData <- function(
obs_names = NULL,
var_names = NULL,
X = NULL,
obs = NULL,
var = NULL,
obsm = NULL,
varm = NULL,
obsp = NULL,
varp = NULL,
uns = NULL,
output_class = c("InMemoryAnnData", "HDF5AnnData",
...
)And as_AnnData <- function(
obj,
output_class = c("InMemoryAnnData", "HDF5AnnData"),
...
)? This way, the default |
|
Yeah, that could work. What about the reverse direction? |
|
I'm not sure what you mean by the reverse direction. Oh, you mean when we want to convert an AnnData to SCE or Seurat? We can call |
|
I can't remember exactly but I think so, yes. I think we discussed and I wanted to avoid exposing these directly but I can't remember all the details. |
|
I'm going to port these changes to a different branch because there are too many conflicts by now (sorry about that!) In summary, I will:
Objects that will be removed from the NAMESPACE:
At some point in the future, we should create a separate roxygen doc or a vignette to explain what the different possible conversions are. |
Tidy the user interface to reduce the exported functions to ones we think users should see.
Changes:
AnnData()to acceptSCE/Seurat(replacingfrom_*functions)generate_dataset()Todo:
AnnData()withSCE/Seuratinputread_h5ad()/write_h5ad()tests