DEG for multiple comparisons
1
0
Entering edit mode
@72eff377
Last seen 3.6 years ago
United Kingdom

Hi all,

I'm quite new to using DESeq2 and was hoping for some guidance. I appreciate my question might be very basic - apologies for this.

I have an experimental set of six groups (24 samples in total, n = 4) and am looking at creating different comparisons. I've read the DESeq2 vignette and have made my contrast like so:

 dds <- DESeqDataSetFromTximport(Txi_gene, colData=sample_file, design=~group)
 dds <- DESeq(dds)
 dds$group <- factor(paste0(dds$condition, dds$time))
 design(dds) <- ~ group

res1 <- results(dds, contrast=c("group","A_day14","B_day14"))
res2 <- results(dds, contrast=c("group","A_day14","A_day0"))

*etc.*

This all seems to be looking as expected. My next question is about visualizing the differentially expressed genes: if I'm looking at comparison A vs B, how can I extract just those DEGs rather than the genes in general?

This is my code chunk so far:

normalized_counts <- counts(dds, normalized=TRUE)

normalized_counts <- normalized_counts %>% 
  data.frame(check.names=FALSE) %>%
  rownames_to_column(var="gene") %>% 
  as_tibble()

top50_sigRes1_genes <- res1_lfcshrink_tb %>% 
        arrange(padj) %>% 
        pull(gene) %>%
        head(n=50)

top50_sigRes1_norm <- normalized_counts %>%
        dplyr::filter(gene %in% top50_sigRes1_genes)

gathered_top50_sigRes1 <- top50_sigRes1_norm %>%
  gather(colnames(top50_sigRes1_norm)[2:25], key = "samplename", value = "normalized_counts")

My hunch is that I need to change the [2:25] to reflect only the columns I'm interested in per comparison? So if I look at A vs B, I only select those columns and disregard C, D, etc. However, when I try that I get the error ! incorrect number of dimensions.

So for visualization:

gathered_top50_sigRes1_joined <- inner_join(meta_data, gathered_top50_sigRes1)

ggplot(gathered_top50_sigRes1_joined) +
        geom_point(aes(x = gene, y = normalized_counts, color = group)) +
        scale_y_log10() +
        xlab("Genes") +
        ylab("log10 Normalized Counts") +
        ggtitle("Top 50 Significant DE Genes - A day 14 vs B day 14") +
        theme_bw() +
    theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
    theme(plot.title = element_text(hjust = 0.5))

This gives me a nice plot, but all my samples are included in it so it's not specific to the comparison I'm looking at.

I hope my question makes sense and thank you in advance for taking the time to help me!

DESeq2 • 976 views
ADD COMMENT
0
Entering edit mode
@72eff377
Last seen 3.6 years ago
United Kingdom

I got the answer to my question here: https://www.biostars.org/p/9516797/#9516956

ADD COMMENT

Login before adding your answer.

Traffic: 727 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6