Mercurial > repos > mingchen0919 > rmarkdown_deseq2_count_matrix
comparison rmarkdown_deseq2_count_matrix.Rmd @ 2:18e3fc69da76 draft
update tool
| author | mingchen0919 |
|---|---|
| date | Sat, 30 Dec 2017 16:42:01 -0500 |
| parents | 4a7131658ca6 |
| children | 320aa7da31d9 |
comparison
equal
deleted
inserted
replaced
| 1:4a7131658ca6 | 2:18e3fc69da76 |
|---|---|
| 52 ```{r 'match sample names'} | 52 ```{r 'match sample names'} |
| 53 col_data = col_data[col_names, ] | 53 col_data = col_data[col_names, ] |
| 54 datatable(col_data) | 54 datatable(col_data) |
| 55 ``` | 55 ``` |
| 56 | 56 |
| 57 # DESeqDataSet | |
| 58 | |
| 59 ```{r 'DeseqDataSet'} | |
| 60 dds = DESeqDataSetFromMatrix(countData = count_data, | |
| 61 colData = col_data, | |
| 62 design = formula(opt$design_formula)) | |
| 63 dds | |
| 64 ``` | |
| 65 | |
| 66 Pre-filter low count genes | |
| 67 | |
| 68 ```{r 'pre-filtering'} | |
| 69 keep = rowSums(counts(dds)) >= 10 | |
| 70 dds = dds[keep, ] | |
| 71 dds | |
| 72 ``` | |
| 73 | |
| 74 # Differential expression analysis | |
| 75 | |
| 76 ```{r 'differential expression analysis'} | |
| 77 dds = DESeq(dds) | |
| 78 # res = results(dds, contrast = c(opt$contrast_condition, opt$treatment, opt$control)) | |
| 79 res = results(dds) | |
| 80 resultsNames(dds) | |
| 81 if(nrow(res) > 500) { | |
| 82 cat('The result table has more than 500 rows. Only 500 rows are randomly selected to dispaly.') | |
| 83 datatable(as.data.frame(res)[sample(1:nrow(res), 500), ]) | |
| 84 } else { | |
| 85 datatable(as.data.frame(res)) | |
| 86 } | |
| 87 ``` | |
| 88 | |
| 89 | |
| 90 | |
| 91 ```{r 'write results into csv'} | |
| 92 #Write results into a CSV file. | |
| 93 write.csv(res, 'differential_genes.csv') | |
| 94 ``` | |
| 95 | |
| 96 # MAplot | |
| 97 | |
| 98 ```{r} | |
| 99 plotMA(res) | |
| 100 ``` | |
| 101 | |
| 102 | |
| 103 ```{r 'save R objects'} | |
| 104 # Save R objects to a file | |
| 105 save(dds, opt, file = 'deseq2.RData') | |
| 106 ``` | |
| 107 |
