comparison aurora_wgcna_trait.Rmd @ 11:01ace2c8a593 draft

Uploaded
author spficklin
date Fri, 22 Nov 2019 01:47:07 +0000
parents ffbafe466107
children 3ed8495d7df7
comparison
equal deleted inserted replaced
10:26bc5ed5d489 11:01ace2c8a593
5 number_sections: false 5 number_sections: false
6 toc: true 6 toc: true
7 --- 7 ---
8 8
9 ```{r setup, include=FALSE, warning=FALSE, message=FALSE} 9 ```{r setup, include=FALSE, warning=FALSE, message=FALSE}
10 knitr::opts_chunk$set(error = TRUE, echo = FALSE) 10 knitr::opts_chunk$set(error = FALSE, echo = FALSE)
11 ``` 11 ```
12 ```{r} 12 ```{r}
13 # Load the data from the previous step. 13 # Load the data from the previous step.
14 load(file=opt$r_data) 14 load(file=opt$r_data)
15 ``` 15 ```
55 trait_data = cbind(keep, encoded) 55 trait_data = cbind(keep, encoded)
56 } 56 }
57 57
58 datatable(trait_data) 58 datatable(trait_data)
59 ``` 59 ```
60 # Module-Condition Association. 60 # Module-Condition Association
61
61 Now that we have trait/phenotype data, we can explore if any of the network modules are asociated with these features. First, is an empirical exploration by viewing again the sample dendrogram but with traits added and colored by category or numerical intensity, as appropriate. If groups of samples with similar expression also share similar annotations then the same colors will appear "in blocks" under the clustered samples. This view does not indicate associations but can help visualize when some modules might be associated. 62 Now that we have trait/phenotype data, we can explore if any of the network modules are asociated with these features. First, is an empirical exploration by viewing again the sample dendrogram but with traits added and colored by category or numerical intensity, as appropriate. If groups of samples with similar expression also share similar annotations then the same colors will appear "in blocks" under the clustered samples. This view does not indicate associations but can help visualize when some modules might be associated.
62 63
63 ```{r fig.align='center', fig.width=8, fig.height=9} 64 ```{r fig.align='center', fig.width=8, fig.height=9}
64 65
65 # Determine the column types within the trait annotation data. 66 # Determine the column types within the trait annotation data.
66 trait_types = sapply(trait_data, class) 67 trait_types = sapply(trait_data, class)
68
69 # So that we can merge colors together with a cbind, create a
70 # data frame with an empty column
67 trait_colors = data.frame(empty = rep(1:dim(trait_data)[1])) 71 trait_colors = data.frame(empty = rep(1:dim(trait_data)[1]))
68 72
69 # Set the colors for the quantitative data. 73 # Set the colors for the quantitative data.
70 quantitative_fields = colnames(trait_data)[which(trait_types == "numeric")] 74 quantitative_fields = colnames(trait_data)[which(trait_types == "numeric")]
71 if (length(quantitative_fields) > 0) { 75 if (length(quantitative_fields) > 0) {
91 ordinal_colors = numbers2colors(odata, signed = FALSE) 95 ordinal_colors = numbers2colors(odata, signed = FALSE)
92 colnames(ordinal_colors) = ordinal_fields 96 colnames(ordinal_colors) = ordinal_fields
93 trait_colors = cbind(trait_colors, ordinal_colors) 97 trait_colors = cbind(trait_colors, ordinal_colors)
94 } 98 }
95 99
100 # Remove the empty column from teh trait_colors dataframe and
101 # reorder the colors to match the same order of columns in the trait_data df.
96 trait_colors = subset(trait_colors, select=-c(empty)) 102 trait_colors = subset(trait_colors, select=-c(empty))
97 trait_colors = trait_colors[,colnames(trait_data)] 103 trait_colors = trait_colors[,colnames(trait_data)]
98 options(repr.plot.width=15, repr.plot.height=10) 104 options(repr.plot.width=15, repr.plot.height=10)
99 plotDendroAndColors(sampleTree, trait_colors, 105 plotDendroAndColors(sampleTree, trait_colors,
100 groupLabels = names(trait_data), 106 groupLabels = names(trait_data),