Skip to content

Instantly share code, notes, and snippets.

@readbio
Last active February 20, 2018 13:43
Show Gist options
  • Save readbio/dc89711cc1f20dcd109c70b71219eaf7 to your computer and use it in GitHub Desktop.
Save readbio/dc89711cc1f20dcd109c70b71219eaf7 to your computer and use it in GitHub Desktop.
DESeq to identify DEG without biological replicates
library(DESeq);
data_pnas<-read.table("readCount.res",header=T,row.names=1);
head(data_pnas);
data_pnas_desi<-data.frame(row.names=colnames(data_pnas),condition = c("Sample_g1","Sample_g2","Sample_g3","Sample_g4"),libType = c("single-end","single-end","single-end","single-end"));
condition = data_pnas_desi$condition;condition;
cds = newCountDataSet(data_pnas, condition);
cds = estimateSizeFactors( cds );
sizeFactors( cds );
### This step is telling the DESeq you don't have replicates.
#Note the option sharingMode="fit-only". Remember that the default, sharingMode="maximum", takes care of
#outliers, i.e., genes with dispersion much larger than the fitted values. Without replicates, we cannot catch such
#outliers and so have to disable this functionality.
cds = estimateDispersions( cds ,method="blind", sharingMode="fit-only" ) ;
#gene_id Sample_g1 Sample_g2 Sample_g3 Sample_g4
Sample_g1_g2 = nbinomTest(cds, "Sample_g1", "Sample_g2");
write.table(Sample_g1_g2 , "DEG_g1_g2.res", append = FALSE, quote = FALSE, sep = "\t");
pdf("plotMA_Sample_g1_g2.pdf");plotMA(Sample_g1_g2,col=ifelse(Sample_g1_g2$padj >= 0.05, "gray32", "red3"));dev.off()
Sample_g1_g3 = nbinomTest(cds, "Sample_g1", "Sample_g3");
write.table(Sample_g1_g3 , "DEG_g1_g3.res", append = FALSE, quote = FALSE, sep = "\t");
pdf("plotMA_Sample_g1_g3.pdf");plotMA(Sample_g1_g3,col=ifelse(Sample_g1_g3$padj >= 0.05, "gray32", "red3"));dev.off()
Sample_g1_g4 = nbinomTest(cds, "Sample_g1", "Sample_g4");
write.table(Sample_g1_g4 , "DEG_g1_g4.res", append = FALSE, quote = FALSE, sep = "\t");
pdf("plotMA_Sample_g1_g4.pdf");plotMA(Sample_g1_g4,col=ifelse(Sample_g1_g4$padj >= 0.05, "gray32", "red3"));dev.off()
gene_id Sample_g1 Sample_g2 Sample_g3 Sample_g4
AT1G01010 38 37 21 20
AT1G01020 39 43 13 19
AT1G01030 8 11 7 1
AT1G01040 205 258 103 146
AT1G01046 2 1 0 2
AT1G01050 109 100 49 63
AT1G01060 243 220 73 166
AT1G01070 19 17 11 27
AT1G01080 73 53 45 65
AT1G01090 268 167 142 160
AT1G01100 588 615 301 334
AT1G01110 10 18 4 8
AT1G01115 0 0 0 1
AT1G01120 80 152 89 77
......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment