From bffaf33d39bb7ae1b9b1098a62fdd8af13349931 Mon Sep 17 00:00:00 2001 From: Louise Deconinck <36621934+LouiseDck@users.noreply.github.com> Date: Tue, 19 Sep 2023 12:46:56 +0200 Subject: [PATCH] Use Bioconductor vignette standards (#112) * Use Bioconductor vignette standards * Fix DESCRIPTION * Linting indentation typo * Run styler and fix lintr issues * Apply suggestions from code review Co-authored-by: Robrecht Cannoodt --------- Co-authored-by: Robrecht Cannoodt --- DESCRIPTION | 1 + R/write_h5ad.R | 2 +- man/write_h5ad.Rd | 2 +- vignettes/getting-started.Rmd | 37 ++++++++++++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cec7d974..c9b5b0a8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -54,6 +54,7 @@ Imports: R6 Suggests: anndata, + BiocStyle, knitr, reticulate, rhdf5, diff --git a/R/write_h5ad.R b/R/write_h5ad.R index c1fb0411..df3e2c98 100644 --- a/R/write_h5ad.R +++ b/R/write_h5ad.R @@ -30,7 +30,7 @@ #' ncells <- 100 #' counts <- matrix(rpois(20000, 5), ncol = ncells) #' logcounts <- log2(counts + 1) -#' # +#' #' pca <- matrix(runif(ncells * 5), ncells) #' tsne <- matrix(rnorm(ncells * 2), ncells) #' diff --git a/man/write_h5ad.Rd b/man/write_h5ad.Rd index f47d835c..9247ca6b 100644 --- a/man/write_h5ad.Rd +++ b/man/write_h5ad.Rd @@ -39,7 +39,7 @@ if (requireNamespace("SingleCellExperiment", quietly = TRUE)) { ncells <- 100 counts <- matrix(rpois(20000, 5), ncol = ncells) logcounts <- log2(counts + 1) - # + pca <- matrix(runif(ncells * 5), ncells) tsne <- matrix(rnorm(ncells * 2), ncells) diff --git a/vignettes/getting-started.Rmd b/vignettes/getting-started.Rmd index f35a3289..360b4497 100644 --- a/vignettes/getting-started.Rmd +++ b/vignettes/getting-started.Rmd @@ -1,8 +1,15 @@ --- -title: "Getting Started" -output: rmarkdown::html_vignette +title: "Using anndataR to read and convert" +shorttitle: "Using anndataR" +author: + - name: Robrecht Cannoodt + - name: Luke Zappia + - name: Martin Morgan + - name: Louise Deconinck +package: anndataR +output: BiocStyle::html_document vignette: > - %\VignetteIndexEntry{Getting Started} + %\VignetteIndexEntry{Using anndataR to read and convert} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- @@ -14,10 +21,24 @@ knitr::opts_chunk$set( ) ``` +# Introduction + This package allows users to work with `.h5ad` files, access various slots in the datasets and convert these files to `SingleCellExperiment` objects and `SeuratObject`s, and vice versa. Check out `?anndataR` for a full list of the functions provided by this package. +# Installation + +Install using: +```{r, eval = FALSE} +if (!require("BiocManager", quietly = TRUE)) { + install.packages("BiocManager") +} +BiocManager::install("anndataR") +``` + +# Usage + This package provides an abstract interface for `AnnData` objects. This abstract interface models its Python counterpart closely, and stores a data matrix `X` and annotations corresponding to observations (`obs`, `obsm`, `obsp`) and variables (`var`, `varm`, `varp`) and unstructured metadata `uns`. @@ -30,6 +51,8 @@ This abstract interface is implemented by different backends. Currently, the fol The `InMemoryAnnData` backend allows you to construct an `AnnData` object in memory. The `HDF5AnnData` backend allows you to read in an `AnnData` object from an `.h5ad` file. +## `HDF5AnnData` backend + Here is an example of how to read in an `.h5ad` file. ```{r setup} @@ -49,6 +72,8 @@ obs <- adata$obs var <- adata$var ``` +## `InMemoryAnnData` backend + The following example details how to construct an InMemoryAnnData and access its contents. ```{r inmemory_construct} @@ -81,3 +106,9 @@ sce <- to_SingleCellExperiment(adata) seurat <- to_Seurat(adata) ``` +# Session info + +```{r} +sessionInfo() +``` +