NBumiConvertData | R Documentation |
Recognizes a variety of R objects/classes and extracts expression matrices from them then converts that to a count matrix for input into NBumi functions.
NBumiConvertData(input, is.log=FALSE, is.counts=FALSE, pseudocount=1)
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 |
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:
uses "counts" or if unavailable then "exprs"
uses "counts", if unavailable then "logcounts", which is assumed to be log-normalized.
uses "exprs", specify log/counts using arguments
uses "exprs", specify log/counts using arguments
uses "raw.data" as counts.
Matrix/Dataframe classes :
specify log/counts using arguments
specify log/counts using arguments
specify log/counts using arguments
specify log/counts using arguments
specify log/counts using arguments
specify log/counts using arguments
specify log/counts using arguments
Counts are rounded up to integers if necessary, if counts are unavailable then this will attempt to convert log2 normalized expression to counts by de-logging, subtracting the pseudocount, and then un-normalizing by rescaling cells based on their relative number of detected genes, finally expression is rounded up to integers for use as counts.
A count matrix appropriate for input into NBumi functions.
# Simulated raw count matrix:
set.seed(42)
counts <- matrix(rpois(200, lambda=3), ncol=10)
input_counts <- NBumiConvertData(counts, is.counts=TRUE)
# log normalized data frame
lognorm <-log2( t(t(counts)/colSums(counts)*100)+1 )
lognorm <- as.data.frame(lognorm)
input_counts <- NBumiConvertData(lognorm)
# Sparse matrix
require("Matrix")
counts <- Matrix(counts, sparse=TRUE)
input_counts <- NBumiConvertData(counts, is.counts=TRUE)
# SingleCellExperiment Object
require("SingleCellExperiment")
SCE <- SingleCellExperiment(assays=list(counts=counts))
input_counts <- NBumiConvertData(SCE)
# monocle Object
require("monocle")
obj <- suppressWarnings(newCellDataSet(as.matrix(lognorm)))
input_counts <- NBumiConvertData(obj, is.log=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.