ExtractSelection | R Documentation |
Extract and rename matrix columns.
ExtractSelection(M, cols, rows = NULL, meta = NULL)
M |
matrix. |
cols |
list. |
rows |
optional. |
meta |
optional data.frame. |
ExtractSelection
returns a matrix
.
meta <- data.frame(
antibody = gl(2, 2, 8, labels = c("H3", "IgG")),
genotype = gl(2, 1, 8, labels = c("WT", "mutant")),
replicate = gl(2, 4, 8, labels = c("R1", "R2"))
)
rownames(meta) <- apply(meta, 1, paste, collapse = "_")
M <- matrix(1:80, 10, 8, dimnames = list(NULL, rownames(meta)))
n <- ncol(M)
# Column selection by name or with logical expression on metadata
ExtractSelection(
M, meta = meta, cols = list(
x = antibody == "H3" & genotype == "WT", y = c("IgG_WT_R1", "IgG_WT_R2")
)
)
ExtractSelection(
M, meta = meta, cols = list(
x = c("H3_WT_R1", "H3_WT_R2"), y = antibody == "IgG" & genotype == "WT"
)
)
# Internal order of extracted columns is determined by metadata
ExtractSelection(
M[, n:1], meta = meta[1:n, ], cols = list(
x = antibody == "H3" & genotype == "WT",
y = antibody == "IgG" & genotype == "WT"
)
)
ExtractSelection(
M[, 1:n], meta = meta[n:1, ], cols = list(
x = antibody == "H3" & genotype == "WT",
y = antibody == "IgG" & genotype == "WT"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.