#' Generate metadata as S4 object
#'
#' This function converts metadata dataframes to S4 object. It assumes that the format
#' as generated by gen_sample_sheets() in gmeta package. It requires both archr and sample
#' metadata dataframes.
#'
#' @param archr_meta archR readme dataframe.
#' @param sample_meta sample metadata sheet.
#' @return S4 object of the two dataframes.
#' @examples
#' gen_meta_obj(archr_meta, sample_meta)
#' @export
gen_meta_obj <- function(archr_meta, sample_meta) {
setClass("archr",
slots = list(point.person = "character",
date = "character",
notes = "character",
taxonomy = "character",
metric = "vector",
threshold = "vector",
batch = "vector",
study = "character",
load = "vector",
cells.prefilter = "character",
cells.postfilter = "character"))
setMethod("show",
"archr",
function(object) {
cat("point.person:",object@point.person, "\n")
cat("date:",object@date, "\n")
cat("notes:", object@notes, "\n")
cat("taxonomy:", object@taxonomy, "\n")
cat("metric:", object@metric, "\n")
cat("batch:", object@batch, "\n")
cat("study:", object@study, "\n")
cat("load:", object@load, "\n")
cat("cells.prefilter:", object@cells.prefilter, "\n")
cat("cells.postfilter:", object@cells.postfilter, "\n")
})
archr.obj <- new("archr",
point.person = archr_meta$Point_person,
date = archr$Date,
notes = archr_meta$Notes,
taxonomy = archr_meta$Taxonomy,
metric = archr_meta$Metric,
threshold = archr_meta$Threshold,
batch = archr_meta$Batch,
study = archr_meta$Study,
load = archr_meta$Load,
cells.prefilter = archr_meta$Cell_PreFilter,
cells.postfilter = archr_meta$Cell_PostFilter)
meta.obj <- list(sample.metadata = sample_meta, archR = archr.obj)
return(meta.obj)
}
#' get metadata sample sheets in the right format
#'
#' @return sample_metadata.txt and archr_metadata.txt files
#' @examples
#' gen_sample_sheets()
#' @export
gen_sample_sheets <- function() {
sample.meta <- data.frame(matrix(vector(),ncol=7))
colnames(sample.meta) <-c("Studies", "Batch_vendor_name", "Load_name", "Donor_name", "Age", "Sex", "ROI")
write.table(sample.meta, file = "sample_metadata.txt", quote = FALSE, sep = "\t", row.names = FALSE)
archr_meta <- data.frame(matrix(vector(),ncol=11))
colnames(archr_meta) <-c("Point_person", "Date", "Notes", "Taxonomy",
"Metric", "Threshold", "Batch", "Study", "Load",
"Cell_PreFilter", "Cell_PostFilter")
write.table(archr_meta, file = "archr_metadata.txt", quote = FALSE, sep = "\t", row.names = FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.