man/importAnnData.Rd
8a70b39e
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/importAnnData.R
 \name{importAnnData}
 \alias{importAnnData}
 \title{Create a SingleCellExperiment Object from Python AnnData .h5ad files}
 \usage{
d32b31c8
 importAnnData(
   sampleDirs = NULL,
   sampleNames = NULL,
   delayedArray = FALSE,
dfe50c33
   class = c("Matrix", "matrix"),
   rowNamesDedup = TRUE
d32b31c8
 )
8a70b39e
 }
 \arguments{
0ccddee1
 \item{sampleDirs}{Folder containing the .h5ad file. Can be one of -
8a70b39e
 \itemize{
   \item Default \code{current working directory}.
0ccddee1
   \item Full path to the directory containing the .h5ad file.
8a70b39e
   E.g \code{sampleDirs = '/path/to/sample'}
0ccddee1
   \item A vector of folder paths for the samples to import.
8a70b39e
   E.g. \code{sampleDirs = c('/path/to/sample1', '/path/to/sample2','/path/to/sample3')}
0ccddee1
   importAnnData will return a single SCE object containing all the samples
8a70b39e
   with the sample name appended to each colname in colData
 }}
 
0ccddee1
 \item{sampleNames}{The prefix/name of the .h5ad file without the .h5ad extension
8a70b39e
 e.g. if 'sample.h5ad' is the filename, pass \code{sampleNames = 'sample'}.
0ccddee1
 Can be one of -
8a70b39e
 \itemize{
   \item Default \code{sample}.
   \item A vector of samples to import. Length of vector must be equal to length of sampleDirs vector
   E.g. \code{sampleDirs = c('sample1', 'sample2','sample3')}
0ccddee1
   importAnnData will return a single SCE object containing all the samples
8a70b39e
   with the sample name appended to each colname in colData
 }}
 
 \item{delayedArray}{Boolean. Whether to read the expression matrix as
969718f9
 \link{DelayedArray} object. Default \code{FALSE}.}
d32b31c8
 
 \item{class}{Character. The class of the expression matrix stored in the SCE
 object. Can be one of "Matrix" (as returned by
 \link{readMM} function), or "matrix" (as returned by
 \link[base]{matrix} function). Default \code{"Matrix"}.}
558e269c
 
 \item{rowNamesDedup}{Boolean. Whether to deduplicate rownames. Default 
 \code{TRUE}.}
8a70b39e
 }
 \value{
 A \code{SingleCellExperiment} object.
 }
 \description{
0ccddee1
 This function reads in one or more Python AnnData files in the .h5ad format
 and returns a single \link[SingleCellExperiment]{SingleCellExperiment} object containing all the
8a70b39e
 AnnData samples by concatenating their counts matrices and related information slots.
 }
 \details{
 \code{importAnnData} converts scRNA-seq data in the AnnData format to the
0ccddee1
 \code{SingleCellExperiment} object. The .X slot in AnnData is transposed to the features x cells
8a70b39e
 format and becomes the 'counts' matrix in the assay slot. The .vars AnnData slot becomes the SCE rowData
 and the .obs AnnData slot becomes the SCE colData. Multidimensional data in the .obsm AnnData slot is
0ccddee1
 ported over to the SCE reducedDims slot. Additionally, unstructured data in the .uns AnnData slot is
 available through the SCE metadata slot.
 There are 2 currently known minor issues -
8a70b39e
 Anndata python module depends on another python module h5pyto read hd5 format files.
 If there are errors reading the .h5ad files, such as "ValueError: invalid shape in fixed-type tuple."
0ccddee1
 the user will need to do downgrade h5py by running \code{pip3 install --user h5py==2.9.0}
8a70b39e
 Additionally there might be errors in converting some python objects in the unstructured data slots.
 There are no known R solutions at present. Refer \url{https://github.com/rstudio/reticulate/issues/209}
 }
 \examples{
0ccddee1
 file.path <- system.file("extdata/annData_pbmc_3k", package = "singleCellTK")
31390a70
 \dontrun{
0ccddee1
 sce <- importAnnData(sampleDirs = file.path,
8a70b39e
                      sampleNames = 'pbmc3k_20by20')
 }
31390a70
 }