├── .gitignore ├── 00_scripts ├── .gitignore ├── raw.counts2logcpm.R └── wgcna.R ├── 01_info_files └── .gitignore ├── 02_data ├── .gitignore ├── example_matrix_count.txt └── example_traits.txt ├── 03_results └── .gitignore └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.out 3 | *.err 4 | -------------------------------------------------------------------------------- /00_scripts/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jleluyer/wgcna_workflow/aa784dd78f8b38f4b58bedaf7d416222fc7bf018/00_scripts/.gitignore -------------------------------------------------------------------------------- /00_scripts/raw.counts2logcpm.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/Rscript 2 | 3 | ## test anova GxE interaction ### 4 | #see post 5 | ls() 6 | rm(list=ls()) 7 | ls() 8 | #https://support.bioconductor.org/p/56568/ 9 | ## test Glm approahc with edger ## 10 | library('edgeR') 11 | 12 | 13 | 14 | counts <-read.table("02_data/count_matrix.txt",header=T,na.strings="NA") 15 | 16 | 17 | # Create design 18 | targets <-read.table("01_info_file/design.txt",header=T,na.strings="NA") 19 | targets$genotype <- relevel(targets$genotype, ref=c("wild")) 20 | 21 | targets 22 | 23 | 24 | #reassignng column name 25 | rownames(counts) <- counts[,1] 26 | counts[,1]<- NULL 27 | dim(counts) 28 | str(counts) 29 | colSums(counts) / 1e06 30 | 31 | #nb gene with low count 32 | table( rowSums( counts ) )[ 1:30 ] 33 | #create object 34 | Group <- factor(paste(targets$environment,targets$genotype,sep=".")) 35 | Group 36 | cds <- DGEList( counts , group = Group ) 37 | head(cds$counts) 38 | cds$samples 39 | levels(cds$samples$group) 40 | 41 | #filtering low counts 42 | cds <- cds[rowSums(1e+06 * cds$counts/expandAsMatrix(cds$samples$lib.size, dim(cds)) > 1) >= 2, ] 43 | dim( cds ) 44 | 45 | #calcultate normalization factors 46 | cds <- calcNormFactors( cds ) 47 | cds$samples 48 | 49 | #library size 50 | cds$samples$lib.size*cds$samples$norm.factors 51 | 52 | #Create design (can be created manually) 53 | design <- model.matrix(~genotype *environment, data=targets) 54 | colnames(design) 55 | design 56 | #library size 57 | cds$samples$lib.size*cds$samples$norm.factors 58 | cds$samples$norm.factors 59 | #estimate dispersion 60 | cds <-estimateDisp(cds,design) #estimate all dispersions in one run #add different prior values (prior.df = INT) 61 | names( cds ) 62 | 63 | #create a logcpm matrix 64 | logcpm <- cpm(cds, prior.count=2, log=TRUE) 65 | write.table(logcpm,file="02_data/logcpm_edger.csv",sep=";",row.names=T,quote=F) 66 | -------------------------------------------------------------------------------- /00_scripts/wgcna.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/Rscript 2 | 3 | ################ WGCNA RNA-seq Analysis ############ 4 | #################################################### 5 | ls() 6 | rm(list=ls()) 7 | ls() 8 | #source("http://bioconductor.org/biocLite.R") 9 | #biocLite(c("AnnotationDbi", "impute", "GO.db", "preprocessCore")) 10 | #install.packages("WGCNA") 11 | library("WGCNA") 12 | 13 | # The following setting is important, do not omit. 14 | options(stringsAsFactors = FALSE); 15 | 16 | #Read in the expr data set 17 | logcpm.temperature <-read.table("02_data/logcpm_edger.csv",header=T) 18 | # Take a quick look at what is in the data set: 19 | dim(logcpm.temperature) 20 | 21 | #===================================================================================== 22 | # 23 | # Code chunk 2 24 | # 25 | #===================================================================================== 26 | datExpr0 = as.data.frame(t(logcpm.temperature)) 27 | 28 | #===================================================================================== 29 | # 30 | # Code chunk 3 31 | # 32 | #===================================================================================== 33 | 34 | 35 | gsg = goodSamplesGenes(datExpr0, verbose = 3); 36 | gsg$allOK 37 | 38 | #===================================================================================== 39 | # 40 | # Code chunk 4 41 | # 42 | #===================================================================================== 43 | 44 | 45 | if (!gsg$allOK) 46 | { 47 | # Optionally, print the gene and sample names that were removed: 48 | if (sum(!gsg$goodGenes)>0) 49 | printFlush(paste("Removing genes:", paste(names(datExpr0)[!gsg$goodGenes], collapse = ", "))); 50 | if (sum(!gsg$goodSamples)>0) 51 | printFlush(paste("Removing samples:", paste(rownames(datExpr0)[!gsg$goodSamples], collapse = ", "))); 52 | # Remove the offending genes and samples from the data: 53 | datExpr0 = datExpr0[gsg$goodSamples, gsg$goodGenes] 54 | } 55 | 56 | #===================================================================================== 57 | # 58 | # Code chunk 5 59 | # 60 | #===================================================================================== 61 | 62 | 63 | sampleTree = hclust(dist(datExpr0), method = "average"); 64 | # Plot the sample tree: Open a graphic output window of size 12 by 9 inches 65 | # The user should change the dimensions if the window is too large or too small. 66 | sizeGrWindow(12,9) 67 | #pdf(file = "Plots/sampleClustering.pdf", width = 12, height = 9); 68 | par(cex = 0.6); 69 | par(mar = c(0,4,2,0)) 70 | plot(sampleTree, main = "Sample clustering to detect outliers", sub="", xlab="", cex.lab = 1.5, 71 | cex.axis = 1.5, cex.main = 2) 72 | 73 | #===================================================================================== 74 | # 75 | # Code chunk 6: check outliers 76 | # 77 | #===================================================================================== 78 | 79 | 80 | # Plot a line to show the cut 81 | abline(h = 250, col = "red"); 82 | # Determine cluster under the line 83 | clust = cutreeStatic(sampleTree, cutHeight = 250, minSize = 10) 84 | table(clust) 85 | # clust 1 contains the samples we want to keep. 86 | keepSamples = (clust==1) 87 | datExpr = datExpr0[keepSamples, ] 88 | nGenes = ncol(datExpr) 89 | nSamples = nrow(datExpr) 90 | 91 | #===================================================================================== 92 | # 93 | # Code chunk 7: add traits 94 | # 95 | #===================================================================================== 96 | 97 | 98 | allTraits = read.table("02_data/traits.csv",sep="\t", header=T); 99 | names(allTraits) 100 | 101 | # Form a data frame analogous to expression data that will hold the clinical traits. 102 | 103 | femaleSamples = rownames(datExpr); 104 | traitRows = match(femaleSamples, allTraits$Ind); 105 | datTraits = allTraits[traitRows, -1]; 106 | rownames(datTraits) = allTraits[traitRows, 1]; 107 | str(datTraits) 108 | 109 | collectGarbage(); 110 | 111 | #===================================================================================== 112 | # 113 | # Code chunk 8 114 | # 115 | #===================================================================================== 116 | 117 | 118 | # Re-cluster samples 119 | sampleTree2 = hclust(dist(datExpr), method = "average") 120 | # Convert traits to a color representation: white means low, red means high, grey means missing entry 121 | traitColors = numbers2colors(datTraits, signed = TRUE); 122 | # Plot the sample dendrogram and the colors underneath. 123 | plotDendroAndColors(sampleTree2, traitColors, 124 | groupLabels = names(datTraits), 125 | main = "Sample dendrogram and trait heatmap") 126 | 127 | 128 | #===================================================================================== 129 | # 130 | # Code chunk 9 131 | # 132 | #===================================================================================== 133 | 134 | 135 | save(datExpr, datTraits, file = "testSnapper-dataInput.RData") 136 | 137 | 138 | 139 | ########################## Module construction step-by-step ################################# 140 | ################################################################################ 141 | #===================================================================================== 142 | # 143 | # Code chunk 1 144 | # 145 | #===================================================================================== 146 | 147 | #setting is important, do not omit. 148 | options(stringsAsFactors = FALSE); 149 | # Allow multi-threading within WGCNA. At present this call is necessary. 150 | # Any error here may be ignored but you may want to update WGCNA if you see one. 151 | # Caution: skip this line if you run RStudio or other third-party R environments. 152 | # See note above. 153 | #enableWGCNAThreads() 154 | # Load the data saved in the first part 155 | lnames = load(file = "testSnapper-dataInput.RData"); 156 | #The variable lnames contains the names of loaded variables. 157 | lnames 158 | 159 | 160 | #===================================================================================== 161 | # 162 | # Code chunk 2 163 | # 164 | #===================================================================================== 165 | 166 | load("sft.Rda") 167 | load("testSnapper-dataInput.RData") 168 | # Choose a set of soft-thresholding powers 169 | powers = c(c(1:10), seq(from = 12, to=20, by=2)) 170 | # Call the network topology analysis function 171 | sft = pickSoftThreshold(datExpr, powerVector = powers, verbose = 5) 172 | # Plot the results: 173 | sizeGrWindow(9, 5) 174 | par(mfrow = c(1,2)); 175 | cex1 = 0.9; 176 | # Scale-free topology fit index as a function of the soft-thresholding power 177 | plot(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2], 178 | xlab="Soft Threshold (power)",ylab="Scale Free Topology Model Fit,signed R^2",type="n", 179 | main = paste("Scale independence")); 180 | text(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2], 181 | labels=powers,cex=cex1,col="red"); 182 | # this line corresponds to using an R^2 cut-off of h 183 | abline(h=0.90,col="red") 184 | # Mean connectivity as a function of the soft-thresholding power 185 | plot(sft$fitIndices[,1], sft$fitIndices[,5], 186 | xlab="Soft Threshold (power)",ylab="Mean Connectivity", type="n", 187 | main = paste("Mean connectivity")) 188 | text(sft$fitIndices[,1], sft$fitIndices[,5], labels=powers, cex=cex1,col="red") 189 | 190 | 191 | #===================================================================================== 192 | # 193 | # Code chunk 3 194 | # 195 | #===================================================================================== 196 | 197 | 198 | softPower = 6; 199 | adjacency = adjacency(datExpr, power = softPower); 200 | 201 | 202 | #===================================================================================== 203 | # 204 | # Code chunk 4 205 | # 206 | #===================================================================================== 207 | 208 | load("sft.Rda") 209 | # Turn adjacency into topological overlap 210 | TOM = TOMsimilarity(adjacency); 211 | dissTOM = 1-TOM 212 | 213 | 214 | #===================================================================================== 215 | # 216 | # Code chunk 5 217 | # 218 | #===================================================================================== 219 | 220 | 221 | # Call the hierarchical clustering function 222 | geneTree = hclust(as.dist(dissTOM), method = "average"); 223 | # Plot the resulting clustering tree (dendrogram) 224 | sizeGrWindow(12,9) 225 | plot(geneTree, xlab="", sub="", main = "Gene clustering on TOM-based dissimilarity", 226 | labels = FALSE, hang = 0.04); 227 | 228 | 229 | #===================================================================================== 230 | # 231 | # Code chunk 6 232 | # 233 | #===================================================================================== 234 | 235 | 236 | # We like large modules, so we set the minimum module size relatively high: 237 | minModuleSize = 30; 238 | # Module identification using dynamic tree cut: 239 | dynamicMods = cutreeDynamic(dendro = geneTree, distM = dissTOM, 240 | deepSplit = 2, pamRespectsDendro = FALSE, 241 | minClusterSize = minModuleSize); 242 | table(dynamicMods) 243 | 244 | 245 | #===================================================================================== 246 | # 247 | # Code chunk 7 248 | # 249 | #===================================================================================== 250 | 251 | 252 | # Convert numeric lables into colors 253 | dynamicColors = labels2colors(dynamicMods) 254 | table(dynamicColors) 255 | # Plot the dendrogram and colors underneath 256 | sizeGrWindow(8,6) 257 | plotDendroAndColors(geneTree, dynamicColors, "Dynamic Tree Cut", 258 | dendroLabels = FALSE, hang = 0.03, 259 | addGuide = TRUE, guideHang = 0.05, 260 | main = "Gene dendrogram and module colors") 261 | 262 | 263 | #===================================================================================== 264 | # 265 | # Code chunk 8 266 | # 267 | #===================================================================================== 268 | 269 | 270 | # Calculate eigengenes 271 | MEList = moduleEigengenes(datExpr, colors = dynamicColors) 272 | MEs = MEList$eigengenes 273 | # Calculate dissimilarity of module eigengenes 274 | MEDiss = 1-cor(MEs); 275 | # Cluster module eigengenes 276 | METree = hclust(as.dist(MEDiss), method = "average"); 277 | # Plot the result 278 | sizeGrWindow(7, 6) 279 | plot(METree, main = "Clustering of module eigengenes", 280 | xlab = "", sub = "") 281 | 282 | 283 | #===================================================================================== 284 | # 285 | # Code chunk 9 286 | # 287 | #===================================================================================== 288 | 289 | 290 | MEDissThres = 0.25 291 | # Plot the cut line into the dendrogram 292 | abline(h=MEDissThres, col = "red") 293 | # Call an automatic merging function 294 | merge = mergeCloseModules(datExpr, dynamicColors, cutHeight = MEDissThres, verbose = 3) 295 | # The merged module colors 296 | mergedColors = merge$colors; 297 | # Eigengenes of the new merged modules: 298 | mergedMEs = merge$newMEs; 299 | 300 | 301 | #===================================================================================== 302 | # 303 | # Code chunk 10 304 | # 305 | #===================================================================================== 306 | 307 | 308 | sizeGrWindow(12, 9) 309 | #pdf(file = "Plots/geneDendro-3.pdf", wi = 9, he = 6) 310 | plotDendroAndColors(geneTree, cbind(dynamicColors, mergedColors), 311 | c("Dynamic Tree Cut", "Merged dynamic"), 312 | dendroLabels = FALSE, hang = 0.03, 313 | addGuide = TRUE, guideHang = 0.05) 314 | #dev.off() 315 | 316 | 317 | #===================================================================================== 318 | # 319 | # Code chunk 11 320 | # 321 | #===================================================================================== 322 | 323 | 324 | # Rename to moduleColors 325 | moduleColors = mergedColors 326 | # Construct numerical labels corresponding to the colors 327 | colorOrder = c("grey", standardColors(50)); 328 | moduleLabels = match(moduleColors, colorOrder)-1; 329 | MEs = mergedMEs; 330 | # Save module colors and labels for use in subsequent parts 331 | save(MEs, moduleLabels, moduleColors, geneTree, file = "Snapper-networkConstruction-stepByStep.RData") 332 | 333 | 334 | ############### Relating genes with traits and identifying important traits ############## 335 | ########################################################################################## 336 | 337 | #===================================================================================== 338 | # 339 | # Code chunk 1 340 | # 341 | #===================================================================================== 342 | 343 | # The following setting is important, do not omit. 344 | options(stringsAsFactors = FALSE); 345 | # Load the expression and trait data saved in the first part 346 | lnames = load(file = "testSnapper-dataInput.RData"); 347 | #The variable lnames contains the names of loaded variables. 348 | lnames 349 | # Load network data saved in the second part. 350 | lnames = load(file = "Snapper-networkConstruction-stepByStep.RData"); 351 | lnames 352 | 353 | 354 | #===================================================================================== 355 | # 356 | # Code chunk 2 357 | # 358 | #===================================================================================== 359 | 360 | 361 | # Define numbers of genes and samples 362 | nGenes = ncol(datExpr); 363 | nSamples = nrow(datExpr); 364 | # Recalculate MEs with color labels 365 | MEs0 = moduleEigengenes(datExpr, moduleColors)$eigengenes 366 | MEs = orderMEs(MEs0) 367 | moduleTraitCor = cor(MEs, datTraits, use = "p"); 368 | moduleTraitPvalue = corPvalueStudent(moduleTraitCor, nSamples); 369 | 370 | 371 | #===================================================================================== 372 | # 373 | # Code chunk 3 374 | # 375 | #===================================================================================== 376 | 377 | 378 | #sizeGrWindow(16,10) 379 | pdf("correlation_matrix.test.pdf",width=16,height = 12) 380 | # Will display correlations and their p-values 381 | 382 | moduleTraitPvalue[moduleTraitPvalue>0.05]=NA #test 383 | textMatrix = paste(signif(moduleTraitCor, 2), "\n(", 384 | signif(moduleTraitPvalue, 1), ")", sep = ""); 385 | 386 | 387 | 388 | dim(textMatrix) = dim(moduleTraitCor) 389 | par(mar = c(6, 8.5, 3, 3)); 390 | # Display the correlation values within a heatmap plot 391 | labeledHeatmap(Matrix = moduleTraitCor, 392 | xLabels = names(datTraits), 393 | yLabels = names(MEs), 394 | ySymbols = names(MEs), 395 | colorLabels = FALSE, 396 | colors = blueWhiteRed(50), 397 | textAdj = c(0.5, 0.5), 398 | textMatrix = textMatrix, 399 | setStdMargins = FALSE, 400 | cex.text = 0.5, 401 | zlim = c(-1,1), 402 | main = paste("Module-trait relationships")) 403 | dev.off() 404 | 405 | #===================================================================================== 406 | # 407 | # Code chunk 4 408 | # 409 | #===================================================================================== 410 | 411 | 412 | # Define variable weight containing the weight column of datTrait 413 | weight = as.data.frame(datTraits$SGR_i); 414 | names(weight) = "weight" 415 | str(weight) 416 | # names (colors) of the modules 417 | modNames = substring(names(MEs), 3) 418 | 419 | geneModuleMembership = as.data.frame(cor(datExpr, MEs, use = "p")); 420 | str(geneModuleMembership) 421 | MMPvalue = as.data.frame(corPvalueStudent(as.matrix(geneModuleMembership), nSamples)); 422 | 423 | names(geneModuleMembership) = paste("MM", modNames, sep=""); 424 | names(MMPvalue) = paste("p.MM", modNames, sep=""); 425 | 426 | geneTraitSignificance = as.data.frame(cor(datExpr, weight, use = "p")); 427 | GSPvalue = as.data.frame(corPvalueStudent(as.matrix(geneTraitSignificance), nSamples)); 428 | 429 | names(geneTraitSignificance) = paste("GS.", names(weight), sep=""); 430 | names(GSPvalue) = paste("p.GS.", names(weight), sep=""); 431 | 432 | 433 | #===================================================================================== 434 | # 435 | # Code chunk 5 436 | # 437 | #===================================================================================== 438 | 439 | 440 | module = "darkolivegreen" 441 | column = match(module, modNames); 442 | moduleGenes = moduleColors==module; 443 | 444 | sizeGrWindow(7, 7); 445 | par(mfrow = c(1,1)); 446 | verboseScatterplot(abs(geneModuleMembership[moduleGenes, column]), 447 | abs(geneTraitSignificance[moduleGenes, 1]), 448 | xlab = paste("Module Membership in", module, "module"), 449 | ylab = "Gene significance for body weight", 450 | main = paste("Module membership vs. gene significance\n"), 451 | cex.main = 1.2, cex.lab = 1.2, cex.axis = 1.2, col = module) 452 | 453 | 454 | #===================================================================================== 455 | # 456 | # Code chunk 6 457 | # 458 | #===================================================================================== 459 | 460 | 461 | names(datExpr) 462 | 463 | 464 | #===================================================================================== 465 | # 466 | # Code chunk 7 467 | # 468 | #===================================================================================== 469 | 470 | 471 | names(datExpr)[moduleColors=="brown2"] 472 | 473 | 474 | #===================================================================================== 475 | # 476 | # Code chunk 8 477 | # 478 | #===================================================================================== 479 | 480 | 481 | annot = read.csv(file = "GeneAnnotation.csv"); 482 | dim(annot) 483 | names(annot) 484 | probes = names(datExpr) 485 | probes2annot = match(probes, annot$substanceBXH) 486 | # The following is the number or probes without annotation: 487 | sum(is.na(probes2annot)) 488 | # Should return 0. 489 | 490 | 491 | #===================================================================================== 492 | # 493 | # Code chunk 9 494 | # 495 | #===================================================================================== 496 | 497 | 498 | # Create the starting data frame 499 | geneInfo0 = data.frame(substanceBXH = probes, 500 | geneSymbol = annot$gene_symbol[probes2annot], 501 | LocusLinkID = annot$LocusLinkID[probes2annot], 502 | moduleColor = moduleColors, 503 | geneTraitSignificance, 504 | GSPvalue) 505 | # Order modules by their significance for weight 506 | modOrder = order(-abs(cor(MEs, weight, use = "p"))); 507 | # Add module membership information in the chosen order 508 | for (mod in 1:ncol(geneModuleMembership)) 509 | { 510 | oldNames = names(geneInfo0) 511 | geneInfo0 = data.frame(geneInfo0, geneModuleMembership[, modOrder[mod]], 512 | MMPvalue[, modOrder[mod]]); 513 | names(geneInfo0) = c(oldNames, paste("MM.", modNames[modOrder[mod]], sep=""), 514 | paste("p.MM.", modNames[modOrder[mod]], sep="")) 515 | } 516 | # Order the genes in the geneInfo variable first by module color, then by geneTraitSignificance 517 | geneOrder = order(geneInfo0$moduleColor, -abs(geneInfo0$GS.weight)); 518 | geneInfo = geneInfo0[geneOrder, ] 519 | 520 | 521 | #===================================================================================== 522 | # 523 | # Code chunk 10 524 | # 525 | #===================================================================================== 526 | 527 | 528 | write.csv(geneInfo, file = "geneInfo.csv") 529 | 530 | 531 | 532 | 533 | ########################## Visualize network ########################## 534 | ####################################################################### 535 | 536 | #===================================================================================== 537 | # 538 | # Code chunk 1 539 | # 540 | #===================================================================================== 541 | 542 | # Load the expression and trait data saved in the first part 543 | lnames = load(file = "FemaleLiver-01-dataInput.RData"); 544 | #The variable lnames contains the names of loaded variables. 545 | lnames 546 | # Load network data saved in the second part. 547 | lnames = load(file = "FemaleLiver-02-networkConstruction-auto.RData"); 548 | lnames 549 | nGenes = ncol(datExpr) 550 | nSamples = nrow(datExpr) 551 | 552 | 553 | #===================================================================================== 554 | # 555 | # Code chunk 2 556 | # 557 | #===================================================================================== 558 | 559 | 560 | # Calculate topological overlap anew: this could be done more efficiently by saving the TOM 561 | # calculated during module detection, but let us do it again here. 562 | dissTOM = 1-TOMsimilarityFromExpr(datExpr, power = 6); 563 | # Transform dissTOM with a power to make moderately strong connections more visible in the heatmap 564 | plotTOM = dissTOM^7; 565 | # Set diagonal to NA for a nicer plot 566 | diag(plotTOM) = NA; 567 | # Call the plot function 568 | sizeGrWindow(9,9) 569 | TOMplot(plotTOM, geneTree, moduleColors, main = "Network heatmap plot, all genes") 570 | 571 | 572 | #===================================================================================== 573 | # 574 | # Code chunk 3 575 | # 576 | #===================================================================================== 577 | 578 | 579 | nSelect = 400 580 | # For reproducibility, we set the random seed 581 | set.seed(10); 582 | select = sample(nGenes, size = nSelect); 583 | selectTOM = dissTOM[select, select]; 584 | # There's no simple way of restricting a clustering tree to a subset of genes, so we must re-cluster. 585 | selectTree = hclust(as.dist(selectTOM), method = "average") 586 | selectColors = moduleColors[select]; 587 | # Open a graphical window 588 | sizeGrWindow(9,9) 589 | # Taking the dissimilarity to a power, say 10, makes the plot more informative by effectively changing 590 | # the color palette; setting the diagonal to NA also improves the clarity of the plot 591 | plotDiss = selectTOM^7; 592 | diag(plotDiss) = NA; 593 | TOMplot(plotDiss, selectTree, selectColors, main = "Network heatmap plot, selected genes") 594 | 595 | 596 | #===================================================================================== 597 | # 598 | # Code chunk 4 599 | # 600 | #===================================================================================== 601 | 602 | 603 | # Recalculate module eigengenes 604 | MEs = moduleEigengenes(datExpr, moduleColors)$eigengenes 605 | # Isolate weight from the clinical traits 606 | weight = as.data.frame(datTraits$weight_g); 607 | names(weight) = "weight" 608 | # Add the weight to existing module eigengenes 609 | MET = orderMEs(cbind(MEs, weight)) 610 | # Plot the relationships among the eigengenes and the trait 611 | sizeGrWindow(5,7.5); 612 | par(cex = 0.9) 613 | plotEigengeneNetworks(MET, "", marDendro = c(0,4,1,2), marHeatmap = c(3,4,1,2), cex.lab = 0.8, xLabelsAngle 614 | = 90) 615 | 616 | 617 | #===================================================================================== 618 | # 619 | # Code chunk 5 620 | # 621 | #===================================================================================== 622 | 623 | 624 | # Plot the dendrogram 625 | sizeGrWindow(6,6); 626 | par(cex = 1.0) 627 | plotEigengeneNetworks(MET, "Eigengene dendrogram", marDendro = c(0,4,2,0), 628 | plotHeatmaps = FALSE) 629 | # Plot the heatmap matrix (note: this plot will overwrite the dendrogram plot) 630 | par(cex = 1.0) 631 | plotEigengeneNetworks(MET, "Eigengene adjacency heatmap", marHeatmap = c(3,4,2,2), 632 | plotDendrograms = FALSE, xLabelsAngle = 90) 633 | 634 | 635 | -------------------------------------------------------------------------------- /01_info_files/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jleluyer/wgcna_workflow/aa784dd78f8b38f4b58bedaf7d416222fc7bf018/01_info_files/.gitignore -------------------------------------------------------------------------------- /02_data/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jleluyer/wgcna_workflow/aa784dd78f8b38f4b58bedaf7d416222fc7bf018/02_data/.gitignore -------------------------------------------------------------------------------- /02_data/example_matrix_count.txt: -------------------------------------------------------------------------------- 1 | name DH-1MA DH-4MA DH-5MA DL-4MA DL-5MA DL-6MA WH-1MA WH-2MA WH-3MA WL-1MA WL-3MA WL-6MA 2 | TRINITY_DN100006_c0_g1_i1 0 0 0 0 0 0 0 0 1 0 0 0 3 | TRINITY_DN100014_c0_g1_i1 0 0 0 0 0 0 0 0 3 0 0 0 4 | TRINITY_DN100027_c0_g1_i1 0 0 0 0 0 0 2 0 0 1 0 1 5 | TRINITY_DN100040_c0_g1_i1 0 2 0 0 0 0 0 0 0 0 0 0 6 | TRINITY_DN100067_c0_g1_i1 199 140 159 186 160 158 163 173 433 246 214 251 7 | TRINITY_DN100085_c0_g1_i1 140 161 82 128 69 65 97 82 60 65 84 67 8 | TRINITY_DN100122_c0_g1_i1 0 1 0 0 0 0 0 0 5 0 0 0 9 | TRINITY_DN100127_c0_g1_i1 2 0 0 0 2 6 1 0 1 1 0 4 10 | TRINITY_DN100142_c0_g1_i1 0 0 0 5 0 0 0 0 3 1 0 1 11 | -------------------------------------------------------------------------------- /02_data/example_traits.txt: -------------------------------------------------------------------------------- 1 | Ind temperature SGR LGR_i 2 | WL.1MA 1 -0.315604109 0 3 | WL.3MA 1 -0.279944746 0 4 | WL.6MA 1 -0.183479979 0 5 | WH.1MA 2 0.477891228 0.214285714 6 | WH.2MA 2 0.145146367 0.071428571 7 | WH.3MA 2 0.004517937 0 8 | DL.4MA 1 0.066415142 0 9 | DL.5MA 1 0.215006766 0 10 | DL.6MA 1 0.102285665 0.035714286 11 | -------------------------------------------------------------------------------- /03_results/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jleluyer/wgcna_workflow/aa784dd78f8b38f4b58bedaf7d416222fc7bf018/03_results/.gitignore -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wgcna_workflow 2 | Analysis of co-expression networks from RNA-seq data 3 | --------------------------------------------------------------------------------