importData {scDataviz} | R Documentation

## Import a data-frame or matrix, and associated metadata, to a `SingleCellExperiment` object.

### Description

Import a data-frame or matrix, and associated metadata, to a `SingleCellExperiment` object.

### Usage

    importData(
      mat,
      assayname,
      metadata = NULL,
      downsampleVar = NULL,
      verbose = TRUE
    )

### Arguments

`mat` | A data-frame or matrix of expression values. Data-frames will be coerced to matrices.
`assayname` | Name of the `SingleCellExperiment` assay slot in which data will be stored.
`metadata` | Metadata associated with the data contained in 'mat'. A strict rule is enforced requiring that `rownames(metadata) == rownames(mat)`.
`downsampleVar` | Downsample based on variance. Removes this proportion of variables (rows) based on lesser variance. This is applied on a per sample basis. If user wishes to apply this globally on the final merged dataset, then set this to 0 and remove based on variance manually after object creation.
`verbose` | Boolean (TRUE / FALSE) to print messages to console or not.

### Details

Import a data-frame or matrix, and associated metadata, to a `SingleCellExperiment` object.

### Value

A `SingleCellExperiment` object.

### Author(s)

Kevin Blighe <kevin@clinicalbioinformatics.co.uk>

### Examples

    # create random data that follows a negative binomial
    mat <- jitter(matrix(
      MASS::rnegbin(rexp(50000, rate=.1), theta = 4.5),
      ncol = 20))
    colnames(mat) <- paste0('CD', 1:ncol(mat))
    rownames(mat) <- paste0('cell', 1:nrow(mat))

    metadata <- data.frame(
      group = rep('A', nrow(mat)),
      row.names = rownames(mat),
      stringsAsFactors = FALSE)

    sce <- importData(mat,
      assayname = 'normcounts',
      metadata = metadata)

[Package scDataviz version 1.4.0 Index]