在 R 中,如何根据另一个对象的类设置 S4 类

发布于 2024-08-23 01:10:36 字数 550 浏览 4 评论 0原文

我需要从 Bioconductor 的 ShortRead 库创建一个 ShortReadQ 类型的对象。

ShortReadQ 'signature(sread = "DNAStringSet", quality =
          "QualityScore", id = "BStringSet")'

质量槽需要是一个继承自 QualityScore 的对象,我可以轻松地从我希望模拟的另一个 ShortReadQ 对象中确定该对象。

> class(quality(anotherObject))
[1] "SFastqQuality"
attr(,"package")
[1] "ShortRead"

在构造函数参数中使用该信息(“SFastqQuality”)的最佳方法是什么?

newObject<-ShortReadQ(sread=...,
             quality=SFastqQuality(...), 
             id=...)

I need to create an object of type ShortReadQ from Bioconductor's ShortRead library.

ShortReadQ 'signature(sread = "DNAStringSet", quality =
          "QualityScore", id = "BStringSet")'

The quality slot needs to be an object inheriting from QualityScore, of which I can easily determine from another ShortReadQ object that I wish to emulate.

> class(quality(anotherObject))
[1] "SFastqQuality"
attr(,"package")
[1] "ShortRead"

What is the best way to use that information ("SFastqQuality") in the contructor argument?

newObject<-ShortReadQ(sread=...,
             quality=SFastqQuality(...), 
             id=...)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

2024-08-30 01:10:36

这是你想要的吗?

quality = new(class(old.quality.obj)[[1]]))

Does this do what you want?

quality = new(class(old.quality.obj)[[1]]))
总攻大人 2024-08-30 01:10:36

您可能需要 get 函数:

a <- get(class(object))
a(...)

You might want the get function:

a <- get(class(object))
a(...)
尽揽少女心 2024-08-30 01:10:36

感谢您的回复。他们引导我找到了有效的解决方案

newObject<-ShortReadQ(sread=...,
             quality=new(Class=class(quality(anotherObject)),theFirstParameter=...), 
             id=...)

thanks for your responses. they lead me to a solution that works

newObject<-ShortReadQ(sread=...,
             quality=new(Class=class(quality(anotherObject)),theFirstParameter=...), 
             id=...)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文