Contents

1 Overview

GWENA (Gene Whole co-Expression Network Analysis) is an R package to perform gene co-expression network analysis in a single pipeline. This pipeline includes functional enrichment of modules of co-expressed genes, phenotypcal association, topological analysis and comparisons of networks between conditions.

Using transcriptomics data from either RNA-seq or microarray, the package follows the steps displayed in Figure 1:

  1. Input: data is provided as a data.frame or a matrix of expression intensities (pre-normalized).
  2. Gene filtering: data is filtered according to the transcriptomic technology used.
  3. Network building: a matrix of similarity score is computed between each gene with Spearman correlation, then transformed into an adjacency matrix, and finally into a topological overlap matrix.
  4. Modules detection: groups of genes with closest similarity scores are detected as modules.
  5. Biological integration: gene set enrichment analysis and phenotypic association (if phenotypes are provided) are performed on modules.
  6. Graph visualization and topological analysis: hub genes are identified, as well as visualization of modules.
  7. Networks comparison: if multiple conditions are available (time points, treatments, phenotype, etc.), analysis of modules preservation/non-preservation between conditions can be performed.

This document gives a brief tutorial using a subset of a microarray data set to show the content and value of each step in the pipeline.

.

Figure 1. Analysis pipeline of GWENA, from expression data to characterization of the modules and comparison of conditions.

2 Main steps of the pipeline

2.1 Starting with GWENA

Installation can either be from:

  1. the official version of the last Bioconductor release (recommended).
  2. the last stable version from the Bioc Devel branch.
  3. the day-to-day development version from the Github repository.
if (!requireNamespace("BiocManager", quietly=TRUE))
  install.packages("BiocManager")

# 1. From Bioconductor release
BiocManager::install("GWENA")

# 2. From Bioconductor devel
BiocManager::install("GWENA", version = "devel")

# 3. From Github repository
BiocManager::install("Kumquatum/GWENA")
# OR
if (!requireNamespace("devtools", quietly=TRUE))
  install.packages("devtools")
devtools::install_github("Kumquatum/GWENA")

Package loading:

library(GWENA)
library(magrittr) # Not mandatory, we use the pipe `%>%` to ease readability.

threads_to_use <- 2

2.2 Input data

2.2.1 The expression data

GWENA support expression matrix data coming from either RNA-seq or microarray experiments. Expression data have to be stored as text or spreadsheet files and formatted with genes as columns and samples as rows. To read this file with R, use the appropriate function according to the data separator (e.g. read.csv, read.table). Moreover, the expression data have to be normalized and transcripts expression reduced to the gene level (See How can I reduce my transcriptomic data to the gene level ? since GWENA is designed to build gene co-expression networks.

In this vignette, we use the microarray data set GSE85358 from the Kuehne et al. study. This data was gathered from a skin ageing study and has been processed and normalized with the R script provided in Additional data n°10 of the corresponding article.

# Import expression table
data("kuehne_expr")
# If kuehne_expr was in a file :
# kuehne_expr = read.table(<path_to_file>, header=TRUE, row.names=1)

# Number of genes
ncol(kuehne_expr)
#> [1] 15801
# Number of samples
nrow(kuehne_expr)
#> [1] 48

# Overview of expression table
kuehne_expr[1:5,1:5]
#>                  A_19_P00325768 A_19_P00800244 A_19_P00801821 A_19_P00802027
#> 253949420929_1_1       10.27450       5.530172       10.75672       16.78277
#> 253949420929_1_2       10.23440       5.712894       11.05393       16.25480
#> 253949420929_1_3       10.54336       5.889068       10.92150       16.39615
#> 253949420929_1_4       10.32649       5.646343       10.55770       16.37210
#> 253949420929_2_1       10.13626       5.726866       11.23012       16.41413
#>                  A_19_P00802201
#> 253949420929_1_1       8.549254
#> 253949420929_1_2       8.313369
#> 253949420929_1_3       8.469018
#> 253949420929_1_4       7.983723
#> 253949420929_2_1       7.521542

# Checking expression data set is correctly defined
is_data_expr(kuehne_expr)
#> $bool
#> [1] TRUE
#> 
#> $reason
#> NULL

2.2.2 The metadata

To be able to perform the phenotypic association step of the pipeline (optional), we need to specify in another matrix the information associated with each sample (e.g. condition, treatment, phenotype, experiment date…). This information is often provided in a separate file (also text or spreadsheet) and can be read in R with read.csv or read.table functions.

# Import phenotype table (also called traits)
data("kuehne_traits")
# If kuehne_traits was in a file :
# kuehne_traits = read.table(<path_to_file>, header=TRUE, row.names=1)

# Phenotype
unique(kuehne_traits$Condition)
#> [1] "young" "old"

# Overview of traits table
kuehne_traits[1:5,]
#>          Slide Array Exp Condition Age
#> 1 253949420929     1 1_1     young  23
#> 2 253949420929     2 1_2       old  66
#> 3 253949420929     3 1_3     young  21
#> 4 253949420929     4 1_4       old  62
#> 5 253949420929     5 2_1     young  25

2.2.3 Using SummarizedExperiment object

GWENA is also compatible with the use of SummarizedExperiment. The previous dataset can therefore be transformed as one and used in the next steps

se_kuehne <- SummarizedExperiment::SummarizedExperiment(
  assays = list(expr = t(kuehne_expr)),
  colData = S4Vectors::DataFrame(kuehne_traits)
)

S4Vectors::metadata(se_kuehne) <- list(
  experiment_type = "Expression profiling by array",
  transcriptomic_technology = "Microarray",
  GEO_accession_id = "GSE85358",
  overall_design = paste("Gene expression in epidermal skin samples from the",
                         "inner forearms 24 young (20 to 25 years) and 24 old",
                         "(55 to 66 years) human volunteers were analysed", 
                         "using Agilent Whole Human Genome Oligo Microarrays",
                         "8x60K V2."),
  contributors = c("Kuehne A", "Hildebrand J", "Soehle J", "Wenck H", 
                   "Terstegen L", "Gallinat S", "Knott A", "Winnefeld M", 
                   "Zamboni N"),
  title = paste("An integrative metabolomics and transcriptomics study to",
                "identify metabolic alterations in aged skin of humans in", 
                "vivo"),
  URL = "https://www.ncbi.nlm.nih.gov/pubmed/28201987",
  PMIDs = 28201987
)

2.3 Gene filtering

Although the co-expression method implemented within GWENA is designed to manage and filter out low co-expressed genes, it is advisable to first reduce the dataset size. Indeed, loading a full expression matrix without filtering for uninformative data will result in excessive processing time, CPU and memory usage, and data storage. However, the author urges the users to proceed carefully during the filtering as it will impact the gene network building.

Multiple filtration methods have been natively implemented :

  • For RNA-seq and microarray:
    • filter_low_var : Filtering on low variation of expression
  • For RNA-seq data:
    • filter_RNA_seq(<...>, method = "at least one"): only one sample needs to have a value above the minimal count threshold in the gene
    • filter_RNA_seq(<...>, method = "mean"): the means of all samples for the gene needs to be above min_count
    • filter_RNA_seq(<...>, method = "all"): all samples for the gene need to be above min_count

NB: The authors of WGCNA (used in GWENA for network building) advise against using differentially expressed (DE) genes as a filter since its module detection method is based on unsupervised clustering. Moreover, using DE genes will break the scale-free property (small-world network) on which the adjacency matrix is calculated.

In this example, we will be filtering the low variable genes with filter_low_var function.

kuehne_expr_filtered <- filter_low_var(kuehne_expr, pct = 0.7, type = "median")

# Remaining number of genes
ncol(kuehne_expr_filtered)
#> [1] 11060

2.4 Network building

Gene co-expression networks are an ensemble of genes (nodes) linked to each other (edges) according to the strength of their relation. In GWENA, this strength is estimated by the computation of a (dis)similarity score which can start with a distance (euclidian, minkowski, …) but is usually a correlation. Among these, Pearson’s one is the most popular, however in GWENA we use Spearman correlation by default. It is less sensitive to outliers which are frequent in transcriptomics datasets and does not assume that the data follows the normal distribution.

The co-expression network is built according to the following sub-steps :

  1. A correlation (or distance) between each pair of genes is computed.
  2. The correlation distributions are fitted to a power law.
  3. An adjacency score is computed by adjusting previous correlations by the fitted power law.
  4. A topological overlap score is computed by accounting for the network’s topology.

These successive adjustments improve the detection of modules for the next step.

# In order to fasten the example execution time, we only take an 
# arbitary sample of the genes. 
kuehne_expr_filtered <- kuehne_expr_filtered[, 1:1000]

net <- build_net(kuehne_expr_filtered, cor_func = "spearman", 
                 n_threads = threads_to_use)

# Power selected :
net$metadata$power
#> [1] 8

# Fit of the power law to data ($R^2$) :
fit_power_table <- net$metadata$fit_power_table
fit_power_table[fit_power_table$Power == net$metadata$power, "SFT.R.sq"]
#> [1] 0.917733

2.5 Modules detection

At this point, the network is a complete graph: all nodes are connected to all other nodes with different strengths. Because gene co-expression networks have a scale free property, groups of genes are strongly linked with one another. In co-expression networks these groups are called modules and assumed to be representative of genes working together to a common set of functions.

Such modules can be detected using unsupervised learning or modeling. GWENA use the hierarchical clustering but other methods can be used (kmeans, Gaussian mixture models, etc.).

detection <- detect_modules(kuehne_expr_filtered, 
                            net$network, 
                            detailled_result = TRUE,
                            merge_threshold = 0.25)

Important: Module 0 contains all genes that did not fit into any modules.

Since this operation tends to create multiple smaller modules with highly similar expression profile (based on the eigengene of each), they are usually merged into one.

# Number of modules before merging :
length(unique(detection$modules_premerge))
#> [1] 10
# Number of modules after merging: 
length(unique(detection$modules))
#> [1] 4

plot_modules_merge(modules_premerge = detection$modules_premerge, 
                   modules_merged = detection$modules)

#>             [,1] [,2]
#>  [1,] -1.0000000    1
#>  [2,] -0.7777778    1
#>  [3,]  0.1111111    1
#>  [4,]  0.3333333    1
#>  [5,]  0.5555556    1
#>  [6,] -0.5555556    1
#>  [7,] -0.3333333    1
#>  [8,] -0.1111111    1
#>  [9,]  0.7777778    1
#> [10,]  1.0000000    1
#> [11,] -1.0000000   -1
#> [12,] -0.4444444   -1
#> [13,]  0.4444444   -1
#> [14,]  1.0000000   -1

Resulting modules contain more genes whose repartition can be seen by a simple barplot.

ggplot2::ggplot(data.frame(detection$modules %>% stack), 
                ggplot2::aes(x = ind)) + ggplot2::stat_count() +
  ggplot2::ylab("Number of genes") +
  ggplot2::xlab("Module")

Each of the modules presents a distinct profile, which can be plotted in two figures to separate the positive (+ facet) and negative (- facet) correlations profile. As a summary of this profile, the eigengene (red line) is displayed to act as a signature.

# plot_expression_profiles(kuehne_expr_filtered, detection$modules)

2.6 Biological integration

2.6.1 Functional enrichment

A popular way to explore the modules consists of linking them with a known biological function by using currated gene sets. Among the available ones, Gene Ontology (GO), Kyoto Encyclopedia of Genes and Genomes (KEGG), WikiPathways, Reactome, Human Phenotype Ontology (HPO) put modules into a broader systemic perspective.

In oppositions, databases references like TRANSFAC, miRTarBase, Human Protein Atlas (HPA), and CORUM give more details about tissue/cell/condition information.

Using the over-representation analysis (ORA) tool GOSt from g:Profiler, we can retrieve the biological association for each module and plot it as follows.

enrichment <- bio_enrich(detection$modules)
plot_enrichment(enrichment)

2.6.2 Phenotypic association

If phenotypic information is available about the samples provided, an association test can help to determine if a module is specifically linked to a trait. In this case, module 1 seems to be strongly linked to Age.

# With data.frame/matrix
phenotype_association <- associate_phenotype(
  detection$modules_eigengenes, 
  kuehne_traits %>% dplyr::select(Condition, Age, Slide))

# With SummarizedExperiment
phenotype_association <- associate_phenotype(
  detection$modules_eigengenes, 
  SummarizedExperiment::colData(se_kuehne) %>% 
    as.data.frame %>% 
    dplyr::select(Condition, Age, Slide))

plot_modules_phenotype(phenotype_association)

Combination of phenotypic information with the previous functional enrichment can guide further analysis.

2.7 Graph visualization and topological analysis

Information can be retrieved from the network topology itself. For example, hub genes are highly connected genes known to be associated with key biological functions. They can be detected by different methods :

  • get_hub_high_co: Highest connectivity, select the top n (n depending on parameter given) highest connected genes. Similar to WGCNA’s selection of hub genes
  • get_hub_degree: Superior degree, select genes whose degree is greater than the average connection degree of the network. Definition from network theory.
  • get_hub_kleinberg: Kleinberg’s score, select genes whose Kleinberg’s score is superior to the provided threshold.

Manipulation of graph objects can be quite demanding in memory and CPU usage. Caution is advised when choosing to plot networks larger than 100 genes. Since co-expression networks are complete graphs, readability is hard because all genes are connected with each other. In order to clarity visualization, edges with a similarity score below a threshold are removed.

#>            [,1]     [,2]
#>   [1,] 64.93902 166.1786
#>   [2,] 51.89563 158.6452
#>   [3,] 56.15871 144.6700
#>   [4,] 54.50006 144.3802
#>   [5,] 71.33309 162.7455
#>   [6,] 50.48000 154.8553
#>   [7,] 78.55236 156.2020
#>   [8,] 74.62805 144.6701
#>   [9,] 72.55530 163.9306
#>  [10,] 59.09876 143.9132
#>  [11,] 69.84981 148.2477
#>  [12,] 50.33439 151.4554
#>  [13,] 56.97984 157.5495
#>  [14,] 57.40410 139.8066
#>  [15,] 78.96111 154.6752
#>  [16,] 63.36816 155.8594
#>  [17,] 66.82104 148.3488
#>  [18,] 72.92365 165.6493
#>  [19,] 73.44661 141.2547
#>  [20,] 57.73210 143.4494
#>  [21,] 67.42677 151.9388
#>  [22,] 75.18055 152.0439
#>  [23,] 55.62877 143.2934
#>  [24,] 74.10699 138.2667
#>  [25,] 64.40781 164.0160
#>  [26,] 72.20885 168.6235
#>  [27,] 56.34738 159.2094
#>  [28,] 77.22663 139.9328
#>  [29,] 82.00371 152.5920
#>  [30,] 74.07416 166.5631
#>  [31,] 58.71500 141.2196
#>  [32,] 60.20620 144.0794
#>  [33,] 81.05098 159.5339
#>  [34,] 58.54793 166.8625
#>  [35,] 57.40961 164.2250
#>  [36,] 71.12299 138.8203
#>  [37,] 75.03239 161.4448
#>  [38,] 84.12328 155.6279
#>  [39,] 50.79545 149.2566
#>  [40,] 69.39562 152.4050
#>  [41,] 51.17671 156.0845
#>  [42,] 77.93697 161.8454
#>  [43,] 80.35234 153.5779
#>  [44,] 72.91126 156.9561
#>  [45,] 60.36736 136.9255
#>  [46,] 73.30362 136.6524
#>  [47,] 72.12158 147.7447
#>  [48,] 62.34897 164.8242
#>  [49,] 75.52938 164.3282
#>  [50,] 63.68215 165.5216
#>  [51,] 55.15200 143.2754
#>  [52,] 78.27295 163.5671
#>  [53,] 66.79085 138.0816
#>  [54,] 60.84754 165.0324
#>  [55,] 65.90326 160.3317
#>  [56,] 74.90430 158.5379
#>  [57,] 60.03141 139.8621
#>  [58,] 57.10083 143.3853
#>  [59,] 76.88362 141.1368
#>  [60,] 60.00346 147.1507
#>  [61,] 58.16852 160.3066
#>  [62,] 76.61808 157.5179
#>  [63,] 55.52599 156.9377
#>  [64,] 76.57370 166.4500
#>  [65,] 61.72399 152.7214
#>  [66,] 64.29729 169.0336
#>  [67,] 70.32974 169.0901
#>  [68,] 53.34880 159.1680
#>  [69,] 52.91945 144.2305
#>  [70,] 65.84155 151.8360
#>  [71,] 81.66129 156.1208
#>  [72,] 76.87859 147.0275
#>  [73,] 66.08234 135.4480
#>  [74,] 61.27756 143.2088
#>  [75,] 55.36100 152.7668
#>  [76,] 50.47246 153.1389
#>  [77,] 64.33252 162.1077
#>  [78,] 52.58766 157.0894
#>  [79,] 62.72155 151.1497
#>  [80,] 77.52534 151.5528
#>  [81,] 81.13469 162.2754
#>  [82,] 54.52561 151.1116
#>  [83,] 81.35667 144.7422
#>  [84,] 66.52136 141.6108
#>  [85,] 71.87786 141.3869
#>  [86,] 60.25293 141.7100
#>  [87,] 58.61497 145.8213
#>  [88,] 54.74663 154.8455
#>  [89,] 79.04895 139.8200
#>  [90,] 61.08001 142.5781
#>  [91,] 72.14353 167.1687
#>  [92,] 67.41640 160.3488
#>  [93,] 67.58037 146.4403
#>  [94,] 55.80308 144.2394
#>  [95,] 56.00242 154.1730
#>  [96,] 76.49034 159.2170
#>  [97,] 80.95390 151.7406
#>  [98,] 54.40259 145.9096
#>  [99,] 74.34132 148.1018
#> [100,] 56.17950 151.4908
#> [101,] 57.87638 158.8549
#> [102,] 53.00286 150.4973
#> [103,] 77.58418 148.1467
#> [104,] 58.48630 157.1036
#> [105,] 58.09065 140.0903
#> [106,] 71.70308 137.3386
#> [107,] 79.37071 160.7044
#> [108,] 77.13421 143.3221
#> [109,] 67.24903 162.1278
#> [110,] 67.23763 168.9715
#> [111,] 78.38961 144.3978
#> [112,] 60.40958 146.5654
#> [113,] 67.24474 155.4866
#> [114,] 73.13133 158.5598
#> [115,] 61.06292 151.0504
#> [116,] 84.44134 153.6498
#> [117,] 69.68852 163.5521
#> [118,] 82.13474 143.6919
#> [119,] 72.62863 138.4141
#> [120,] 72.01597 150.6681
#> [121,] 70.95705 164.4404
#> [122,] 59.47532 139.9889
#> [123,] 80.66561 146.1864
#> [124,] 83.52589 146.7732
#> [125,] 67.85330 165.6077
#> [126,] 58.75604 141.9399
#> [127,] 82.28504 160.6167
#> [128,] 59.31454 147.2878
#> [129,] 58.01427 162.9641
#> [130,] 79.62311 142.0087
#> [131,] 75.64133 150.5535
#> [132,] 57.24036 152.9538
#> [133,] 59.34214 142.3258
#> [134,] 76.55935 152.8715
#> [135,] 77.11346 149.8240
#> [136,] 81.82180 148.8443
#> [137,] 66.96539 158.0785
#> [138,] 52.69745 155.5865
#> [139,] 82.04815 146.5449
#> [140,] 54.58358 163.5947
#> [141,] 80.92819 158.1426
#> [142,] 54.99227 147.6847
#> [143,] 65.39633 137.9524
#> [144,] 65.79494 146.7428
#> [145,] 76.71328 154.6311
#> [146,] 53.83552 157.7488
#> [147,] 83.58042 157.7400
#> [148,] 69.10737 146.4844
#> [149,] 59.66667 163.0124
#> [150,] 69.62495 138.5447
#> [151,] 65.39204 167.7693
#> [152,] 69.94973 158.1177
#> [153,] 70.69676 153.8155
#> [154,] 75.37710 165.7461
#> [155,] 54.91024 142.8318
#> [156,] 51.38569 150.7983
#> [157,] 56.17761 145.7372
#> [158,] 54.96391 141.5489
#> [159,] 59.54622 158.8460
#> [160,] 71.23072 156.9586
#> [161,] 71.48317 144.8201
#> [162,] 58.19187 151.6438
#> [163,] 71.48033 165.7770
#> [164,] 62.57597 154.3320
#> [165,] 80.85500 160.9698
#> [166,] 53.30519 154.2504
#> [167,] 60.44774 145.2681
#> [168,] 70.08189 166.4603
#> [169,] 59.22234 138.9764
#> [170,] 73.03218 144.5415
#> [171,] 75.64738 148.8951
#> [172,] 53.25695 160.8177
#> [173,] 70.62720 146.2987
#> [174,] 61.49499 158.7526
#> [175,] 61.37759 140.8654
#> [176,] 57.02282 165.8527
#> [177,] 75.96532 137.5310
#> [178,] 82.87791 145.2390
#> [179,] 77.73862 165.5647
#> [180,] 71.21496 140.1783
#> [181,] 59.98095 167.6746
#> [182,] 75.29636 162.8821
#> [183,] 62.99344 163.2588
#> [184,] 61.15703 140.0269
#> [185,] 74.73830 142.3637
#> [186,] 74.05277 164.6209
#> [187,] 70.05047 150.6601
#> [188,] 76.31118 138.8148
#> [189,] 79.33623 152.4823
#> [190,] 69.93245 142.5238
#> [191,] 84.47383 151.3275
#> [192,] 69.64077 135.3876
#> [193,] 64.47106 160.0010
#> [194,] 75.89510 144.0760
#> [195,] 76.81038 162.8134
#> [196,] 54.21905 156.2077
#> [197,] 56.68744 140.7979
#> [198,] 55.05456 158.6366
#> [199,] 55.88340 164.7995
#> [200,] 67.49111 139.5370
#> [201,] 82.89872 148.0234
#> [202,] 69.83141 141.0601
#> [203,] 73.47516 143.0843
#> [204,] 71.19201 149.1004
#> [205,] 58.89648 143.2845
#> [206,] 53.39028 162.2194
#> [207,] 66.80293 143.4810
#> [208,] 66.38821 144.9622
#> [209,] 70.77445 167.8023
#> [210,] 57.79590 154.8298
#> [211,] 78.63744 149.3010
#> [212,] 65.96890 153.7485
#> [213,] 68.33862 158.8658
#> [214,] 51.75603 154.2832
#> [215,] 70.15795 161.6527
#> [216,] 72.71974 161.8221
#> [217,] 60.19688 157.3330
#> [218,] 80.75170 154.9868
#> [219,] 79.34245 162.2450
#> [220,] 73.56743 167.9855
#> [221,] 75.14762 154.6394
#> [222,] 79.30657 159.2413
#> [223,] 70.64669 155.4832
#> [224,] 63.85868 167.4697
#> [225,] 60.17214 160.2959
#> [226,] 82.19357 157.6861
#> [227,] 60.97593 144.6474
#> [228,] 78.41716 142.7198
#> [229,] 68.34755 143.0702
#> [230,] 58.35040 165.4408
#> [231,] 66.14234 139.9620
#> [232,] 55.98701 160.6965
#> [233,] 82.00286 154.0826
#> [234,] 59.89522 166.1190
#> [235,] 72.15854 135.8097
#> [236,] 69.34054 165.2396
#> [237,] 73.76776 162.8202
#> [238,] 58.30057 147.0554
#> [239,] 58.21810 140.6071
#> [240,] 60.92508 145.9945
#> [241,] 82.99469 156.2414
#> [242,] 61.44173 138.5913
#> [243,] 59.28701 164.3873
#> [244,] 77.11831 145.4135
#> [245,] 67.98948 153.6886
#> [246,] 62.41535 137.8345
#> [247,] 59.66774 145.7172
#> [248,] 77.89041 160.1295
#> [249,] 62.67656 141.2198
#> [250,] 79.00070 151.0271
#> [251,] 75.15305 167.3926
#> [252,] 57.43620 145.6305
#> [253,] 57.79730 161.5240
#> [254,] 71.51477 160.5846
#> [255,] 58.76753 147.7232
#> [256,] 65.65177 162.5014
#> [257,] 53.86622 152.9197
#> [258,] 77.74607 138.5365
#> [259,] 54.75715 144.9051
#> [260,] 68.22026 163.9382
#> [261,] 68.01481 141.3343
#> [262,] 66.84574 167.5822
#> [263,] 64.96473 155.1411
#> [264,] 65.83689 169.1996
#> [265,] 68.64118 156.8998
#> [266,] 57.91565 142.7429
#> [267,] 64.94225 148.3983
#> [268,] 65.96663 156.5630
#> [269,] 72.46995 154.8746
#> [270,] 74.74229 160.0889
#> [271,] 66.45570 136.6254
#> [272,] 73.80132 150.9912
#> [273,] 65.34797 158.3121
#> [274,] 56.62656 155.8145
#> [275,] 82.72726 159.1559
#> [276,] 76.99228 156.0469
#> [277,] 84.14767 148.7196
#> [278,] 63.94302 157.4900
#> [279,] 79.50378 157.7321
#> [280,] 80.07500 143.4747
#> [281,] 61.57965 144.5560
#> [282,] 69.20489 168.0171
#> [283,] 62.79145 168.4762
#> [284,] 68.99124 155.1032
#> [285,] 79.12372 164.7012
#> [286,] 56.90688 142.6603
#> [287,] 61.46453 168.1719
#> [288,] 74.20573 153.3935
#> [289,] 68.34411 148.7523
#> [290,] 51.71095 152.6957
#> [291,] 79.25837 147.4025
#> [292,] 61.32053 166.6673
#> [293,] 56.90057 141.8222
#> [294,] 78.00389 153.5313
#> [295,] 74.03539 155.7473
#> [296,] 61.17152 155.7283
#> [297,] 68.27140 150.4718
#> [298,] 62.68224 144.3123
#> [299,] 53.71824 143.6286
#> [300,] 76.98163 164.4328
#> [301,] 56.14841 139.9810
#> [302,] 80.01094 149.0839
#> [303,] 57.84087 147.5896
#> [304,] 52.07513 149.3818
#> [305,] 56.00941 163.4757
#> [306,] 54.34595 147.2747
#> [307,] 61.57479 162.0914
#> [308,] 62.49534 140.4439
#> [309,] 57.25797 146.9913
#> [310,] 57.77242 141.7184
#> [311,] 68.67296 161.7310
#> [312,] 71.37836 152.2550
#> [313,] 65.79020 164.7426
#> [314,] 69.61944 160.0444
#> [315,] 55.71170 147.9666
#> [316,] 58.49785 145.0286
#> [317,] 75.66853 146.3147
#> [318,] 72.63231 146.3147
#> [319,] 80.11676 156.3894
#> [320,] 65.94062 149.9956
#> [321,] 70.24050 144.0630
#> [322,] 58.97830 153.7620
#> [323,] 59.71027 152.2395
#> [324,] 78.39885 141.0243
#> [325,] 66.80485 163.6780
#> [326,] 80.84589 147.7852
#> [327,] 83.30521 154.5057
#> [328,] 83.70957 149.9354
#> [329,] 75.06760 156.9520
#> [330,] 59.00550 138.4784
#> [331,] 60.60937 154.1797
#> [332,] 68.49631 136.3253
#> [333,] 82.19307 150.2303
#> [334,] 78.00374 158.2074
#> [335,] 80.01177 163.4383
#> [336,] 57.55508 144.4936
#> [337,] 59.20974 155.6498
#> [338,] 81.23020 142.4983
#> [339,] 75.08351 139.3639
#> [340,] 74.66073 136.9604
#> [341,] 51.10901 157.5165
#> [342,] 64.79887 136.2484
#> [343,] 61.23336 163.5160
#> [344,] 60.53145 137.8261
#> [345,] 72.83965 152.9443
#> [346,] 60.60464 139.0549
#> [347,] 62.04489 157.1534
#> [348,] 83.07187 151.3382
#> [349,] 63.74961 149.6634
#> [350,] 78.70653 146.1117
#> [351,] 64.24805 151.5976
#> [352,] 52.09622 160.1432
#> [353,] 52.82547 151.9831
#> [354,] 61.72459 160.5741
#> [355,] 68.33169 167.0609
#> [356,] 59.26562 141.5962
#> [357,] 80.41328 141.0490
#> [358,] 62.63549 166.6091
#> [359,] 53.85012 145.5095
#> [360,] 71.36614 158.9281
#> [361,] 60.52183 142.9952
#> [362,] 73.29787 149.3390
#> [363,] 76.16092 142.2122
#> [364,] 79.78726 144.9149
#> [365,] 71.73036 142.8382
#> [366,] 83.52705 152.7038
#> [367,] 68.15155 137.7244
#> [368,] 80.64089 150.3696
#> [369,] 63.10026 159.1062
#> [370,] 68.93547 139.7583
#> [371,] 56.45767 162.0855
#> [372,] 67.70074 135.3156
#> [373,] 54.59967 160.2977
#> [374,] 74.95126 140.6767
#> [375,] 62.64617 141.9863
#> [376,] 69.83528 137.1530
#> [377,] 59.66277 161.6216
#> [378,] 68.55830 144.8457
#> [379,] 73.13990 160.2426
#> [380,] 76.59818 160.9990
#> [381,] 63.97364 153.3895
#> [382,] 70.87304 136.1822
#> [383,] 73.18447 139.7576
#> [384,] 74.20100 146.5143
#> [385,] 63.18572 161.1389
#> [386,] 54.78846 162.0227
#> [387,] 66.51306 166.1525
#> [388,] 68.56552 169.2875

2.8 Networks comparison

A co-expression network can be built for each of the experimental conditions studied (e.g. control/test) and then be compared with each other to detect differences of patterns in co-expression. These may indicate breaks of inhibition, inefficiency of a factor of transcription, etc. These analyses can focus on preserved modules between conditions (e.g. to detect housekeeping genes), or unpreserved modules (e.g. to detect genes contributing to a disease).

GWENA uses a comparison test based on random re-assignment of gene names inside modules to see whether patterns inside modules change (from NetRep package). This permutation test is repeated a large number of times to evaluate the significance of the result obtained.

To perform the comparison, all previous steps leading to modules detection need to be done for each condition. To save CPU, memory and time, the parameter keep_cor_mat from the build_net function can be switched to TRUE so the similarity matrix is kept and can be passed to compare_conditions. If not, the matrix is re-computed in compare_conditions.

# Expression by condition with data.frame/matrix
samples_by_cond <- lapply(kuehne_traits$Condition %>% unique, function(cond){
  df <- kuehne_traits %>% 
    dplyr::filter(Condition == cond) %>%
    dplyr::select(Slide, Exp)
  apply(df, 1, paste, collapse = "_")
}) %>% setNames(kuehne_traits$Condition %>% unique)

expr_by_cond <- lapply(samples_by_cond %>% names, function(cond){
  samples <- samples_by_cond[[cond]]
  kuehne_expr_filtered[which(rownames(kuehne_expr_filtered) %in% samples),]
}) %>% setNames(samples_by_cond %>% names)


# Expression by condition with SummarizedExperiment
se_expr_by_cond <- lapply(unique(se_kuehne$Condition), function(cond){
     se_kuehne[, se_kuehne$Condition == cond]
}) %>% setNames(unique(se_kuehne$Condition))


# Network building and modules detection by condition
net_by_cond <- lapply(expr_by_cond, build_net, cor_func = "spearman", 
                      n_threads = threads_to_use, keep_matrices = "both")

mod_by_cond <- mapply(detect_modules, expr_by_cond, 
                      lapply(net_by_cond, `[[`, "network"), 
                      MoreArgs = list(detailled_result = TRUE), 
                      SIMPLIFY = FALSE)


comparison <- compare_conditions(expr_by_cond, 
                                 lapply(net_by_cond, `[[`, "adja_mat"), 
                                 lapply(net_by_cond, `[[`, "cor_mat"),  
                                 lapply(mod_by_cond, `[[`, "modules"), 
                                 pvalue_th = 0.05)

The final object contains a table summarizing the comparison of the modules, directly available with the comparison$result$young$old$comparison command. The comparison take into account the permutation test result and the z summary.

(#tab:condition_comparison)Modules preservation with young as reference
comparison
preserved
preserved
inconclusive
preserved
moderately preserved
preserved

The detail of the pvalues can also be seen as a heatmap. Since all evaluation metrics of compare_conditions need to be significant to consider a module preserved/unpreserved/one of them, it could be interesting to see which metrics prevented a module to be significant.

plot_comparison_stats(comparison$result$young$old$p.values)

3 Frequently asked questions

1. How can I reduce my transcriptomic data to the gene level?

Microarray probes are not reduced to gene level the same way RNA-seq transcripts are. But in both cases, the optimal collapsing strategy depends on the analysis goal, here co-expression network analysis. * For microarray, the highest mean expression is the most robust regarding the expression correlation. You can use the collapseRows R function available in the WGCNA package which also allow to use other methods like median. * For RNA-seq, it is recommended to sum the transcripts counts for a gene

2. What is an eigengene?

A module’s eigengene is a gene (real or estimated) whose expression profile summarizes the profile of expression of the whole module. In WGCNA, it is the first component of an SVD performed on the module’s expression matrix.

3. What should I do if I get warning/error “No fitting power could be found for provided fit_cut_off” ?

You should first verify your data. This implies : * Your data are RNA-seq or microarray data * You have gene names as columns and samples as row or if you use get_fit.cor you had it when you computed your correlation matrix on it * You didn’t filtered your data in a way that breaks the scale-free property. Classic wrong filter is usign only differentially expressed genes (see question 2. from WGCNA package FAQ) If you verified these causes, you may have set a fit_cut_off too high (default is 0.9 default).

4. Why do the first modules have so many genes as the last ones have very few?

5. Why GWENA doesn’t provide normalization methods ?

GWENA is design to support both RNA-seq and microarray data. However each of these technologies have its own normalization methods, partly because of the distribution of the expression (discrete against continuous). Also microarrays normalization steps aim to remove noise like mRNA quality variability, batch effect, background effect, etc. While RNA-seq normalization steps aim to account for differences of gene length, sequencing depths, GC content, etc. but can also take into account classic noise like batch effect.

Some of this normalization methods require metadata and specific constructor package in the case of microarrays. To avoid over-complexification of the input for this pipeline and since the experimenters are in the best position to know the best normalisations to apply, we prefer to ask for already normalized methods.

6. Why forcing expression datasets to have no NA values?

As you may know in R, missing values in cor and cov function by default propagate missing values in each column and row where there are found. Multiple options are available in these function to manage missing values. However some of them are not available for all type of correlations available, and not all imputations methods are wise to use (take a look at this article: Pairwise-complete correlation considered dangerous). Since WGCNA running requires no missing values, I prefere forcing to have a complete dataset. You have therefore the full understanding of the imputation you compute for your missing values. If you have no idea how to do it, see Dealing with missing data: Key assumptions and methods for applied analysis for general information about missing values imputation, and Dealing with missing values in large-scale studies: microarray data imputation and beyond for more transcriptomic-specific imputation.

7. Why did you wrapped multiple functions of WGCNA like pickSoftThreshold or adjacency ? Wasn’t they already working?

Short answer is “Yes they were”. However, the parameters of these functions and their syntax didn’t eased tehir use. Moreover, the current succession of functions to built modules repeated multiple times the correlation computation which takes quite some time. Also, I took the opportunity to integrate native sperman correlation.

8. Why didn’t you use S3 class to create objects usable by your functions ?

GWENA architecture is designed to be modular, meaning each step method is easily exchangeable for another method (i.e. changing the detection step which is a hierarchical cultering to a kmeans) as long as the input and output format are the same. Also using native data types ensure the ease of compatibility with other tools (i.e. using cytoscape for the visualization step instead of the GWENA’s one).

9. Why the arg network_type = "signed" implies a modification of the similarity score even though it is already signed?

Since a correlation matrix is already signed, one could as what is this similarity <- (1 + cor_mat) / 2 operation. It is simply because ulterior steps of estimating a scale-free index in WGCNA implies a log10 transformation. Therefore you can’t have negative numbers. Because a correlation matrix have values in [0;1], the operation will keep the distribution and avoid negative values.

10. Why plot_expression_profiles() computes a PCA for eigengenes instead of using eigengenes given by detect_modules()?

Eigenenes provided by detect_modules are from a SVD, and PCA is equivalent to performing the SVD on the centered data (see ‘Running PCA and SVD in R’). Because expression profiles are using centered values (for clarity of representation), the PCA to represent eigengenes is more accurate.


If you have a question or a misunderstanding, send an email to lemoine.gwenaelle[@t)gmail{d0t]com