Clarion: Clarion R6-class definition

ClarionR Documentation

Clarion R6-class definition

Description

Use this to create a clarion object. This object is used by all top-level wilson modules.

Constructor

Clarion$new(header = NULL, metadata, data, validate = TRUE)

Constructor Arguments

Variable Return
header A named list. Defaults to NULL.
metadata Clarion metadata in form of a data.table.
data Data.table according to metadata.
validate Logical value to validate on initialization. Defaults to TRUE.

Public fields

header

List of global information regarding the whole experiment.

metadata

Data.table with additional information for each column.

data

Data.table containing experiment result data.

Methods

Public methods


Clarion$get_id()

Returns name of unique identifier column. Assumes first feature to be unique if not specified.

Usage
Clarion$get_id()
Returns

Name of the id column.


Clarion$get_name()

Returns name of name column. If not specified return unique Id.

Usage
Clarion$get_name()
Returns

Name of the name column.


Clarion$get_delimiter()

Return delimiter used within multi-value fields (no delimiter = NULL).

Usage
Clarion$get_delimiter()

Clarion$is_delimited()

Logical whether the given column name is delimited.

Usage
Clarion$is_delimited(x)
Arguments
x

Name of the column.

Returns

boolean


Clarion$get_factors()

Get factors to all columns.

Usage
Clarion$get_factors()
Details

Named factors (e.g. factor1="name") will be cropped to their name.

Returns

Returns a data.table columns: key and factor(s) if any.


Clarion$get_level()

Get level(s) to given column name(s).

Usage
Clarion$get_level(column)
Arguments
column

One or more column name(s).

Returns

Provide a vector of levels to the given columnnames in column. Returns NA for missing columns and character(0) if column = NULL.


Clarion$get_label()

Get label(s) to given column name(s).

Usage
Clarion$get_label(column = NULL, sub_label = TRUE, sep = " ")
Arguments
column

One or more column name(s).

sub_label

Whether the sub_label should be included.

sep

Separator between label and sub_label.

Details

If a column does not have a label the key is returned.

Returns

Provides a vector of labels (+ sub_label) to the given columnnames in column. Returns NA for missing columns and all labels if column = NULL.


Clarion$validate()

Check the object for inconsistencies.

Usage
Clarion$validate(solve = TRUE)
Arguments
solve

For solve = TRUE try to resolve some warnings.


Clarion$new()

Initialize a new clarion object.

Usage
Clarion$new(header = NULL, metadata, data, validate = TRUE)
Arguments
header

A named list. Defaults to NULL.

metadata

Clarion metadata in form of a data.table.

data

Data.table according to metadata.

validate

Logical value to validate on initialization. Defaults to TRUE.

Returns

Clarion object.


Clarion$write()

Save the object as a clarion file.

Usage
Clarion$write(file)
Arguments
file

Filename for the file to be written.


Clarion$clone()

The objects of this class are cloneable with this method.

Usage
Clarion$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

# generate clarion contents
header <- list(format = "Clarion", version = "1.0", experiment_id = "123456")

metadata <- data.table::as.data.table(list(
  key = c("id", "name", "sample_a", "sample_b"),
  factor1 = c("", "", "sample_a", "sample_b"),
  level = c("feature", "feature", "sample", "sample"),
  type = c("unique_id", "name", "score", "score"),
  label = c("Identifier", "Name", "Sample A", "Sample B")
))

data <- data.table::data.table(
  id = c("id_1", "id_2", "id_3"),
  name = c("AAA", "BBB", "CCC"),
  sample_a = c(10000, 300, 20),
  sample_b = c(50, 40000, 12002)
)

# initializing a new object
object <- Clarion$new(header = header, metadata = metadata, data = data, validate = TRUE)

# create a deep copy
object_copy <- object$clone(deep = TRUE)


wilson documentation built on July 28, 2026, 5:07 p.m.