enrichplot源码阅读

最后发布时间:2023-02-21 13:08:48 浏览量:

YuLab-SMU/enrichplot/enrichplot/R/method-fortify.R

IDDescriptionGeneRatioBgRatiopvaluep.adjustqvaluegeneIDCount
GO:0005819spindle26/201313/118651.748160953695457e-115.261964470623326e-94.802842199100151e-9CDCA8/CDC20/KIF23/CENPE/ASPM/DLGAP5/SKA1/NUSAP1/TPX2/TACC3/NEK2/CDK1/MAD2L1/KIF18A/BIRC5/KIF11/TRAT1/TTK/AURKB/PRC1/KIFC1/KIF18B/KIF20A/AURKA/CCNB1/KIF4A26
GO:0000775chromosome, centromeric region19/201169/118656.340879428793475e-116.8326302038778255e-96.236462609589483e-9CDCA8/CENPE/NDC80/TOP2A/HJURP/SKA1/NEK2/CENPM/CENPN/ERCC6L/MAD2L1/KIF18A/CDT1/BIRC5/EZH2/TTK/NCAPG/AURKB/CCNB119
GO:0072686mitotic spindle17/201131/118656.80993043575863e-116.8326302038778255e-96.236462609589483e-9KIF23/CENPE/ASPM/SKA1/NUSAP1/TPX2/TACC3/CDK1/MAD2L1/KIF18A/KIF11/TRAT1/AURKB/PRC1/KIFC1/KIF18B/AURKA17
GO:0000779condensed chromosome, centromeric region16/201123/118652.4398133262121816e-101.8359595279746667e-81.675766521424683e-8CENPE/NDC80/HJURP/SKA1/NEK2/CENPM/CENPN/ERCC6L/MAD2L1/KIF18A/CDT1/BIRC5/TTK/NCAPG/AURKB/CCNB116
GO:0098687chromosomal region23/201287/118655.709915237613229e-103.437368973043164e-83.1374481621411644e-8CDCA8/CENPE/NDC80/TOP2A/HJURP/SKA1/NEK2/CENPM/RAD51AP1/CENPN/CDK1/ERCC6L/MAD2L1/KIF18A/CDT1/BIRC5/EZH2/TTK/NCAPG/AURKB/CHEK1/CCNB1/MCM523
GO:0000776kinetochore15/201115/118658.719736637953852e-104.3744012133735155e-83.992721513168343e-8CENPE/NDC80/HJURP/SKA1/NEK2/CENPM/CENPN/ERCC6L/MAD2L1/KIF18A/CDT1/BIRC5/TTK/AURKB/CCNB115

dotplot函数中使用as.data.frame(res <- as.data.frame(model))的泛型函数将enrichResult对象转换为data.frame对象,这其中就使用了enrichGO(pvalueCutoff = 0.01) 函数中pvalueCutoff参数设置的阈值对p.agjust进行筛选。res <- res[!is.na(res$Description), ]也是一个泛型函数,

点击查看S3对象的泛型和多态

fortify.internal

res <- as.data.frame(model)
res <- res[!is.na(res$Description), ]

res <- as.data.frame(model)

##' @method as.data.frame gseaResult
##' @export
as.data.frame.enrichResult <- function(x, ...) {
    x <- get_enriched(x)
    as.data.frame(x@result, ...)
}

res <- res[!is.na(res$Description), ]

##' @method [ enrichResult
##' @export
`[.enrichResult` <- function(x, i, j, asis = FALSE, ...) {
    x <- get_enriched(x)
    y <- x@result[i, j, ...]
    if (!asis)
        return(y)
    x@result <- y
    return(x)
}

x <- get_enriched(x)

get_enriched <- function(object) {
    Over <- object@result
    pvalueCutoff <- object@pvalueCutoff
    if (length(pvalueCutoff) != 0) {
        ## if groupGO result, numeric(0)
        Over <- Over[ Over$pvalue <= pvalueCutoff, ]
        Over <- Over[ Over$p.adjust <= pvalueCutoff, ]
    }
    qvalueCutoff <- object@qvalueCutoff
    if (length(qvalueCutoff) != 0) {
        if (! any(is.na(Over$qvalue))) {
            if (length(qvalueCutoff) > 0)
                Over <- Over[ Over$qvalue <= qvalueCutoff, ]
        }
    }
    object@result <- Over
    return(object)
}

可以看到pvalueCutoff <- object@pvalueCutoff这行代码是获取了enrichResult对象的pvalueCutoff这个属性。

Over <- Over[ Over$pvalue <= pvalueCutoff, ]
Over <- Over[ Over$p.adjust <= pvalueCutoff, ]

这里直接就使用了p.adjust < = pvalueCutoff的阈值进行过滤,并没有使用pvalue进行过滤的选项。

更改后的R包
BioinfoFungi/enrichplot2