YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/contribution-tree-data/
838 stars 173 forks source link

Heatmap with foldchange displayed #531

Closed suekn closed 2 years ago

suekn commented 2 years ago

Using heatmap(), I cannot get the foldChange to display properly. It looks the same as without fold change. I followed tutorial 15.4 and I believe my gene_list is equivalent.

I am using following csv: DESeq2_kallisto_MM003_MM007_MM011_vs_MM027_MM031_MM035-DEG_list.csv

library(clusterProfiler)

organism = "org.Hs.eg.db"
library(organism, character.only = TRUE)

 # in this overrepresentation analysis, we define DEGs as
  # log FC > 2 and padj < 0.05

  # reading in input from deseq2
  df = read.csv(as.character(file))

  # we want the log2 fold change 
  original_gene_list <- df$log2FoldChange

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

  # Exctract significant results (padj < 0.05)
  sig_genes_df = subset(df, padj < 0.05)

  # From significant results, we want to filter on log2fold change
  genes <- sig_genes_df$log2FoldChange

  # Name the vector
  names(genes) <- sig_genes_df$X

  # omit NA values
  genes <- na.omit(genes)

  # filter on min log2fold change (log2FoldChange > 2)
  genes <- names(genes)[abs(genes) > 2]

  go_enrich <- enrichGO(gene = genes,
                        universe = names(gene_list),
                        OrgDb = organism, 
                        keyType = 'SYMBOL',
                        readable = T,
                        ont = "BP",
                        pvalueCutoff = 0.05,
                        qvalueCutoff = 0.10,
                        pAdjustMethod = 'none')

library(enrichplot)
  heatplot(go_enrich, showCategory = 5)

image

  heatplot(go_enrich, foldChange=gene_list, showCategory=5)

image