I'm experiencing issues again with the replicates of our experiment. We should be comparing 3 types of treatments in one heatmap.
Each of which have 3 replicates. The following code works very well when I don't use replicates, and simply compare one treatment vs control. Also, when calling mcols, it should show the 3 comparisons we will use in our heatmap, though it only says CTRL vs T (if I don't use replicates) or T vs A in this case.
So here are my two questions:
Thanks
(ps: I'm not an R expert)
- Ctrl vs T
- Ctrl vs B
- Ctrl vs A
Each of which have 3 replicates. The following code works very well when I don't use replicates, and simply compare one treatment vs control. Also, when calling mcols, it should show the 3 comparisons we will use in our heatmap, though it only says CTRL vs T (if I don't use replicates) or T vs A in this case.
So here are my two questions:
- Is there a better way to define samples$condition?
- How should I use mcols to have the 3 comparisons?
Thanks
(ps: I'm not an R expert)Code:
# DESeq1 libraries
library( "DESeq2" )
library("Biobase")
# Heatmap libraries
library(RColorBrewer)
library( "genefilter" )
library(gplots)
# Start loading matrix data
clba = read.table("matrix_duplicates_merged_CLBA.txt", header=TRUE, row.names=1)
head(clba)
samplesclba <- data.frame(row.names=c("C1", "C2", "C3", "T1", "T2", "T3", "B1", "B2", "B3", "A1", "A2", "A3"), condition=as.factor(c(rep("C",3), rep("T", 3), rep("B", 3), rep("A", 3))))
## Relevel doesn't work with replicates
samples$condition <- relevel(samples$condition, "C")
[B]Error in samples$condition : object of type 'closure' is not subsettable[/B]
# Launch DESeq2
ddsclba <- DESeqDataSetFromMatrix(countData = as.matrix(clba), colData=samplesclba, design=~condition)
ddsclba <- DESeq(ddsclba, betaPrior=FALSE)
# Results
resclba <- results( ddsclba )
mcols(resclba, use.names=TRUE)
DataFrame with 6 rows and 2 columns
type description
<character> <character>
baseMean intermediate the base mean over all rows
log2FoldChange results log2 fold change: condition T vs A
lfcSE results standard error: condition T vs A
stat results Wald statistic: condition T vs A
pvalue results Wald test p-value: condition T vs A
padj results BH adjusted p-values
# Heatmap with top 35 genes
rldclba <- rlogTransformation(ddsclba)
topVarGenesclba <- order( rowVars( assay(rldclba) ), decreasing=TRUE ) [1:35]
hmcol <- colorRampPalette( rev(brewer.pal(9, "RdBu")))(255)
heatmap.2( assay(rldclba)[ topVarGenesclba, ], Colv=FALSE, scale="row",
trace="none", dendrogram="row", col = hmcol

Comment