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,] 30.40275 172.5826
#>   [2,] 57.57317 152.1931
#>   [3,] 35.40524 150.5590
#>   [4,] 36.93541 150.1673
#>   [5,] 46.08589 149.6722
#>   [6,] 32.74059 170.4931
#>   [7,] 43.00609 176.2717
#>   [8,] 49.99122 154.4683
#>   [9,] 58.39790 164.7675
#>  [10,] 33.41493 155.8866
#>  [11,] 49.55847 173.0216
#>  [12,] 53.45322 154.1238
#>  [13,] 30.27727 170.4029
#>  [14,] 36.84982 153.2747
#>  [15,] 46.26804 146.9554
#>  [16,] 45.00570 150.6526
#>  [17,] 36.68837 176.3491
#>  [18,] 44.45892 160.9874
#>  [19,] 51.19328 161.0432
#>  [20,] 34.05469 151.7743
#>  [21,] 44.45035 170.6011
#>  [22,] 47.97421 165.4898
#>  [23,] 37.42918 151.1722
#>  [24,] 36.92780 166.7822
#>  [25,] 43.73816 146.8512
#>  [26,] 36.75276 174.9580
#>  [27,] 35.70683 172.2226
#>  [28,] 38.87670 177.9781
#>  [29,] 53.40053 175.0770
#>  [30,] 37.49618 164.0017
#>  [31,] 32.88335 152.4070
#>  [32,] 31.60078 152.9158
#>  [33,] 32.40426 173.9070
#>  [34,] 52.84233 149.7890
#>  [35,] 37.10677 168.9072
#>  [36,] 32.50549 168.4670
#>  [37,] 35.31356 175.7687
#>  [38,] 29.57219 169.0964
#>  [39,] 48.48789 148.9296
#>  [40,] 49.61880 166.2794
#>  [41,] 31.19734 173.6819
#>  [42,] 52.40374 170.2524
#>  [43,] 55.42305 161.9775
#>  [44,] 56.63948 153.5778
#>  [45,] 39.56824 152.2740
#>  [46,] 49.82063 148.0916
#>  [47,] 50.22110 167.8887
#>  [48,] 42.75856 152.6898
#>  [49,] 35.86057 170.1742
#>  [50,] 59.58731 161.9229
#>  [51,] 32.47338 154.0280
#>  [52,] 48.43419 154.7860
#>  [53,] 53.05792 176.3693
#>  [54,] 46.98884 155.4541
#>  [55,] 32.55329 172.2628
#>  [56,] 57.31560 155.9752
#>  [57,] 37.77791 150.4657
#>  [58,] 32.45440 156.0166
#>  [59,] 49.28141 161.5950
#>  [60,] 32.98225 148.8965
#>  [61,] 29.32686 167.6523
#>  [62,] 49.30635 169.2431
#>  [63,] 47.68769 157.0981
#>  [64,] 31.46186 161.6438
#>  [65,] 28.62739 163.9140
#>  [66,] 39.97371 178.8232
#>  [67,] 41.09630 178.0581
#>  [68,] 51.81223 166.8942
#>  [69,] 30.23687 155.4284
#>  [70,] 53.09761 165.3545
#>  [71,] 40.41950 145.8841
#>  [72,] 54.97281 164.4936
#>  [73,] 43.20772 171.4838
#>  [74,] 33.26683 157.1004
#>  [75,] 43.42780 159.4421
#>  [76,] 54.46095 172.4800
#>  [77,] 46.72364 151.2611
#>  [78,] 38.14416 170.1401
#>  [79,] 38.97503 166.8247
#>  [80,] 27.78794 162.5535
#>  [81,] 56.89668 161.9259
#>  [82,] 35.84363 165.1985
#>  [83,] 38.14374 176.4232
#>  [84,] 44.71990 165.5089
#>  [85,] 47.73084 163.4650
#>  [86,] 34.87485 155.9479
#>  [87,] 31.58091 157.4956
#>  [88,] 50.75048 174.6158
#>  [89,] 32.63618 175.3310
#>  [90,] 34.23316 157.5339
#>  [91,] 47.44604 161.7430
#>  [92,] 50.26566 176.3845
#>  [93,] 45.40599 174.5396
#>  [94,] 36.35799 151.7786
#>  [95,] 27.05355 159.7817
#>  [96,] 58.27031 161.8501
#>  [97,] 42.04474 149.7285
#>  [98,] 37.44028 149.1499
#>  [99,] 54.54756 160.0686
#> [100,] 58.17618 170.9716
#> [101,] 33.95257 174.8725
#> [102,] 51.61998 177.1832
#> [103,] 44.02679 151.9319
#> [104,] 36.47272 162.9432
#> [105,] 35.20180 153.0051
#> [106,] 37.65751 161.5856
#> [107,] 26.84352 161.3509
#> [108,] 42.84741 156.1926
#> [109,] 40.59805 172.4379
#> [110,] 50.65611 151.2437
#> [111,] 52.74048 157.0961
#> [112,] 34.99241 148.1275
#> [113,] 56.89330 171.0787
#> [114,] 46.44963 165.9494
#> [115,] 60.81173 161.4935
#> [116,] 33.81768 173.3092
#> [117,] 42.41295 165.6722
#> [118,] 51.30976 149.8950
#> [119,] 38.79233 171.9605
#> [120,] 27.97983 168.6168
#> [121,] 59.56692 160.4280
#> [122,] 36.06384 153.6672
#> [123,] 46.42951 160.2711
#> [124,] 53.35250 150.9893
#> [125,] 48.76741 153.0017
#> [126,] 34.82238 154.5753
#> [127,] 44.94256 176.4544
#> [128,] 32.37843 149.3080
#> [129,] 48.30112 167.4939
#> [130,] 34.23701 169.1543
#> [131,] 50.05809 177.9579
#> [132,] 44.43216 145.1499
#> [133,] 35.48272 151.0354
#> [134,] 56.44661 150.7476
#> [135,] 48.09246 170.3659
#> [136,] 57.79082 160.2553
#> [137,] 42.96994 169.3457
#> [138,] 44.09635 167.0213
#> [139,] 52.64520 172.3576
#> [140,] 45.93423 171.5232
#> [141,] 55.83814 173.9639
#> [142,] 38.87643 155.9073
#> [143,] 46.36054 173.1221
#> [144,] 41.11946 175.1319
#> [145,] 49.48260 171.3593
#> [146,] 51.20188 148.4577
#> [147,] 59.75235 156.4806
#> [148,] 39.60949 175.4949
#> [149,] 58.98454 159.1563
#> [150,] 29.35615 165.5763
#> [151,] 55.13804 154.1610
#> [152,] 37.05416 171.3596
#> [153,] 58.85440 169.6620
#> [154,] 47.88124 175.5684
#> [155,] 36.43727 153.8240
#> [156,] 56.21362 157.0836
#> [157,] 36.66791 155.4389
#> [158,] 38.03559 151.6471
#> [159,] 46.44811 145.4122
#> [160,] 53.66492 171.1455
#> [161,] 56.14761 160.3958
#> [162,] 51.01512 173.0499
#> [163,] 42.76214 177.6189
#> [164,] 49.30380 174.9036
#> [165,] 54.25003 148.9230
#> [166,] 27.71897 158.4565
#> [167,] 32.15989 157.9100
#> [168,] 36.64732 173.3038
#> [169,] 30.52133 152.6880
#> [170,] 31.44819 171.5044
#> [171,] 31.85298 165.2346
#> [172,] 38.11303 173.1896
#> [173,] 39.58115 164.2966
#> [174,] 44.50626 154.0252
#> [175,] 30.77642 154.8338
#> [176,] 52.00615 151.8490
#> [177,] 53.63398 158.6628
#> [178,] 44.53150 177.6928
#> [179,] 56.80749 166.9172
#> [180,] 48.85709 160.1021
#> [181,] 53.98004 173.7072
#> [182,] 49.22309 158.1977
#> [183,] 41.59083 173.5644
#> [184,] 36.18053 155.7392
#> [185,] 47.28987 178.7303
#> [186,] 43.94970 162.7671
#> [187,] 44.70765 168.7914
#> [188,] 54.63690 167.7499
#> [189,] 32.05433 166.8698
#> [190,] 47.33137 168.7044
#> [191,] 50.74693 156.9002
#> [192,] 35.14665 166.6513
#> [193,] 51.56546 163.9747
#> [194,] 46.14707 154.2157
#> [195,] 54.76880 152.6625
#> [196,] 55.15631 166.0221
#> [197,] 33.26353 151.7960
#> [198,] 53.34180 163.9056
#> [199,] 44.15209 175.1032
#> [200,] 45.18023 158.9834
#> [201,] 50.11547 162.8688
#> [202,] 41.80841 145.8426
#> [203,] 30.55282 166.4575
#> [204,] 50.55913 159.4234
#> [205,] 32.51602 152.1551
#> [206,] 53.03914 155.6035
#> [207,] 44.71467 148.0210
#> [208,] 50.87085 146.8632
#> [209,] 31.83120 163.2860
#> [210,] 46.04447 167.5641
#> [211,] 27.13026 166.8446
#> [212,] 42.79900 174.6902
#> [213,] 28.23955 160.5235
#> [214,] 41.90456 157.6476
#> [215,] 51.80567 153.6703
#> [216,] 48.73319 146.9530
#> [217,] 31.51217 169.6049
#> [218,] 49.33827 164.3581
#> [219,] 57.72800 154.5612
#> [220,] 51.79639 168.5832
#> [221,] 45.78381 162.3262
#> [222,] 28.94187 162.0890
#> [223,] 53.34847 168.7278
#> [224,] 48.65155 178.1782
#> [225,] 52.32190 147.2994
#> [226,] 53.53408 161.2918
#> [227,] 31.51105 154.9955
#> [228,] 40.51700 165.6772
#> [229,] 49.60241 146.0107
#> [230,] 40.82923 162.3068
#> [231,] 48.84618 176.6463
#> [232,] 41.81384 159.2252
#> [233,] 50.44478 152.8684
#> [234,] 43.00756 154.5931
#> [235,] 38.26070 174.7819
#> [236,] 44.72450 172.8375
#> [237,] 57.79797 163.4673
#> [238,] 34.45558 148.9467
#> [239,] 35.67109 154.8840
#> [240,] 35.43087 148.6609
#> [241,] 45.99611 178.4084
#> [242,] 38.18413 154.5455
#> [243,] 44.16573 157.4782
#> [244,] 40.69414 147.2835
#> [245,] 56.29948 163.6968
#> [246,] 36.00463 149.7254
#> [247,] 32.86858 158.2744
#> [248,] 50.71977 169.9946
#> [249,] 34.87000 158.3715
#> [250,] 57.42233 169.2649
#> [251,] 53.29174 152.5917
#> [252,] 35.33291 156.6961
#> [253,] 43.00538 145.3505
#> [254,] 58.23584 158.0413
#> [255,] 34.19969 148.1235
#> [256,] 51.73261 175.6489
#> [257,] 47.59159 147.6453
#> [258,] 57.03297 158.7632
#> [259,] 37.49713 153.7252
#> [260,] 46.05668 157.2863
#> [261,] 49.28878 156.3044
#> [262,] 29.47172 171.5415
#> [263,] 47.68006 171.8528
#> [264,] 46.30930 176.2360
#> [265,] 55.83688 172.5206
#> [266,] 33.56163 153.2632
#> [267,] 34.93650 163.9058
#> [268,] 52.96592 148.3706
#> [269,] 34.29574 170.6078
#> [270,] 46.34472 148.4455
#> [271,] 30.39334 164.5451
#> [272,] 35.38653 161.8437
#> [273,] 33.61615 165.9856
#> [274,] 35.78343 168.2493
#> [275,] 49.66883 149.7907
#> [276,] 45.12204 146.2275
#> [277,] 59.44915 168.3146
#> [278,] 47.25692 177.2460
#> [279,] 33.14198 161.7043
#> [280,] 42.58695 161.5811
#> [281,] 31.23052 156.8652
#> [282,] 39.32403 160.4502
#> [283,] 41.98724 179.0951
#> [284,] 58.35072 156.7515
#> [285,] 44.89404 155.7448
#> [286,] 35.42502 152.6156
#> [287,] 55.61921 158.7298
#> [288,] 58.41598 153.4414
#> [289,] 42.09740 148.4164
#> [290,] 35.24926 174.0412
#> [291,] 48.97053 151.3719
#> [292,] 40.95801 160.5436
#> [293,] 34.09379 154.7342
#> [294,] 36.06954 177.4727
#> [295,] 48.20466 173.4562
#> [296,] 41.38393 176.5351
#> [297,] 60.10255 157.9835
#> [298,] 29.52287 153.7788
#> [299,] 38.02828 152.6354
#> [300,] 33.82375 167.6813
#> [301,] 31.80856 152.0859
#> [302,] 45.53891 152.4936
#> [303,] 31.88799 149.9516
#> [304,] 41.37883 169.8273
#> [305,] 28.53589 170.0938
#> [306,] 37.91353 157.2536
#> [307,] 54.59924 157.5202
#> [308,] 36.32194 157.6882
#> [309,] 33.54535 148.4606
#> [310,] 33.91488 152.8979
#> [311,] 47.77433 145.8021
#> [312,] 58.08862 166.3523
#> [313,] 56.07377 152.1882
#> [314,] 53.50218 166.8008
#> [315,] 38.39296 156.5657
#> [316,] 33.84605 150.3990
#> [317,] 33.52947 163.0209
#> [318,] 52.47219 159.8879
#> [319,] 40.21652 168.7352
#> [320,] 54.80804 175.0469
#> [321,] 57.19479 172.5703
#> [322,] 30.13606 163.1221
#> [323,] 42.57638 167.7430
#> [324,] 59.99202 167.0109
#> [325,] 44.87933 179.1599
#> [326,] 51.40869 155.3335
#> [327,] 38.05684 165.4168
#> [328,] 26.79507 164.7617
#> [329,] 43.18795 150.5804
#> [330,] 37.40302 152.2665
#> [331,] 46.24065 169.9072
#> [332,] 39.74467 173.7974
#> [333,] 43.18537 173.1027
#> [334,] 46.98985 174.5121
#> [335,] 47.81618 150.2573
#> [336,] 32.56883 151.1857
#> [337,] 41.05088 167.2498
#> [338,] 56.69941 165.2129
#> [339,] 43.91261 149.1263
#> [340,] 46.01560 164.1158
#> [341,] 58.13035 167.9190
#> [342,] 43.45229 164.2881
#> [343,] 28.33506 166.7910
#> [344,] 38.80105 153.3731
#> [345,] 51.03559 165.4210
#> [346,] 34.96919 151.6774
#> [347,] 60.56041 159.3900
#> [348,] 55.29644 149.7111
#> [349,] 60.46373 164.9180
#> [350,] 30.06466 161.2754
#> [351,] 47.35320 152.7969
#> [352,] 54.42841 169.7408
#> [353,] 39.74879 170.6434
#> [354,] 52.08781 162.3533
#> [355,] 55.46688 170.9164
#> [356,] 33.11956 154.1105
#> [357,] 51.21511 171.5180
#> [358,] 54.56670 155.8695
#> [359,] 36.87765 148.7778
#> [360,] 56.01923 169.4528
#> [361,] 33.89218 157.0742
#> [362,] 59.44991 165.7934
#> [363,] 38.60612 168.3663
#> [364,] 29.36520 159.9545
#> [365,] 59.09564 155.2180
#> [366,] 30.86144 168.1189
#> [367,] 41.56049 163.7858
#> [368,] 42.42070 147.1864
#> [369,] 37.61597 178.1104
#> [370,] 34.20992 176.4129
#> [371,] 43.43489 178.9137
#> [372,] 52.33506 173.9538
#> [373,] 47.42181 158.9319
#> [374,] 54.30361 162.7746
#> [375,] 35.67615 158.1299
#> [376,] 56.02536 167.9801
#> [377,] 27.91274 165.2305
#> [378,] 54.80708 151.0365
#> [379,] 39.09366 162.5596
#> [380,] 51.67858 158.2327
#> [381,] 59.39457 163.5950
#> [382,] 60.71296 163.3165
#> [383,] 41.71973 171.3515
#> [384,] 26.78105 163.2560
#> [385,] 39.83049 176.9152
#> [386,] 33.23644 164.5125
#> [387,] 55.99063 155.4204
#> [388,] 34.19644 171.9524

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