Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Authors@R: c(
person("scverse consortium", role = "spn")
)
Description: Bring the power and flexibility of AnnData to the R
ecosystem, allowing you to effortlessly manipulate and analyze your
ecosystem, allowing you to effortlessly manipulate and analyse your
single-cell data. This package lets you work with backed h5ad and zarr
files, directly access various slots (e.g. X, obs, var), or convert
the data into SingleCellExperiment and Seurat objects.
Expand Down Expand Up @@ -54,6 +54,7 @@ Suggests:
Seurat,
SeuratObject,
SingleCellExperiment,
spelling,
SummarizedExperiment,
testthat (>= 3.0.0),
vctrs,
Expand All @@ -67,3 +68,4 @@ Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE, r6 = TRUE)
RoxygenNote: 7.3.3
Language: en-GB
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
- Bump required R version to 4.5 in preparation for Bioconductor submission
(PR #309)
- Remove deprecated functions and arguments (PR #311, PR #313)
- Minor cleanups and improvements (PR #313).
- Minor clean-ups and improvements (PR #313).
- Add more tests to increase coverage (PR #315)

# anndataR 0.2.0
Expand Down Expand Up @@ -123,7 +123,7 @@
- Most round trip tests are now enabled and pass successfully
- Conversion helpers have been added to assist with **{reticulate}** tests

# anndataR 0.1.0 (inital release candidate)
# anndataR 0.1.0 (initial release candidate)

Initial release candidate of **{anndataR}** including:

Expand Down
8 changes: 4 additions & 4 deletions R/AbstractAnnData-s3methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
#' making them behave like native R objects with familiar syntax.
#'
#' @details
#' **Subsetting behavior**: The `[` method supports logical, integer, and character
#' **Subsetting behaviour**: The `[` method supports logical, integer, and character
#' subsetting for both observations (rows) and variables (columns). However, unlike
#' standard R behavior:
#' standard R behaviour:
#'
#' - Logical vectors are **not recycled** and must have the exact same length as
#' the dimension being subset
#' - **Negative indices are not supported** (R's "exclude these" syntax)
#'
#' These design choices ensure clear and predictable subsetting behavior for
#' These design choices ensure clear and predictable subsetting behaviour for
#' biological data matrices, avoiding potential confusion from accidental recycling
#' or exclusion patterns.
#'
Expand Down Expand Up @@ -111,7 +111,7 @@ dimnames.AbstractAnnData <- function(x) {
`dimnames<-.AbstractAnnData` <- function(x, value) {
if (is.null(value)) {
# When dimnames(x) <- NULL, generate default sequential names
# This mimics Python AnnData behavior but uses 1-based indexing (R convention)
# This mimics Python AnnData behaviour but uses 1-based indexing (R convention)
# instead of 0-based indexing (Python convention)
x$obs_names <- as.character(seq_len(x$n_obs()))
x$var_names <- as.character(seq_len(x$n_vars()))
Expand Down
36 changes: 36 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
AbstractAnnData
AnnData
AnnDataView
Bioc
BiocCheck
BiocManager
CMD
HDF
InMemoryAnnData
LZF
Lifecycle
ORCID
R's
ReticulateAnnData
SCE
Seurat
SeuratObject
SingleCellExperiment
Zarr
anndata
dynverse
hdf
knitr
mudata
obs
png
py
rhdf
scanpy
scverse
theislab
transcriptomics
var
vars
zarr
zellkonverter
6 changes: 3 additions & 3 deletions man/AbstractAnnData-s3methods.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/anndataR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions tests/spelling.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (requireNamespace("spelling", quietly = TRUE)) {
spelling::spell_check_test(
vignettes = TRUE,
error = FALSE,
skip_on_cran = TRUE
)
}
16 changes: 9 additions & 7 deletions vignettes/anndataR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ BiocManager::install("anndataR")

# Usage

These sections breifly show how to use `r Biocpkg("anndataR")`.
These sections briefly show how to use `r Biocpkg("anndataR")`.

## Read from disk

Expand All @@ -79,13 +79,13 @@ By default, a H5AD is read to an in-memory `AnnData` object:
adata <- read_h5ad(h5ad_path)
```

It can also be read as a `SingleCellExperiment` object:
It can also be read as a `SingleCellExperiment` object (see `vignette("usage_singlecellexperiment")`):

```{r read-as-SingleCellExperiment}
sce <- read_h5ad(h5ad_path, as = "SingleCellExperiment")
```

Or as a `Seurat` object:
Or as a `Seurat` object (see `vignette("usage_seurat")`):

```{r read-as-Seurat}
obj <- read_h5ad(h5ad_path, as = "Seurat")
Expand All @@ -97,6 +97,8 @@ There is also a HDF5-backed `AnnData` object:
adata <- read_h5ad(h5ad_path, as = "HDF5AnnData")
```

See `r vignette("usage_python")` for interacting with a Python `AnnData` via `r CRANpkg("reticulate")`.

## Using `AnnData` objects

View structure:
Expand All @@ -118,28 +120,28 @@ See ```?`AnnData-usage` ```for more details on how to work with `AnnData` object

## Interoperability

Convert the `AnnData` object to a `SingleCellExperiment` object:
Convert the `AnnData` object to a `SingleCellExperiment` object (see `vignette("usage_singlecellexperiment")`):

```{r as-SingleCellExperiment}
sce <- adata$as_SingleCellExperiment()
sce
```

Convert the `AnnData` object to a `Seurat` object:
Convert the `AnnData` object to a `Seurat` object (see `vignette("usage_seurat")`):

```{r as-Seurat}
obj <- adata$as_Seurat()
obj
```

Convert a `SingleCellExperiment` object to an `AnnData` object:
Convert a `SingleCellExperiment` object to an `AnnData` object (see `vignette("usage_singlecellexperiment")`):

```{r as-AnnData-from-SingleCellExperiment}
adata <- as_AnnData(sce)
adata
```

Convert a `Seurat` object to an `AnnData` object:
Convert a `Seurat` object to an `AnnData` object (see `vignette("usage_seurat")`):

```{r as-AnnData-from-Seurat}
adata <- as_AnnData(obj)
Expand Down
16 changes: 8 additions & 8 deletions vignettes/usage_python.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,20 @@ sc$pp$log1p(adata)

# Conversion to R objects

Convert to `Seurat`:

```{r convert_to_seurat}
seurat_obj <- adata$as_Seurat()
print(seurat_obj)
```

Convert to `SingleCellExperiment`:
Convert to `SingleCellExperiment` (see `vignette("usage_singlecellexperiment")`):

```{r convert_to_sce}
sce_obj <- adata$as_SingleCellExperiment()
print(sce_obj)
```

Convert to `Seurat` (see `vignette("usage_seurat")`):

```{r convert_to_seurat}
seurat_obj <- adata$as_Seurat()
print(seurat_obj)
```

# Multi-modal data with _mudata_

Install required Python packages if needed:
Expand Down
14 changes: 7 additions & 7 deletions vignettes/usage_seurat.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ install.packages("Seurat")

Using an example `.h5ad` file included in the package, we will demonstrate how to read an `.h5ad` file and convert it to a `Seurat` object.

```{r prep_file}
```{r prep-file}
library(anndataR)
library(Seurat)

Expand All @@ -45,14 +45,14 @@ h5ad_file <- system.file("extdata", "example.h5ad", package = "anndataR")

Read the `.h5ad` file as a `Seurat` object:

```{r read_data}
```{r read-data}
seurat_obj <- read_h5ad(h5ad_file, as = "Seurat")
seurat_obj
```

This is equivalent to reading in the `.h5ad` file as an `AnnData` and explicitly converting:

```{r convert_seurat}
```{r convert-seurat}
adata <- read_h5ad(h5ad_file)
seurat_obj <- adata$as_Seurat()
seurat_obj
Expand Down Expand Up @@ -85,7 +85,7 @@ Each of the mapping arguments can be provided with one of the following:

See `?as_Seurat` for more details on how to customize the conversion process. For instance:

```{r customize_seurat_conversion}
```{r customize-seurat-conversion}
seurat_obj <- adata$as_Seurat(
layers_mapping = c("counts", "dense_counts"),
object_metadata_mapping = c(metadata1 = "Int", metadata2 = "Float"),
Expand All @@ -106,13 +106,13 @@ The mapping arguments can also be passed directly to `read_h5ad()`.

The reverse conversion is also possible, allowing you to convert the `Seurat` object back to an `AnnData` object, or to just write out the `Seurat` object as an `.h5ad` file.

```{r write_seurat}
```{r write-seurat}
write_h5ad(seurat_obj, tempfile(fileext = ".h5ad"))
```

This is equivalent to converting the `Seurat` object to an `AnnData` object and then writing it out:

```{r convert_to_anndata}
```{r convert-to-anndata}
adata <- as_AnnData(seurat_obj)
adata$write_h5ad(tempfile(fileext = ".h5ad"))
```
Expand All @@ -122,7 +122,7 @@ For more details, see `?as_AnnData`.

Here's an example:

```{r customize_anndata_conversion}
```{r customize-anndata-conversion}
adata <- as_AnnData(
seurat_obj,
assay_name = "RNA",
Expand Down
14 changes: 7 additions & 7 deletions vignettes/usage_singlecellexperiment.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ BiocManager::install("SingleCellExperiment")

Using an example `.h5ad` file included in the package, we will demonstrate how to read an `.h5ad` file and convert it to a `SingleCellExperiment` object.

```{r prep_h5ad_file}
```{r prep-h5ad-file}
library(anndataR)
library(SingleCellExperiment)

Expand All @@ -48,14 +48,14 @@ h5ad_file <- system.file("extdata", "example.h5ad", package = "anndataR")

Read the `.h5ad` file as a `SingleCellExperiment` object:

```{r read_data}
```{r read-data}
sce_obj <- read_h5ad(h5ad_file, as = "SingleCellExperiment")
sce_obj
```

This is equivalent to reading in the `.h5ad` file as an `AnnData` and explicitly converting:

```{r read_h5ad}
```{r read-h5ad}
adata <- read_h5ad(h5ad_file)
sce <- adata$as_SingleCellExperiment()
sce
Expand Down Expand Up @@ -86,7 +86,7 @@ Each of the mapping arguments can be provided with one of the following:

See `?as_SingleCellExperiment` for more details on how to customize the conversion process. For instance:

```{r ex_mapping}
```{r ex-mapping}
adata$as_SingleCellExperiment(
x_mapping = "counts",
assays_mapping = c("csc_counts"),
Expand All @@ -108,13 +108,13 @@ The mapping arguments can also be passed directly to `read_h5ad()`.

The reverse conversion is also possible, allowing you to convert a `SingleCellExperiment` object back to an `AnnData` object, or to just write out the `SingleCellExperiment` object as an `.h5ad` file.

```{r write_Seurat}
```{r write-sce}
write_h5ad(sce_obj, tempfile(fileext = ".h5ad"))
```

This is equivalent to converting the `SingleCellExperiment` object to an `AnnData` object and then writing it out:

```{r convert_and_write}
```{r convert-and-write}
adata <- as_AnnData(sce_obj)
adata$write_h5ad(tempfile(fileext = ".h5ad"))
```
Expand All @@ -123,7 +123,7 @@ You can again customize the conversion process by providing specific mappings fo

Here's an example:

```{r customize_anndata_conversion}
```{r customize-anndata-conversion}
as_AnnData(
sce_obj,
x_mapping = "counts",
Expand Down