Package 'MOObject'

Title: multiOmicDataSet object class for MOSuite
Description: MOObject defines the multiOmicDataSet object class which is used in MOSuite for differential RNA-seq and multi-omics analyses. Separating the MOObject class definition from MOSuite allows for lightweight installations in downstream workflows. See the website for more information: <https://ccbr.github.io/MOObject/>. See the MOSuite website for the most comprehensive documentation: <https://ccbr.github.io/MOSuite/>.
Authors: Kelly L Sovacool [aut, cre] (ORCID: <https://orcid.org/0000-0003-3283-829X>), Philip Homan [aut], Vishal Koparde [aut] (ORCID: <https://orcid.org/0000-0001-8978-8495>), CCR Collaborative Bioinformatics Resource [cph]
Maintainer: Kelly L Sovacool <[email protected]>
License: MIT + file LICENSE
Version: 0.5.0.9000
Built: 2026-10-08 17:12:00 UTC
Source: https://github.com/CCBR/MOObject

Help Index


Construct a multiOmicDataSet object from data frames

Description

Construct a multiOmicDataSet object from data frames

Usage

create_multiOmicDataSet_from_dataframes(
  sample_metadata,
  counts_dat,
  sample_id_colname = NULL,
  feature_id_colname = NULL,
  count_type = "raw"
)

Arguments

sample_metadata

sample metadata as a data frame or tibble. The first column is assumed to contain the sample IDs which must correspond to column names in the raw counts.

counts_dat

data frame of feature counts (e.g. expected feature counts from RSEM).

sample_id_colname

name of the column in sample_metadata that contains the sample IDs. (Default: NULL - first column in the sample metadata will be used.)

feature_id_colname

name of the column in counts_dat that contains feature/gene IDs. (Default: NULL - first column in the count data will be used.)

count_type

type to assign the values of counts_dat to in the counts slot

Value

A multiOmicDataSet object.

See Also

Other moo: create_multiOmicDataSet_from_files(), extract_counts(), multiOmicDataSet(), read_multiOmicDataSet(), read_multiOmicDataSet_properties(), write_multiOmicDataSet(), write_multiOmicDataSet_properties()

Examples

sample_meta_dat <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
feature_counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
moo <- create_multiOmicDataSet_from_dataframes(
  sample_metadata = sample_meta_dat,
  counts_dat = feature_counts_dat
)
head(moo@sample_meta)
head(moo@counts[['raw']])

Construct a multiOmicDataSet object from text files (e.g. TSV, CSV).

Description

Construct a multiOmicDataSet object from text files (e.g. TSV, CSV).

Usage

create_multiOmicDataSet_from_files(
  sample_meta_filepath,
  feature_counts_filepath,
  count_type = "raw",
  sample_id_colname = NULL,
  feature_id_colname = NULL,
  delim = NULL,
  ...
)

Arguments

sample_meta_filepath

path to text file with sample IDs and metadata for differential analysis.

feature_counts_filepath

path to text file of expected feature counts (e.g. gene counts from RSEM).

count_type

type to assign the values of counts_dat to in the counts slot

sample_id_colname

name of the column in sample_metadata that contains the sample IDs. (Default: NULL - first column in the sample metadata will be used.)

feature_id_colname

name of the column in counts_dat that contains feature/gene IDs. (Default: NULL - first column in the count data will be used.)

delim

Delimiter used in the input files. Any delimiter accepted by readr::read_delim() can be used. If the files are in CSV format, set delim = ','; for TSV format, set delim = '\t'.

...

additional arguments forwarded to readr::read_delim().

Value

A multiOmicDataSet object.

See Also

Other moo: create_multiOmicDataSet_from_dataframes(), extract_counts(), multiOmicDataSet(), read_multiOmicDataSet(), read_multiOmicDataSet_properties(), write_multiOmicDataSet(), write_multiOmicDataSet_properties()

Examples

sample_meta_dat <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
feature_counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
sample_meta_filepath <- tempfile(fileext = ".csv")
feature_counts_filepath <- tempfile(fileext = ".csv")
readr::write_csv(sample_meta_dat, sample_meta_filepath)
readr::write_csv(feature_counts_dat, feature_counts_filepath)

moo <- create_multiOmicDataSet_from_files(
  sample_meta_filepath = sample_meta_filepath,
  feature_counts_filepath = feature_counts_filepath,
  delim = ","
)
head(moo@sample_meta)
head(moo@counts[['raw']])

Extract count data

Description

Extract count data

Usage

extract_counts(moo, count_type, sub_count_type = NULL)

## S7 method for class <MOObject::multiOmicDataSet>
extract_counts(moo, count_type, sub_count_type = NULL)

Arguments

moo

multiOmicDataSet containing count_type & sub_count_type in the counts slot

count_type

the type of counts to use – must be a name in the counts slot (moo@counts[[count_type]])

sub_count_type

if count_type is a list, specify the sub count type within the list (moo@counts[[count_type]][[sub_count_type]]). (Default: NULL)

Value

A data frame of counts.

See Also

Other moo: create_multiOmicDataSet_from_dataframes(), create_multiOmicDataSet_from_files(), multiOmicDataSet(), read_multiOmicDataSet(), read_multiOmicDataSet_properties(), write_multiOmicDataSet(), write_multiOmicDataSet_properties()

Examples

sample_metadata <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
moo <- create_multiOmicDataSet_from_dataframes(sample_metadata, counts_dat)
extract_counts(moo, "raw")

multiOmicDataSet class

Description

multiOmicDataSet class

Usage

multiOmicDataSet(sample_metadata, anno_dat, counts_lst, analyses_lst = list())

Arguments

sample_metadata

sample metadata as a data frame or tibble. The first column is assumed to contain the sample IDs which must correspond to column names in the raw counts.

anno_dat

data frame of feature annotations, such as gene symbols or any other information about the features in counts_lst.

counts_lst

named list of data frames containing counts, e.g. expected feature counts from RSEM. Each data frame is expected to contain a feature_id column as the first column, and all remaining columns are sample IDs in the sample_meta.

analyses_lst

named list of analysis results, e.g. DESeq results object

Value

A multiOmicDataSet S7 object.

Additional properties

@sample_meta

sample metadata as a data frame or tibble. The first column is assumed to contain the sample IDs which must correspond to column names in the raw counts.

@counts

named list of counts data frames (e.g. raw, clean, cpm, filt, norm, batch). Each data frame is expected to contain a feature ID column as the first column, and all remaining columns are sample IDs.

@annotation

data frame of feature annotations, such as gene symbols or any other information about the features in the counts list.

@analyses

named list of analysis results (e.g. DESeq2 results, colors).

See Also

Other moo: create_multiOmicDataSet_from_dataframes(), create_multiOmicDataSet_from_files(), extract_counts(), read_multiOmicDataSet(), read_multiOmicDataSet_properties(), write_multiOmicDataSet(), write_multiOmicDataSet_properties()

Examples

# sample metadata (sample names, labels, groups, batches, etc.)
sample_metadata <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
# counts data such as from bulk RNA-seq
counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
# annotations for the counts data such as alternative gene names, gene IDs, etc.
anno_dat <- data.frame(feature_id = c("gene1", "gene2"), ensembl_id = c('ENSG000001', 'ENSG000002'))

# construct a multiOmicDataSet object
moo <- multiOmicDataSet(
  sample_metadata = sample_metadata,
  counts_lst = list(raw = counts_dat),
  anno_dat = anno_dat
)
moo
S7::S7_class(moo)

# validate the object
S7::validate(moo)

# Retrieve properties from the object
head(moo@sample_meta)
# Set properties in the object
moo@sample_meta$batch <- c("C", "D")

Read a multiOmicDataSet from RDS

Description

Read a multiOmicDataSet from RDS

Usage

read_multiOmicDataSet(filepath)

Arguments

filepath

Path to an RDS file produced by write_multiOmicDataSet()

Value

A multiOmicDataSet object.

See Also

Other moo: create_multiOmicDataSet_from_dataframes(), create_multiOmicDataSet_from_files(), extract_counts(), multiOmicDataSet(), read_multiOmicDataSet_properties(), write_multiOmicDataSet(), write_multiOmicDataSet_properties()

Examples

sample_metadata <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
moo <- create_multiOmicDataSet_from_dataframes(sample_metadata, counts_dat)
filepath <- tempfile(fileext = ".rds")
write_multiOmicDataSet(moo, filepath)
moo2 <- read_multiOmicDataSet(filepath)

Read multiOmicDataSet properties from individual files.

Description

Reads a directory created by write_multiOmicDataSet_properties() and reconstructs the multiOmicDataSet object. The sample_meta and annotation properties are read from CSV files, the counts property is read from the ⁠counts/⁠ subdirectory, and the analyses property is read from the ⁠analyses/⁠ subdirectory.

Usage

read_multiOmicDataSet_properties(input_dir)

Arguments

input_dir

Directory previously created by write_multiOmicDataSet_properties().

Value

A multiOmicDataSet object.

See Also

Other moo: create_multiOmicDataSet_from_dataframes(), create_multiOmicDataSet_from_files(), extract_counts(), multiOmicDataSet(), read_multiOmicDataSet(), write_multiOmicDataSet(), write_multiOmicDataSet_properties()

Examples

sample_metadata <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
moo <- create_multiOmicDataSet_from_dataframes(sample_metadata, counts_dat)
output_dir <- tempfile()
write_multiOmicDataSet_properties(moo, output_dir)
moo2 <- read_multiOmicDataSet_properties(output_dir)

Write a multiOmicDataSet to RDS

Description

Write a multiOmicDataSet to RDS

Usage

write_multiOmicDataSet(moo, filepath = "moo.rds")

Arguments

moo

multiOmicDataSet object to serialize

filepath

Path to the RDS file to write (default: "moo.rds")

Value

Invisibly returns filepath.

See Also

Other moo: create_multiOmicDataSet_from_dataframes(), create_multiOmicDataSet_from_files(), extract_counts(), multiOmicDataSet(), read_multiOmicDataSet(), read_multiOmicDataSet_properties(), write_multiOmicDataSet_properties()

Examples

sample_metadata <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
moo <- create_multiOmicDataSet_from_dataframes(sample_metadata, counts_dat)
filepath <- tempfile(fileext = ".rds")
write_multiOmicDataSet(moo, filepath)

Write multiOmicDataSet properties to individual files.

Description

The sample_meta and annotation properties are written to CSV files, the counts property is written to a subdirectory of CSV files, and the analyses property is written to a subdirectory of CSV or RDS files depending on the type of each analysis result.

Usage

write_multiOmicDataSet_properties(moo, output_dir = "moo")

## S7 method for class <MOObject::multiOmicDataSet>
write_multiOmicDataSet_properties(moo, output_dir = "moo")

Arguments

moo

multiOmicDataSet object to write properties from

output_dir

Directory where the properties will be saved (default: "moo")

Value

Invisibly returns output_dir.

See Also

Other moo: create_multiOmicDataSet_from_dataframes(), create_multiOmicDataSet_from_files(), extract_counts(), multiOmicDataSet(), read_multiOmicDataSet(), read_multiOmicDataSet_properties(), write_multiOmicDataSet()

Examples

sample_metadata <- data.frame(sample_id = c("s1", "s2"), group = c("A", "B"))
counts_dat <- data.frame(
  feature_id = c("gene1", "gene2"),
  s1 = c(10, 20),
  s2 = c(15, 25)
)
moo <- create_multiOmicDataSet_from_dataframes(sample_metadata, counts_dat)
output_dir <- tempfile()
write_multiOmicDataSet_properties(moo, output_dir)