Mercurial > repos > mingchen0919 > rmarkdown_deseq2
diff DESeq_results.Rmd @ 6:2f8ddef8d545 draft
update deseq2
author | mingchen0919 |
---|---|
date | Tue, 07 Nov 2017 13:50:32 -0500 |
parents | 7231d7e8d3ed |
children |
line wrap: on
line diff
--- a/DESeq_results.Rmd Tue Aug 08 15:06:40 2017 -0400 +++ b/DESeq_results.Rmd Tue Nov 07 13:50:32 2017 -0500 @@ -10,17 +10,14 @@ ```{r setup, include=FALSE, warning=FALSE, message=FALSE} knitr::opts_chunk$set( - echo = ECHO + echo = ECHO, + error = TRUE ) - -library(DESeq2) -library(pheatmap) -library(genefilter) ``` -# Import workspace ```{r eval=TRUE} +# Import workspace fcp = file.copy("DESEQ_WORKSPACE", "deseq.RData") load("deseq.RData") ``` @@ -30,9 +27,11 @@ ## Result table ```{r} -group = colnames(sample_table)[CONTRAST_GROUP] -res <- results(dds, contrast = c(group, 'TREATMENT_LEVEL', 'CONDITION_LEVEL')) -datatable(as.data.frame(res), style="bootstrap", filter = 'top', +cat('--- View the top 100 rows of the result table ---') +res <- results(dds, contrast = c('CONTRAST_FACTOR', 'TREATMENT_LEVEL', 'CONDITION_LEVEL')) +write.csv(as.data.frame(res), file = 'deseq_results.csv') +res_df = as.data.frame(res)[1:100, ] +datatable(res_df, style="bootstrap", filter = 'top', class="table-condensed", options = list(dom = 'tp', scrollX = TRUE)) ``` @@ -45,16 +44,10 @@ # MA-plot {.tabset} -## Shrinked with `lfcShrink()` function -```{r eval=FALSE} -shrink_res = DESeq2::lfcShrink(dds, contrast = c(group, 'TREATMENT_LEVEL', 'CONDITION_LEVEL'), res=res) -plotMA(shrink_res) -``` - -## Shrinked with Bayesian procedure ```{r} +cat('--- Shrinked with Bayesian procedure ---') plotMA(res) ``` @@ -68,11 +61,11 @@ ``` -# Gene clustering +# Visualization {.tabset} +## Gene clustering ```{r} -group_index = as.numeric(strsplit("CLUSTERING_GROUPS", ',')[[1]]) -clustering_groups = colnames(sample_table)[group_index] +clustering_groups = strsplit("CLUSTERING_FACTORS", ',')[[1]] topVarGenes <- head(order(rowVars(assay(rld)), decreasing = TRUE), 20) mat <- assay(rld)[ topVarGenes, ] @@ -83,3 +76,34 @@ pheatmap(mat, annotation_col = annotation_col) ``` +## Sample-to-sample distance + +```{r} +sampleDistMatrix <- as.matrix( sampleDists ) +colors <- colorRampPalette( rev(brewer.pal(9, "Blues")) )(255) +pheatmap(sampleDistMatrix, + clustering_distance_cols = sampleDists, + col = colors) +``` + +## PCA plot + +```{r} +plotPCA(rld, intgroup = clustering_groups) +``` + +## MDS plot {.tabset} + +### Data table +```{r} +mds <- as.data.frame(colData(rld)) %>% + cbind(cmdscale(sampleDistMatrix)) +knitr::kable(mds) +``` + +### Plot +```{r} +ggplot(mds, aes(x = `1`, y = `2`, col = time)) + + geom_point(size = 3) + coord_fixed() +``` +