This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DEseq2 result file figure between Genus and log2fold change

Hello

Could you please suggest how I can get dotplot figure like attached from deseq2 result file; My deseq2 result file looks like this;

I wanted to show Genus names on Y-axis and log2Foldchange on the X-axis and I am also wanted to show dot colour based on phylum name.

         log2FoldChange padj    Kingdom           Phylum    Genus
OTU1    0.214360038 0.369800256 Bacteria    Proteobacteria  Burkholderiaceae
OTU2    0.104133836 0.611791812 Bacteria    Proteobacteria  Xanthobacteraceae
OTU3    0.911214638 8.33E-08    Bacteria    Proteobacteria  Archangiaceae
OTU4    1.162701206 4.80E-08    Bacteria    Proteobacteria  Geobacteraceae
OTU5   -2.439651618 1.62E-08    Bacteria    Actinobacteria  Microbacteriaceae

dotplot

r bioconducter

1 answer

Example data.

df <- structure(list(log2FoldChange = c(0.214360038, 0.104133836, 0.911214638,
1.162701206, -2.439651618), padj = c(0.369800256, 0.611791812,
8.33e-08, 4.8e-08, 1.62e-08), Kingdom = c("Bacteria", "Bacteria",
"Bacteria", "Bacteria", "Bacteria"), Phylum = c("Proteobacteria",
"Proteobacteria", "Proteobacteria", "Proteobacteria", "Actinobacteria"
), Genus = c("Burkholderiaceae", "Xanthobacteraceae", "Archangiaceae",
"Geobacteraceae", "Microbacteriaceae")), class = "data.frame", row.names = c("OTU1",
"OTU2", "OTU3", "OTU4", "OTU5"))

ggplot2 solution.

library("forcats")
library("ggplot2")

df %>%
  mutate(Genus=fct_reorder(Genus, log2FoldChange)) %>%
  ggplot(aes(x=log2FoldChange, y=Genus)) +
    geom_vline(xintercept=0) +
    geom_point(aes(color=Phylum), size=5)

enter image description here

Log in to answer this question.