Skip to content

Add a mapping_spec class/function #336

@lazappi

Description

@lazappi

Add a mapping_spec function that returns the automatic slot mapping for a conversion (similar to readr::spec()). It would return a mapping_spec object that is a list with a nice print output, something like:

Mapping spec for `AnnData` to `Seurat`:
	x_mapping: "X"
	layers_mapping:
		counts: "counts"
		lognorm: "lognorm"
	object_metadata_mapping:
		batch: batch
		cell_type: "cell_type"

The main use would be to let users see what the default mapping is but it also be useful as a starting point for constructing a custom mapping. We could also add arguments to the conversion functions that accept the mapping_spec (ignoring the other mapping arguments).

Possible usage examples:

# Create a `mapping_spec` object
mapping_spec(adata, as = "Seurat")
mapping_spec(seurat, as = "AnnData")

# Use `mapping_spec` instead of mapping arguments
adata$as_Seurat(mapping_spec = mapping_spec)
as_AnnData(sce, mapping_spec = mapping_spec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions