saveReference: Save a reference dataset

View source: R/saveReference.R

saveReferenceR Documentation

Save a reference dataset

Description

Save a reference dataset to disk, usually in preparation for upload via uploadDirectory.

Usage

saveReference(x, labels, path, metadata)

Arguments

x

Matrix of log-normalized expression values. This may be sparse or dense, but should be non-integer and have no missing values. Row names should be present and unique for all rows.

labels

DataFrame of labels. Each row of labels corresponds to a column of x and contains the label(s) for that column. Each column of labels represents a different label type; typically, the column name has a label. prefix to distinguish between, e.g., label.fine, label.broad and so on. At least one column should be present.

path

String containing the path to a directory in which to save x.

metadata

Named list containing metadata for this reference dataset, see the schema returned by fetchMetadataSchema(). Note that the applications.takane property will be automatically added by this function and does not have to be supplied.

Details

The SummarizedExperiment saved to path is guaranteed to have the "logcounts" assay and at least one column in labels. This mirrors the expectation for reference datasets obtained via fetchReference.

Value

x and labels are used to create a SummarizedExperiment that is saved into path. NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

uploadDirectory, to upload the saved dataset to the gypsum backend.

fetchReference, to download an existing dataset into the current sesssion.

Examples

# Mocking up some data to be saved.
x <- matrix(rnorm(1000), ncol=10)
rownames(x) <- sprintf("GENE_%i", seq_len(nrow(x)))
labels <- DataFrame(
    labels.broad = sample(c("B", "T", "NK"), ncol(x), replace=TRUE),
    labels.fine = sample(c("PC", "pre-B", "pro-B", "Th2", "CD4+T", "NK"), 
        ncol(x), replace=TRUE)
)

# Making up some metadata as well.
meta <- list(
    title="New reference dataset",
    description="This is a new reference dataset, generated from blah blah.",
    genome="GRCm38",
    taxonomy_id="10090",
    sources=list(
        list(provider="GEO", id="GSE123456"),
        list(provider="PubMed", id="123456"),
        list(provider="URL", id="https://reference.data.com", version="2024-02-26")
    ),
    maintainer_name="Chihaya Kisaragi",
    maintainer_email="kisaragi.chihaya@765.com"
)

# Actually saving it.
tmp <- tempfile()
saveReference(x, labels, tmp, meta)

# Reloading it to make sure it looks good.
alabaster.base::readObject(tmp)
str(jsonlite::fromJSON(file.path(tmp, "_bioconductor.json")))


LTLA/celldex documentation built on April 29, 2024, 4:34 p.m.