Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dazhudou1122
    Junior Member
    • Aug 2016
    • 3

    #1

    DESeq2 multiple comparison

    Dear Seqanswers community:

    I ran into a question when I was doing RNA-seq analysis using DeSEQ2. I have 4 groups, 3 samples per group, and set my groups using the following code:

    (condition <- factor(c(rep("ctl", 3), rep("A", 3), rep("B", 3), rep("C", 3))))

    Can anyone tell me how the comparison in DeSEQ2 is done? I am not sure what the p value and log2FC mean in the default output. Supposedly it should be outputting ctl vs A in the default output. But the data is different when I have only ctl and A as input (2 groups). Also, is there a way to specify how the program performs the comparison? I read some previous threads but the answers were not very clear. Any help will be highly appreciated!

    Best,

    Wenhan

    Below is the code I used:

    countdata <- read.table("B6_B6MHV_B6MHVWY.txt", header=TRUE, row.names=1)
    countdata <- countdata[ ,6:ncol(countdata)]
    colnames(countdata) <- gsub("\\.[sb]am$", "", colnames(countdata))
    countdata <- as.matrix(countdata)
    head(countdata)
    (condition <- factor(c(rep("ctl", 3), rep("A", 3), rep("B", 3), rep("C", 3))))
    library(DESeq2)
    (coldata <- data.frame(row.names=colnames(countdata), condition))
    dds <- DESeqDataSetFromMatrix(countData=countdata, colData=coldata, design=~condition)
    dds
    dds <- DESeq(dds)
    # Plot
    dispersions
    png("qc-dispersions.png", 2000, 2000, pointsize=20)
    plotDispEsts(dds, main="Dispersion plot")
    dev.off()

    # Regularized log transformation for clustering/heatmaps, etc
    rld <- rlogTransformation(dds)
    head(assay(rld))
    hist(assay(rld))

    # Colors for plots below
    ## Ugly:
    ## (mycols <- 1:length(unique(condition)))
    ## Use RColorBrewer, better
    library(RColorBrewer)
    (mycols <- brewer.pal(8, "Dark2")[1:length(unique(condition))])

    # Sample distance heatmap
    sampleDists <- as.matrix(dist(t(assay(rld))))
    library(gplots)
    png("qc-heatmap-samples.png", w=1500, h=2500, pointsize=1500)
    heatmap.2(as.matrix(sampleDists), key=F, trace="none",
    col=colorpanel(100, "black", "white"),
    ColSideColors=mycols[condition], RowSideColors=mycols[condition],
    margin=c(10, 10), main="Sample Distance Matrix")
    dev.off()

    # Principal components analysis
    ## Could do with built-in DESeq2 function:
    ## DESeq2:lotPCA(rld, intgroup="condition")
    ## I like mine better:
    rld_pca <- function (rld, intgroup = "condition", ntop = 500, colors=NULL, legendpos="bottomleft", main="PCA Biplot", textcx=1, ...) {
    require(genefilter)
    require(calibrate)
    require(RColorBrewer)
    rv = rowVars(assay(rld))
    select = order(rv, decreasing = TRUE)[seq_len(min(ntop, length(rv)))]
    pca = prcomp(t(assay(rld)[select, ]))
    fac = factor(apply(as.data.frame(colData(rld)[, intgroup, drop = FALSE]), 1, paste, collapse = " : "))
    if (is.null(colors)) {
    if (nlevels(fac) >= 3) {
    colors = brewer.pal(nlevels(fac), "Paired")
    } else {
    colors = c("black", "red")
    }
    }
    pc1var <- round(summary(pca)$importance[2,1]*100, digits=1)
    pc2var <- round(summary(pca)$importance[2,2]*100, digits=1)
    pc1lab <- paste0("PC1 (",as.character(pc1var),"%)")
    pc2lab <- paste0("PC1 (",as.character(pc2var),"%)")
    plot(PC2~PC1, data=as.data.frame(pca$x), bg=colors[fac], pch=21, xlab=pc1lab, ylab=pc2lab, main=main, ...)
    with(as.data.frame(pca$x), textxy(PC1, PC2, labs=rownames(as.data.frame(pca$x)), cex=textcx))
    legend(legendpos, legend=levels(fac), col=colors, pch=20)
    # rldyplot(PC2 ~ PC1, groups = fac, data = as.data.frame(pca$rld),
    # pch = 16, cerld = 2, aspect = "iso", col = colours, main = draw.key(key = list(rect = list(col = colours),
    # terldt = list(levels(fac)), rep = FALSE)))
    }
    png("qc-pca.png", 1500, 1500, pointsize=25)
    rld_pca(rld, colors=mycols, intgroup="condition", xlim=c(-75, 35))
    dev.off()


    # Get differential expression results
    res <- results(dds)
    table(res$padj<0.05)
    ## Order by adjusted p-value
    res <- res[order(res$padj), ]
    ## Merge with normalized count data
    resdata <- merge(as.data.frame(res), as.data.frame(counts(dds, normalized=TRUE)), by="row.names", sort=FALSE)
    names(resdata)[1] <- "Gene"
    head(resdata)
    ## Write results
    write.csv(resdata, file="diffexpr-results.csv")
  • luminasapientiae
    Junior Member
    • Sep 2017
    • 5

    #2
    There is a problem with this kind of analysis from statistical point of view. (more than two groups)
    In practice, DESEq2 use a chi-squared like strategy and a binominal test, the analysis is better when you have one vs another group. In the other hand, edgeR is cappable to make this strategy works, but in their own manual this is not advisable and still in test phase, since you can have an "inflation" and false tendency of result. In other words: the logic in RNA-Seq still working in a 2D universe (difference of A-B) and you are talking about 3D (difference of A-B-C).

    In my opinion, you should produce different DGEs crossing the groups (with the same control group if possible) and use a Venn diagram to identify the common findings.
    Last edited by luminasapientiae; 03-25-2019, 08:31 AM.

    Comment

    Latest Articles

    Collapse

    • SEQadmin2
      Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
      by SEQadmin2



      Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

      Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
      ...
      10-14-2026, 09:55 AM
    • SEQadmin2
      New Genomics Technologies Take Aim at Long-Standing Limits
      by SEQadmin2


      Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

      We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
      ...
      09-28-2026, 10:25 AM

    ad_right_rmr

    Collapse

    News

    Collapse

    Topics Statistics Last Post
    Started by SEQadmin2, Yesterday, 11:13 AM
    0 responses
    16 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, Yesterday, 10:48 AM
    0 responses
    17 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-15-2026, 10:52 AM
    0 responses
    35 views
    0 reactions
    Last Post SEQadmin2  
    Started by SEQadmin2, 10-14-2026, 05:39 AM
    0 responses
    42 views
    0 reactions
    Last Post SEQadmin2  
    Working...