如何在包中显示 S4 函数的源代码? [英] How do I show the source code of an S4 function in a package?

查看:14
本文介绍了如何在包中显示 S4 函数的源代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用R中的topGO包来分析基因富集,代码如下:

sampleGOdata <- new("topGOdata", description = "Simple session", ontology = "BP",allGenes = 基因列表,geneSel = topDiffGenes,nodeSize = 10,annot = annFUN.db,affyLib = affyLib)resultFisher <- runTest(sampleGOdata, algorithm = "classic", statistic = "fisher")allRes <- GenTable(sampleGOdata, classicFisher = resultFisher, orderBy = "fisher",rankOf = "classicFisher",topNodes = 10)

我想查看和更改RunTest函数和GenTable函数来更改ResultTable,但我不知道如何显示功能.使用 getAnywhere("GenTable") 我没有得到我想要的硬代码.

getAnywhere("GenTable")

<块引用>

找到一个匹配GenTable"的对象

在以下地方发现

包:topGO命名空间:topGO

有价值

函数(对象,...)标准通用(GenTable")<环境:0x16a30c10>attr(,"通用")[1] 基因表"attr(,"通用")attr(,"包")[1] 顶级GO"attr(,"包")[1] 顶级GO"attr(,"组")列表()attr(,"valueClass")字符(0)attr(,"签名")[1] 对象"attr(,"默认")`空`attr(,"骨架")功能(对象,...)stop("方法派发到"GenTable"的无效调用(无默认方法)",域 = NA)(对象, ...)属性(类")[1] 标准通用"属性(类")属性(包")[1] 方法"

我该怎么做?

解决方案

使用 getMethod() 并指定签名.在你的情况下,这可能是例如:

getMethod("GenTable","topGOdata")

显示 topGOdata 对象的 GenTable 方法.在这种情况下,只有一个为 topGOdata 对象定义的方法.如果有不同签名的方法,showMethods() 会告诉你哪些方法.在你的情况下:

showMethods("GenTable")# 功能:GenTable(封装topGO)# object="topGOdata"

您可以通过在 getMethod() 函数中指定来获取所需签名的代码.

I used the packages topGO in R to analyze gene enrichment with the following code:

sampleGOdata <- new("topGOdata", description = "Simple session", ontology = "BP",
                    allGenes = geneList, geneSel = topDiffGenes, nodeSize = 10, 
                    annot = annFUN.db, affyLib = affyLib)
resultFisher <- runTest(sampleGOdata, algorithm = "classic", statistic = "fisher")
allRes <- GenTable(sampleGOdata, classicFisher = resultFisher, orderBy = "fisher", 
                   ranksOf = "classicFisher",topNodes = 10)

I want to see and change the RunTest function and the GenTable function to change the ResultTable, but I don't know how to show the function. With the getAnywhere("GenTable") I do not get the hard code I want.

getAnywhere("GenTable")

A single object matching ‘GenTable’ was found

It was found in the following places

package:topGO

namespace:topGO

with value

function (object, ...)
standardGeneric("GenTable")
<environment: 0x16a30c10>
attr(,"generic")
[1] "GenTable"
attr(,"generic")attr(,"package")
[1] "topGO"
attr(,"package")
[1] "topGO"
attr(,"group")
list()
attr(,"valueClass")
character(0)
attr(,"signature")
[1] "object"
attr(,"default")
`NULL`
attr(,"skeleton")
function (object, ...)
stop("invalid call in method dispatch to "GenTable" (no default method)",
domain = NA)(object, ...)
attr(,"class")
[1] "standardGeneric"
attr(,"class")attr(,"package")
[1] "methods"

How can I do this?

解决方案

Use getMethod() and specify the signature. In your case, that could be eg :

getMethod("GenTable","topGOdata")

to show the GenTable method for topGOdata objects. In this case, there is only a method defined for topGOdata objects. In case there are methods with different signatures, showMethods() will tell you which ones. In your case :

showMethods("GenTable")
# Function: GenTable (package topGO)
# object="topGOdata"

You can get the code for the signature you want by specifying it in the getMethod() function.

这篇关于如何在包中显示 S4 函数的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆