This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to sort graph based on fold change and instead of activated and suppressed, how to add up and downregulated in graph header?
BiocManager::install("clusterProfiler", version = "3.16")
BiocManager::install("pathview")
BiocManager::install("enrichplot")
library(clusterProfiler)
library(enrichplot)
# we use ggplot2 to add x axis labels (ex: ridgeplot)
library(ggplot2)

# reading in data from deseq2
df = read.csv("C:/DE_gene_downregulated_clusterprofiler.csv", header=TRUE)
View(df)
organism = "org.Hs.eg.db" #set the desired organism here, # org.Hs.eg.db for human
BiocManager::install(organism, character.only = TRUE)
library(organism, character.only = TRUE)
# we want the log2 fold change 
original_gene_list <- df$PostFC
original_gene_list
# name the vector
names(original_gene_list) <- df$X
# omit any NA values 
gene_list<-na.omit(original_gene_list)
# sort the list in decreasing order (required for clusterProfiler)
gene_list = sort(gene_list, decreasing = TRUE)
gene_list

gse <- gseGO(geneList=gene_list, 
              ont ="BP", 
              keyType = "ENSEMBL", 
              minGSSize = 1, 
              maxGSSize = 450, 
              pvalueCutoff = 0.05, 
              verbose = TRUE, 
              OrgDb = organism, 
              pAdjustMethod = "none")

cluster_summary <- data.frame(gse)
write.csv(cluster_summary, "C:/DE_gene/clusterProfiler_out.csv")
require(DOSE)
dotplot(gse, showCategory=10, orderBy = "setSize", split=".sign") + facet_grid(.~.sign)
clusterprofiler

0 answers

No answers yet.

Log in to answer this question.