问题描述
我正在编写一个名为 Expression
的S4类,并希望包含一个S4对象, DESeq2 = DESeqDataSet
作为广告位:
I am writing an S4 class called Expression
and would like to include an S4 object, DESeq2 = "DESeqDataSet"
as a slot:
setClass(
Class = "Expression",
representation = representation (
species = "character",
edgeR = "DGEList",
DESeq2 = "DESeqDataSet",
lengths = "matrix",
individuals = "vector",
treatments = "vector",
id = "vector",
samples = "vector",
sample_prep = "vector",
genome_type = "vector",
molecule_type = "vector",
blast_hit = "vector",
rRNA = "vector",
protein = "vector"
))
但是,当我检查包裹时,会收到以下警告:
When I check the package, though, I get the following Warning:
Found the following significant warnings:
Warning: undefined slot classes in definition of "Expression": DESeq2(class "DESeqDataSet")
课堂作业很好(即现在有错误),但是我想修复代码中的所有警告。
The class works fine (ie, there are now errors), but I would like to fix all warnings in our code.
带有 DESeqDataSet
对象( DESeq2
,也是我们给插槽指定的名称)导入包 DESCRIPTION
文件。我是否需要做其他事情以使其内容可用于插槽?例如,我使用 setOldClass()
使S3类可用于S4插槽。
The package with the DESeqDataSet
object (DESeq2
, also the name we have given to the slot) is imported in the package DESCRIPTION
file. Do I need to do something else to make its contents available for use in a slot? For example, I have used setOldClass()
to make S3 classes available for use in S4 slots.
这里是引发警告的travis-ci构建示例-
Here is an example of a travis-ci build that throws the warning - https://travis-ci.org/caseywdunn/agalmar/builds/138564256
给出问题的完整代码位于 https://github.com/caseywdunn/agalmar/blob/a7c4013fcb5c924cfd6e1
The full code that is giving the problem is at https://github.com/caseywdunn/agalmar/blob/a7c4013fcb5c924cfd6e1aa8e99f182ceec6fe20/R/utility_functions.R
推荐答案
需要导入类定义,就像函数,泛型和方法一样。因此,在NAMESPACE文件中说
Class definitions need to be imported, just like functions, generics, and methods. So in the NAMESPACE file say
importClassesFrom("DESeq2", "DESeqDataSet")
我相信roxygen2的表示法是 @importClassesFrom DESeq2 DESeqDataSet
I believe the roxygen2 notation is @importClassesFrom DESeq2 DESeqDataSet
这篇关于将现有包中的S4对象包括为新S4类中的插槽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!