R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:


``` r
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
de_df <- data.frame(
  gene = c("GeneA", "GeneB", "GeneC", "GeneD", "GeneE"),
  log2FoldChange = c(2.1, -1.5, 0.8, -3.2, 1.2),
  padj = c(0.001, 0.045, 0.3, 0.0005, 0.02),
  baseMean = c(150, 220, 100, 180, 250)
)

de_df <- de_df %>%
  mutate(
    negLog10Padj = -log10(padj),
    sig_status = case_when(
      padj < 0.05 & log2FoldChange > 1 ~ "Up",
      padj < 0.05 & log2FoldChange < -1 ~ "Down",
      TRUE ~ "NotSig"
    )
  )

## Including Plots

You can also embed plots, for example:


``` r
ggplot(de_df, aes(x = log2FoldChange, y = negLog10Padj, color = sig_status, label = gene)) +
  geom_point(size = 3) +
  geom_text(aes(label = ifelse(sig_status != "NotSig", gene, "")),
            hjust = 0.5, vjust = -0.7, size = 4) +
  scale_color_manual(values = c("Up" = "red", "Down" = "blue", "NotSig" = "grey")) +
  geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "black") +
  geom_vline(xintercept = c(-1, 1), linetype = "dashed", color = "black") +
  theme_minimal(base_size = 14) +
  labs(
    title = "Mini Volcano Plot with Thresholds",
    x = "log2(Fold Change)",
    y = "-log10(padj)",
    color = "Status"
  )

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.