sedesign_to_factors | R Documentation |
Convert SEDesign to data.frame of design factors
sedesign_to_factors(
sedesign,
se = NULL,
factor_names = NULL,
factor_sep = "_",
default_order = c("appearance", "mixedSort"),
verbose = FALSE,
...
)
sedesign |
|
se |
|
factor_names |
|
factor_sep |
|
default_order |
|
verbose |
|
This function is a utility function intended to convert SEDesign
objects, which contain a design matrix, into a data.frame
representing the experimental design factors used to produce
the design matrix.
data.frame
with one column for each experiment design factor,
where each column is converted to factor
for non-numeric columns,
and where colnames are defined as follows:
use factor_colnames
when supplied
use the corresponding column in colData(se)
when se
is supplied
use factor#
format for all other columns
Other jam experiment design:
check_sedesign()
,
contrast2comp()
,
contrast_colors_by_group()
,
contrast_names_to_sedesign()
,
contrasts_to_factors()
,
contrasts_to_venn_setlists()
,
draw_oneway_contrast()
,
draw_twoway_contrast()
,
filter_contrast_names()
,
groups_to_sedesign()
,
plot_sedesign()
,
validate_sedesign()
isamples_1 <- paste0(
rep(c("DMSO", "Etop", "DMSO", "Etop"), each=6),
"_",
rep(c("NF", "Flag"), each=12),
"_",
rep(c("WT", "KO", "WT", "KO", "WT", "D955N", "WT", "D955N"), each=3),
"_",
LETTERS[1:3])
# simple data.frame with group information
idf <- data.frame(jamba::rbindList(strsplit(isamples_1, "_")))[,1:3]
rownames(idf) <- isamples_1;
# convert to sedesign
sedesign <- groups_to_sedesign(idf)
plot_sedesign(sedesign, axis1=2, axis2=3, axis3=1, label_cex=0.5)
# prepare colData data.frame
cdf <- data.frame(check.names=FALSE, stringsAsFactors=FALSE,
jamba::rbindList(strsplit(isamples_1, "_")))
colnames(cdf) <- c("Treatment", "Flag", "Genotype", "Rep")
rownames(cdf) <- sedesign@samples;
cdf
# prepare assay matrix
imatrix <- matrix(data=seq_len(nrow(cdf) * 10), ncol=nrow(cdf));
colnames(imatrix) <- rownames(cdf);
rownames(imatrix) <- paste0("row", 1:10);
# prepare se
se <- SummarizedExperiment::SummarizedExperiment(
assays=list(raw=imatrix),
colData=cdf)
sedesign_to_factors(sedesign, se=se)
# confirm first column contains proper factor order
sedesign_to_factors(sedesign, se=se)[,1]
# demonstrate reverse order of Treatment column levels
SummarizedExperiment::colData(se)$Treatment <- factor(
SummarizedExperiment::colData(se)$Treatment,
levels=c("Etop", "DMSO"))
sedesign_to_factors(sedesign, se=se)[,1]
# define Treatment column levels again
SummarizedExperiment::colData(se)$Treatment <- factor(
SummarizedExperiment::colData(se)$Treatment,
levels=c("DMSO", "Etop"))
sedesign_to_factors(sedesign, se=se)[,1]
# provide specific colnames to use from se object
sedesign_to_factors(sedesign,
se=se,
factor_names=c("Treatment", "Flag", "Genotyoe"))
sedesign_to_factors(sedesign,
se=se,
factor_names=c("Treatment", "Flag", "Genotyoe"))[,1]
# substring of colnames(colData(se)) is acceptable
sedesign_to_factors(sedesign,
factor_names=c("Treat", "Flag", "Genotyoe"),
se=se)[,1]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.