Skip to content

Commit

Permalink
Refactor from/to Seurat conversion (#183)
Browse files Browse the repository at this point in the history
* wip new seurat conversion

* fix var

* fix test

* style pkg

* refactor seurat approach

* add graph mappings

* update to_Seurat function

* update from_Seurat

* add assay name to helper functions

* improve to_seurat docs

* improvements to seurat docs

* update documentation

* run styler

* make sure that assay meta.data ends up in the output

* fix unit test

* fix to_seurat

* add to_seurat test

* update docs and styler

* add seurat to suggests

* remove biocstyle from vignette

* fix variable

* fix guess_varms

* do not export to/from_Seurat helper functions

* roxygen

* remove accidental comment

* fix links

* undo changes not related to seurat

* add more info to layer mapping

* Update R/Seurat.R

Co-authored-by: Luke Zappia <[email protected]>

* Apply suggestions from code review

Co-authored-by: Luke Zappia <[email protected]>

* update descriptions

* map all uns to misc my default

* use `check_requires` to check required packages

* roxygenise

* simplify flow

* improve readability

* change warning into stop

* remove do.call

* clarify

* address comments

* fix imports

* styler

* fix check_requires if packages are on bioconductor

* uniformise notation

* apply suggestions from review

* apply suggestions

* Apply suggestions from code review

Co-authored-by: Luke Zappia <[email protected]>

* apply suggestions from review

* trycatch generator

* restyle

* fix guess function

* Update R/Seurat.R

Co-authored-by: Luke Zappia <[email protected]>

---------

Co-authored-by: Luke Zappia <[email protected]>
  • Loading branch information
rcannood and lazappi authored Nov 12, 2024
1 parent 60f7d7b commit 1d07188
Show file tree
Hide file tree
Showing 11 changed files with 1,157 additions and 161 deletions.
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ BugReports: https://github.com/scverse/anndataR/issues
Depends:
R (>= 4.0.0)
Imports:
cli,
Matrix,
methods,
R6
purrr,
R6,
rlang
Suggests:
anndata,
BiocStyle,
Expand All @@ -73,6 +76,7 @@ Suggests:
hdf5r (>= 1.3.11),
rmarkdown,
S4Vectors,
Seurat,
SeuratObject,
SingleCellExperiment,
SummarizedExperiment,
Expand Down
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@ export(from_Seurat)
export(from_SingleCellExperiment)
export(generate_dataset)
export(read_h5ad)
export(to_Seurat)
export(write_h5ad)
importFrom(Matrix,as.matrix)
importFrom(Matrix,sparseMatrix)
importFrom(Matrix,t)
importFrom(R6,R6Class)
importFrom(cli,cli_abort)
importFrom(cli,cli_inform)
importFrom(cli,cli_warn)
importFrom(methods,as)
importFrom(methods,new)
importFrom(purrr,map_lgl)
importFrom(rlang,caller_env)
13 changes: 10 additions & 3 deletions R/HDF5AnnData.R
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ HDF5AnnData <- R6::R6Class("HDF5AnnData", # nolint
shape = NULL,
mode = c("r", "r+", "a", "w", "w-", "x"),
compression = c("none", "gzip", "lzf")) {
if (!requireNamespace("hdf5r", quietly = TRUE)) {
stop("The HDF5 interface requires the 'hdf5r' package to be installed")
}
check_requires("HDF5AnnData", "hdf5r")

# check arguments
compression <- match.arg(compression)
Expand Down Expand Up @@ -446,3 +444,12 @@ to_HDF5AnnData <- function(
mode = mode
)
}

cleanup_HDF5AnnData <- function(...) { # nolint object_name_linter
args <- list(...)

if (!is.null(args$file) && is.character(args$file) && file.exists(args$file)) {
cli::cli_alert("Removing file: ", args$file)
unlink(args$file)
}
}
Loading

0 comments on commit 1d07188

Please sign in to comment.