# clusterProfiler：gson格式初探

## 更新包

- conda activate clusterprofile
- ~/dev/xray/xray -c ~/etc/xui2.json &
- wget -e “https_proxy=http://127.0.0.1:20809“ https://github.com/YuLab-SMU/clusterProfiler/archive/refs/heads/master.zip -O clusterProfiler-master.zip
- wget -e “https_proxy=http://127.0.0.1:20809“ https://github.com/YuLab-SMU/DOSE/archive/refs/heads/master.zip -O DOSE-master.zip
- devtools::install_local(‘DOSE-master.zip’)
- devtools::install_local(‘clusterProfiler-master.zip’)

## 保存gson到本地

- library(clusterProfiler)
- kk <- gson_KEGG(‘hsa’)
- gson::write.gson(kk, file = ‘./KEGG.hsa.gson’)

## 使用本地gson进行KEGG分析

- library(clusterProfiler)
- kk <- gson::read.gson(‘KEGG.hsa.gson’)
- rres <- readRDS(‘deg.rds’)
- rres <- rres[order(rres$log2FoldChange),]

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33

    require(org.Hs.eg.db)
    f_id2name_kk <- function(lc_cgene, keytype="SYMBOL", columns="ENTREZID"){
        res=AnnotationDbi::select(org.Hs.eg.db::org.Hs.eg.db,keys=lc_cgene,columns=columns, keytype=keytype)
        res <- subset(res, !is.na(ENTREZID))
        res$ENTREZID
    }
    require(tidyverse)
    require(enrichplot)
    require(DOSE)
    f_kegg_p <- function(keggr2, n = 15){
        keggr <- subset(keggr2@result, p.adjust < 0.05)
        keggr[['-log(Padj)']] <- -log10(keggr[['p.adjust']])
        keggr[['geneRatio']] <- parse_ratio(keggr[['GeneRatio']])
        keggr$Description <- factor(keggr$Description,
                                           levels=keggr[order(keggr$geneRatio),]$Description)
        ggplot(head(keggr,n),aes(x=geneRatio,y=Description))+
            geom_point(aes(color=`-log(Padj)`,
                     size=`Count`))+
            theme_bw()+
            scale_color_gradient(low="blue1",high="brown1")+
            labs(y=NULL) +
            theme(axis.text.x=element_text(angle=90,hjust = 1,vjust=0.5, size = 12),
                 axis.text.y=element_text(size = 15))
    }
    f_title <- function(gp,title){
        gp + labs(title = title) + theme(plot.title = element_text(hjust = 0.5))
    }
    kegg.d <- enrichKEGG(gene = f_id2name_kk(subset(rres, log2FoldChange < -0.1 & padj < 0.05)$symbol),
          organism = kk,
          universe = f_id2name_kk(rres$symbol),
          pAdjustMethod = "fdr",
          qvalueCutoff =0.05)
    f_kegg_p(kegg.d, n =15) %>% f_title("kegg.d")

通路富集
clusterProfiler：gson格式初探
https://occdn.limour.top/2126.html
Author
Limour
Posted on
July 21, 2022
Licensed under
clusterProfiler：自定义数据库 Previous
Docker内宝塔面板的NGINX自启问题 Next

#### Search

Keyword