GeneSpec | R Documentation |
A GeneSpec
consists of the gene IDs (possibly named with labels),
the summary function and the name of the summary function.
new()
Creates a new GeneSpec
object.
GeneSpec$new(genes = NULL, fun = NULL, fun_name = deparse(substitute(fun)))
genes
(named character
or NULL
)
the gene IDs, where the names
are used as labels if available.
fun
(function
or NULL
)
summary function. If NULL
is
used then multiple genes are not summarized but returned as a matrix from the
extract
method.
fun_name
(string
)
name of the summary function.
A new GeneSpec
object.
get_genes()
Returns the genes.
GeneSpec$get_genes()
get_gene_labels()
Returns the gene labels (substituted by gene IDs if not available).
GeneSpec$get_gene_labels(genes = self$get_genes())
genes
(character
)
for which subset of genes the labels should be returned.
returns_vector()
Predicate whether the extract returns a vector or not.
GeneSpec$returns_vector()
get_label()
Returns a string which can be used e.g. for plot labels.
GeneSpec$get_label(genes = self$get_genes())
genes
(character
)
for which subset of genes the labels should be returned.
extract()
Extract the gene values from an assay as specified.
GeneSpec$extract(assay)
assay
(matrix
)
original matrix with rownames containing the
specified genes.
Either a vector with one value per column, or a matrix with multiple genes in the rows.
extract_data_frame()
Extract the gene values as a data.frame
.
GeneSpec$extract_data_frame(assay)
assay
(matrix
)
original matrix with rownames containing the
specified genes.
A data.frame
with the genes in the columns and the samples
in the rows.
clone()
The objects of this class are cloneable with this method.
GeneSpec$clone(deep = FALSE)
deep
Whether to make a deep clone.
# Minimal specification if only one gene is used.
x_spec <- gene_spec("GeneID:1820")
# Using multiple genes with a signature.
x_spec <- gene_spec(c("GeneID:1820", "GeneID:52"), fun = colMeans)
x_spec <- gene_spec(c("GeneID:1820", "GeneID:52"), fun = colPrinComp1)
x_spec$returns_vector()
x_spec$get_genes()
x_spec$get_gene_labels()
x_spec$get_label()
# Using multiple genes with partial labels, without a signature.
x_spec <- gene_spec(c(A = "GeneID:1820", "GeneID:52"))
x_spec$returns_vector()
x_spec$get_gene_labels()
# Use the gene specification to extract genes from a matrix.
mat <- matrix(
data = rpois(15, 10),
nrow = 3, ncol = 5,
dimnames = list(c("GeneID:1820", "GeneID:52", "GeneID:523"), NULL)
)
x_spec$extract(mat)
# We can also extract these as a `data.frame`.
x_spec$extract_data_frame(mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.