Package 'alabaster.ranges'

Title: Load and Save Ranges-related Artifacts from File
Description: Save GenomicRanges, IRanges and related data structures into file artifacts, and load them back into memory. This is a more portable alternative to serialization of such objects into RDS files. Each artifact is associated with metadata for further interpretation; downstream applications can enrich this metadata with context-specific properties.
Authors: Aaron Lun [aut, cre]
Maintainer: Aaron Lun <[email protected]>
License: MIT + file LICENSE
Version: 1.5.2
Built: 2024-07-23 02:42:38 UTC
Source: https://github.com/bioc/alabaster.ranges

Help Index


Load an atomic vector list

Description

Load a list of atomic vectors as a CompressedAtomicList from its on-disk representation. This is usually not directly called by users, but is instead called by dispatch in readObject.

Usage

readAtomicVectorList(path, metadata, ...)

Arguments

path

String containing a path to a directory, itself created with the saveObject method for CompressedAtomicLists.

metadata

Named list of metadata for this object, see readObjectFile for details.

...

Further arguments, to be passed to internal altReadObject calls.

Value

A CompressedAtomicList of the relevant type.

Author(s)

Aaron Lun

See Also

"saveObject,CompressedAtomicList-method", to save an object to disk.

Examples

library(S4Vectors)
X <- splitAsList(LETTERS, sample(3, 26, replace=TRUE))

tmp <- tempfile()
saveObject(X, tmp)
readObject(tmp)

Load a data frame list

Description

Load a list of data frames as a CompressedSplitDataFrameList from its on-disk representation. This is usually not directly called by users, but is instead called by dispatch in readObject.

Usage

readDataFrameList(path, metadata, ...)

Arguments

path

String containing a path to a directory, itself created with the saveObject method for CompressedSplitDataFrameList objects.

metadata

Named list of metadata for this object, see readObjectFile for details.

...

Further arguments, to be passed to internal altReadObject calls.

Value

A CompressedSplitDataFrameList.

Author(s)

Aaron Lun

See Also

"saveObject,CompressedSplitDataFrameList-method", to save an object to disk.

Examples

library(S4Vectors)
Y <- splitAsList(DataFrame(Xxx=LETTERS, Yyy=1:26), sample(3, 26, replace=TRUE))

tmp <- tempfile()
saveObject(Y, tmp)
readObject(tmp)

Read a GRanges from disk

Description

Read a GRanges object from its on-disk representation. This is usually not directly called by users, but is instead called by dispatch in readObject.

Usage

readGRanges(path, metadata, ...)

Arguments

path

String containing a path to a directory, itself created with the stageObject method for GRanges.

metadata

Named list of metadata for this object, see readObjectFile for details.

...

Further arguments to pass to internal altReadObject calls.

Value

A GRanges object.

Author(s)

Aaron Lun

See Also

"saveObject,GRanges-method", to save a GRanges to disk.

Examples

gr <- GRanges(c("chrA", "chrB"), IRanges(c(1, 5), c(100, 200)))
seqlengths(gr) <- c(chrA=1000, chrB=2000)

tmp <- tempfile()
saveObject(gr, tmp)
readObject(tmp)

Read a GRangesList from disk

Description

Read a GRangesList object from its on-disk representation.

Usage

readGRangesList(path, metadata, ...)

Arguments

path

String containing a path to a directory, itself created with the saveObject method for GRangesLists.

metadata

Named list of metadata for this object, see readObjectFile for details.

...

Further arguments, to be passed to internal altReadObject calls.

Value

A GRangesList object.

Examples

gr <- GRanges(c("chrA", "chrB"), IRanges(c(1, 5), c(100, 200)))
seqlengths(gr) <- c(chrA=1000, chrB=2000)
grl <- split(gr, rep(1:3, length.out=length(gr)))

tmp <- tempfile()
saveObject(grl, tmp)
readObject(tmp)

Read a Seqinfo from disk

Description

Read a Seqinfo object from its on-disk representation. This is usually not directly called by users, but is instead called by dispatch in readObject.

Usage

readSeqinfo(path, metadata, ...)

Arguments

path

String containing a path to a directory, itself created with the saveObject method for Seqinfo objects.

metadata

Named list of metadata for this object, see readObjectFile for details.

...

Further arguments, ignored.

Value

A Seqinfo object.

See Also

"saveObject,Seqinfo-method" for the corresponding saving method.

Examples

si <- Seqinfo(c("chrA", "chrB"), c(1000, 2000))

tmp <- tempfile()
saveObject(si, tmp)
readObject(tmp)

Save compressed list of atomic vectors to disk

Description

Save a CompressedAtomicList object to its on-disk representation.

Usage

## S4 method for signature 'CompressedAtomicList'
saveObject(x, path, ...)

Arguments

x

A CompressedAtomicList object.

path

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

...

Further arguments to pass to specific methods.

Value

x is saved to path, and NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

readAtomicVectorList, to read a CompressedAtomicList from disk.

Examples

library(S4Vectors)
X <- splitAsList(LETTERS, sample(3, 26, replace=TRUE))

tmp <- tempfile()
saveObject(X, tmp)
list.files(tmp, recursive=TRUE)

Save compressed lists of data frames to disk

Description

Save a CompressedSplitDataFrameList object to its on-disk representation.

Usage

## S4 method for signature 'CompressedSplitDataFrameList'
saveObject(x, path, ...)

Arguments

x

A CompressedSplitDataFrameList object.

path

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

...

Further arguments to pass to specific methods.

Value

x is saved to path, and NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

readDataFrameList, to read a CompressedSplitDataFrameList from disk.

Examples

library(S4Vectors)
Y <- splitAsList(DataFrame(Xxx=LETTERS, Yyy=1:26), sample(3, 26, replace=TRUE))

tmp <- tempfile()
saveObject(Y, tmp)
list.files(tmp, recursive=TRUE)

Save a GRanges object to disk

Description

Save a GRanges object to its on-disk representation .

Usage

## S4 method for signature 'GRanges'
saveObject(x, path, ...)

Arguments

x

A GRanges object or one of its subclasses.

path

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

...

Further arguments to pass to specific methods.

Value

x is saved to path, and NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

readGRanges, to read a GRanges from disk.

Examples

gr <- GRanges(c("chrA", "chrB"), IRanges(c(1, 5), c(100, 200)))
seqlengths(gr) <- c(chrA=1000, chrB=2000)

tmp <- tempfile()
saveObject(gr, tmp)
list.files(tmp, recursive=TRUE)

Save a GRangesList object to disk

Description

Save a GRangesList object to its on-disk representation.

Usage

## S4 method for signature 'GRangesList'
saveObject(x, path, ...)

Arguments

x

A GRangesList object.

path

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

...

Further arguments to pass to specific methods.

Value

x is saved to path, and NULL is invisibly returned.

Author(s)

Aaron Lun

See Also

readGRangesList, to read a GRangesList from disk.

Examples

gr <- GRanges("chrA", IRanges(1:100, width=1))
grl <- split(gr, rep(1:3, length.out=length(gr)))

tmp <- tempfile()
saveObject(grl, tmp)
list.files(tmp, recursive=TRUE)

Save a Seqinfo object to disk

Description

Save a Seqinfo object to its on-disk representation.

Usage

## S4 method for signature 'Seqinfo'
saveObject(x, path, ...)

Arguments

x

A Seqinfo object.

path

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

...

Further arguments to pass to specific methods.

Value

x is saved to path, and NULL is invisibly returned.

See Also

readSeqinfo, to read a Seqinfo from disk.

Examples

si <- Seqinfo(c("chrA", "chrB"), c(1000, 2000))

tmp <- tempfile()
dir.create(tmp)
saveObject(si, tmp, path="seqinfo")
list.files(tmp, recursive=TRUE)