The HermesData
class is an extension of SummarizedExperiment::SummarizedExperiment
with additional validation criteria.
Arguments
- object
(
SummarizedExperiment
)
input to create theHermesData
object from. If this is aRangedSummarizedExperiment
, then the result will beRangedHermesData
.- counts
(
matrix
)
counts to create theHermesData
object from.- ...
additional arguments, e.g.
rowData
,colData
, etc. passed toSummarizedExperiment::SummarizedExperiment()
internally. Note that ifrowRanges
is passed instead ofrowData
, then the result will be aRangedHermesData
object.
Details
The additional criteria are:
The first assay must be
counts
containing non-missing, integer, non-negative values. Note thatrename()
can be used to edit the assay name tocounts
if needed.-
The following columns must be in
rowData
:symbol
(also often calledHGNC
or similar, example:"INMT"
)desc
(the gene name, example:"indolethylamine N-methyltransferase"
)chromosome
(the chromosome as string, example:"7"
)size
(the size of the gene in base pairs, e.g5468
)low_expression_flag
(can be populated withadd_quality_flags()
)
-
The following columns must be in
colData
:low_depth_flag
(can be populated withadd_quality_flags()
)tech_failure_flag
(can be populated withadd_quality_flags()
)
The object must have unique row and column names. The row names are the gene names and the column names are the sample names.
Analogously, RangedHermesData
is an extension of
SummarizedExperiment::RangedSummarizedExperiment
and has the same
additional validation requirements. Methods can be defined for both classes at the
same time with the AnyHermesData
signature.
A Biobase::ExpressionSet
object can be imported by using the
SummarizedExperiment::makeSummarizedExperimentFromExpressionSet()
function to
first convert it to a SummarizedExperiment::SummarizedExperiment
object before
converting it again into a HermesData
object.
Note
Note that we use
S4Vectors::setValidity2()
to define the validity method, which allows us to turn off the validity checks in internal functions where intermediate objects may not be valid within the scope of the function.It can be helpful to convert character and logical variables to factors in
colData()
(before or after theHermesData
creation). We provide the utility functiondf_cols_to_factor()
to simplify this task, but leave it to the user to allow for full control of the details.
See also
rename()
for renaming columns of the input data.
Examples
# Convert an `ExpressionSet` to a `RangedSummarizedExperiment`.
ranged_summarized_experiment <- makeSummarizedExperimentFromExpressionSet(expression_set)
# Then convert to `RangedHermesData`.
HermesData(ranged_summarized_experiment)
#> class: RangedHermesData
#> assays(1): counts
#> genes(5085): GeneID:11185 GeneID:10677 ... GeneID:9087 GeneID:9426
#> additional gene information(12): HGNC HGNCGeneName ... chromosome_name
#> LowExpressionFlag
#> samples(20): 06520011B0023R 06520067C0018R ... 06520015C0016R
#> 06520019C0023R
#> additional sample information(74): Filename SampleID ... LowDepthFlag
#> TechnicalFailureFlag
# Create objects starting from a `SummarizedExperiment`.
hermes_data <- HermesData(summarized_experiment)
hermes_data
#> class: HermesData
#> assays(1): counts
#> genes(5085): GeneID:11185 GeneID:10677 ... GeneID:9087 GeneID:9426
#> additional gene information(12): HGNC HGNCGeneName ... chromosome_name
#> LowExpressionFlag
#> samples(20): 06520011B0023R 06520067C0018R ... 06520015C0016R
#> 06520019C0023R
#> additional sample information(74): Filename SampleID ... LowDepthFlag
#> TechnicalFailureFlag
# Create objects from a matrix. Note that additional arguments are not required but possible.
counts_matrix <- assay(summarized_experiment)
counts_hermes_data <- HermesDataFromMatrix(counts_matrix)