scverse / anndataR

AnnData interoperability in R
https://anndatar.data-intuitive.com
Other
57 stars 8 forks source link

Tidy user interface #159

Closed lazappi closed 1 month ago

lazappi commented 10 months ago

Tidy the user interface to reduce the exported functions to ones we think users should see.

Changes:

Todo:

lazappi commented 10 months ago

The test/example stuff I would like to do but requires a working Seurat converter. I think maybe it's easier to merge this first? The vignette would be nice but can be done later.

lazappi commented 10 months ago
rcannood commented 10 months ago

@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 AnnData()?

lazappi commented 9 months ago

Yes, I think so. I'll try to work on it, assuming I can work out how to implement as() properly.

lazappi commented 9 months ago

Ok, so using as() probably won't work for us because there is no way to provide additional arguments (which I think we need for things like setting which assay should be X).

Possible alternatives:

rcannood commented 9 months ago

There is no way to provide additional arguments

Good point, I hadn't considered that.

Something else

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 as_AnnData will be the inmemory one, which can be used to write to disk using write_h5ad. I do like having the conversion separate from the regular constructor, because then we need to include code to make sure that the obj and the [obs_names, var_names, X, varm, obsm, ... arguments are mutually exclusive while they might as well just be split into two different functions.

lazappi commented 9 months ago

Yeah, that could work. What about the reverse direction?

rcannood commented 3 months ago

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 adata$to_SingleCellExperiment() and adata$to_Seurat(). Is this what you mean?

lazappi commented 3 months ago

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.

rcannood commented 1 month ago

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.