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

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

问题描述

我使用R中的topGO软件包通过以下代码分析了基因富集:

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)

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

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")

找到了一个与"GenTable"匹配的对象

A single object matching ‘GenTable’ was found

在以下地方发现

package:topGO

namespace:topGO

具有价值

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"

我该怎么做?

推荐答案

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

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

getMethod("GenTable","topGOdata")

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

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"

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

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

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

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