M3D_ConverData: Convert Data to be suitable for M3Drop

M3DropConvertDataR Documentation

Convert Data to be suitable for M3Drop

Description

Recognizes a variety of R objects/classes and extracts expression matrices from them then converts that to a normalized but not-log transformed matrix appropriate for input into M3Drop functions.

Usage

  M3DropConvertData(input, is.log=FALSE, is.counts=FALSE, pseudocount=1)

Arguments

input

a matrix, data.frame or object

is.log

has the data been log-transformed? (assumes log-base 2 with pseudocount of 1)

is.counts

is the data raw unnormalized counts? (raw counts will be CPM normalized)

pseudocount

pseudocount added before log-transformation

Details

You must have loaded the respective packages (in parentheses) into your namespace before running this function on the respective objects. Note that to maintain scalability sparse matrices will remain as such.

Supported classes/objects:

SCESet (scater <= 1.4.0)

uses "exprs" or if unavailable then "counts"

SingleCellExperiment (scater >= 1.6.0)

uses "normcounts" if available, then "logcounts", which is assumed to be log-normalized, then "counts"

CellDataSet (monocle)

uses "exprs", specify log/counts using arguments

ExpressionSet (Biobase)

uses "exprs", specify log/counts using arguments

seurat (Seurat)

uses "raw.data" as counts.

Matrix/Dataframe classes :

dgCMatrix (Matrix)

specify log/counts using arguments

data.table (data.table)

specify log/counts using arguments

DataTable (S4Vectors)

specify log/counts using arguments

DataFrame (S4Vectors)

specify log/counts using arguments

AnnotatedDataFrame (Biobase)

specify log/counts using arguments

matrix (base-r)

specify log/counts using arguments

data.frame (base-r)

specify log/counts using arguments

Value

A normalized but not log-transformed matrix appropriate for input into M3Drop functions.

Examples

	# Simulated raw count matrix:
	set.seed(42)
	counts <- matrix(rpois(200, lambda=3), ncol=10)
	expr_mat <- M3DropConvertData(counts, is.counts=TRUE)

	# log normalized data frame
	lognorm <-log2( t(t(counts)/colSums(counts)*100)+1 )
	lognorm <- as.data.frame(lognorm)
	expr_mat <- M3DropConvertData(lognorm)

	# Sparse matrix
	require("Matrix")
	counts <- Matrix(counts, sparse=TRUE)
	expr_mat <- M3DropConvertData(counts, is.counts=TRUE)

	# SingleCellExperiment Object
	require("SingleCellExperiment")
	SCE <- SingleCellExperiment(assays=list(counts=counts))
	expr_mat <- M3DropConvertData(SCE)

	# monocle Object
	require("monocle")
	obj <- suppressWarnings(newCellDataSet(as.matrix(lognorm)))
	expr_mat <- M3DropConvertData(obj, is.log=TRUE)

tallulandrews/M3Drop documentation built on March 6, 2024, 1:49 a.m.