Chapter 7 WGCNA RNA-seq Blog

7.1 Introduction to the WGCNA Rpackage

7.1.1 WGCNA Rpackage Installation procedure.

Installing and re-installing new versions or R and Studio.
In Terminal (or Rstudio > Terminal).

brew reinstall --cask r
brew reinstall --cask rstudio

Installing WGCNA: and R package for weighted correlation network analysis.

To install the package, go to Tab: Packages > Install …[]… -Repository: (CRAN); -Packages: WGCNA; *Install. In R code:

install.packages("WGCNA")

Installation (Failed).
Unfortunately, it could not install correctly. Error was:

install.packages("WGCNA")
Warning in install.packages :
dependencies ‘Biobase’, ‘impute’, ‘preprocessCore’, ‘GO.db’, ‘AnnotationDbi’ are not available
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘WGCNA’
Do you want to attempt to install these from sources? (Yes/no/cancel) y
Warning in install.packages :
installation of package ‘WGCNA’ had non-zero exit status

Dependencies are old and require special installation.

  1. From this page, installed several packages. (Failed).
install.packages(c("dynamicTreeCut", "cluster", "flashClust", "Hmisc", "reshape", "foreach", "doParallel") ) 
source("http://bioconductor.org/biocLite.R") 
biocLite("impute")
install.packages("WGCNA")

Install most of the packages, but not “impute,” result: could not install WGCNA.

  1. Tried to install dependencies independently from here: (Failed)
You're using R-3.6.0, but trying to install Bioconductor version 3.8. Try using BiocManager::install("Biobase"). If that works, then try BiocManager::install("GO.db").
If you have success, make sure your installation is valid with BiocManager::valid().
BiocManager::install("Biobase")
BiocManager::install("GO.db")
BiocManager::valid()
No resutl
  1. Decided to install the complete “BiocManager” pack. ** BiocManager: (OK); (WGCNA:(Failed)**
> install.packages("BiocManager") 
 downloaded 315 KB
> install.packages("WGCNA")
 Warning in install.packages : dependencies ‘impute’, ‘preprocessCore’ are not available
  1. Search ‘preprocessCore,’ in this page. PreprocessCore:(OK); (WGCNA:(Failed)
    To install this package, start R (version “4.1”) and enter:
if (!requireNamespace("BiocManager", quietly = TRUE))
 install.packages("BiocManager")
BiocManager::install("preprocessCore")
  1. For ‘impute,’ found install in this page. Impute:(OK); WGCNA:( OK)
    To install this package, start R (version “4.1”) enter:
if (!requireNamespace("BiocManager", quietly = TRUE))
 install.packages("BiocManager")
BiocManager::install("impute")
 Then install WGCNA
install.packages("WGCNA")

7.1.2 Final installation workflow:

# Set working directory
getwd()
setwd("/Users/marcelorosales/Box Sync/Documents/R/Rmarkdown")  
getwd()

# Load list of packages and install.
load("Rpackages")
for (p in setdiff(packages, installed.packages()[,"Package"]))
  install.packages(p)

Check <- installed.packages()

BiocManager::install("Biobase")
BiocManager::install("GO.db")
BiocManager::valid()
> install.packages("BiocManager")
if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

BiocManager::install("preprocessCore")
BiocManager::install("WGCNA")


install.packages(c("dynamicTreeCut", "cluster", "flashClust", "Hmisc", "reshape", "foreach", "doParallel") ) 
source("http://bioconductor.org/biocLite.R") 
biocLite("impute")

if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

BiocManager::install("impute")

install.packages("WGCNA")

Checking the packages for WGCNA installed previously for OS Catalina.

Warning in install.packages : package ‘anRichment’ is not available for this version of R

A version of this package for your version of R might be available elsewhere, see the ideas at https://cran.r-project.org/doc/manuals/r-patched/R-admin.htmlInstalling-packages

Warning in install.packages :
package ‘anRichment’ is not available for this version of R
package ‘anRichmentMethods’ is not available for this version of R
package ‘BiocFileCache’ is not available for this version of R
package ‘BiocParallel’ is not available for this version of R
package ‘biomaRt’ is not available for this version of R
package ‘DelayedArray’ is not available for this version of R
package ‘GenomicAlignments’ is not available for this version of R
package ‘GenomicFeatures’ is not available for this version of R
package ‘GenomicRanges’ is not available for this version of R
package ‘inserttable’ is not available for this version of R
package ‘lorem’ is not available for this version of R
package ‘org.Hs.eg.db’ is not available for this version of R
package ‘org.Mm.eg.db’ is not available for this version of R
package ‘Rhtslib’ is not available for this version of R
package ‘Rsamtools’ is not available for this version of R
package ‘rtracklayer’ is not available for this version of R
package ‘SummarizedExperiment’ is not available for this version of R
package ‘TxDb.Hsapiens.UCSC.hg19.knownGene’ is not available for this version of R
package ‘TxDb.Mmusculus.UCSC.mm10.knownGene’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.htmlInstalling-packages

7.1.3 WGCNA tutorial.

This code has been adapted from the tutorials available at WGCNA website (this page does no longer exist).

WGCNA: an R package for weighted correlation network analysis site.

Tutorials for the WGCNA package. R tutorial
Steps Required for this process are:
1. Data input and cleaning: PDF document, R script.
1. Network construction and module detection
a. Automatic, one-step network construction and module detection: PDF document, R script
b. Step-by-step network construction and module detection: PDF document, R script
c. Dealing with large datasets: block-wise network construction and module detection: PDF document, R script
1. Relating modules to external clinical traits and identifying important genes: PDF document, R script
1. Interfacing network analysis with other data such as functional annotation and gene ontology PDF document, R script
1. Network visualization using WGCNA functions: PDF document, R script
1. Export of networks to external software: PDF document, R script

7.1.4 3.4 Gene expression analysis

The level of gene expression is measured by read density, the higher the read density, the higher the level of gene expression.
Gene expression calculation was performed with the formula below, which calculates FPKM (Fragments per kilo bases per million reads) based on read counts from HT-seq (V 0.6.1) (Mortazavi, 2008).

The formula is:

Figure 3.4.1

The ratio of (total exon fragments / mapped reads [millions]) is the read count mapped to the gene normalized to total read counts. The value is then normalized to gene length (exon length [KB]), so that the expression of genes with different sequencing depths and length are comparable.

The numbers of genes with different expression levels are summarized in Table 3.7.1. In general, FPKM threshold for gene expression is set between 0.1-1, although there is no absolute standard and various thresholds have been used in the literature.

7.2 RNA-seq Analisys with Kaku’s Data sample.

2021/07/02
Copy Trial data from MK/土橋 to folder :
The Report file.
The Summary file

Report
### Experimental Workflow.
Transcriptome sequencing experiments include:
* RNA extraction and QC (Quality Control?),
* Library construction, * Purification,
* Library QC and
* Quantitation, as well as
* Sequencing cluster generation and high through-put sequencing.

Each step is important for data quality and quantity, which in turn affect the data analysis. To ensure the accuracy and reliability of the analysis results, every step is under strict monitoring and quality control. After mixing libraries based on their effective concentration and the required sequencing data volume, Illumina platform is used for high through-put sequencing.

7.2.1 Data Analysis.

First Data must be in the right format.
In the data received.

“GeneName”
“Chr”
“Start”
“End”
“Strand”
“Length”
“mPDL_RNA14D_Ko1”
“mPDL_RNA14D_Ko2”
“mPDL_RNA14D_Ko3”
“mPDL_RNA14D_Ko4”
“mPDL_RNA14D_WT1”
“mPDL_RNA14D_WT2”
“mPDL_RNA14D_WT3”
“mPDL_RNA14D_WT4”
“mPDL_RNA7D_Ko1”
“mPDL_RNA7D_Ko2”
“mPDL_RNA7D_Ko3”
“mPDL_RNA7D_Ko4”
“mPDL_RNA7D_WT1”
“mPDL_RNA7D_WT2”
“mPDL_RNA7D_WT3”
“mPDL_RNA7D_WT4”

Use Markdown Table generator.

20210705

Problems with software*
** Regarding Rstudio Shortcut keys “not working” sometimes**
SOME shortcuts will work if not on the corresponding file type. For example, MARKDOWN shortcuts will not work on R script files window or vice versa.

Set working directory

getwd()
setwd("/Users/marcelorosales/Box Sync/Documents/R/Rmarkdown")  "/Users/marcelorosales/Box Sync/Documents/R/Rmarkdown"
# [1] "/Users/marcelorosales/Box Sync/Niigata Uni Box/Experiments/Photoconvertible FP/Experiment Notebooks"
getwd()

Load list of packages and install.

load("Rpackages")
for (p in setdiff(packages, installed.packages()[,"Package"]))
  install.packages(p)

Check <- installed.packages()

BiocManager::install("Biobase")
BiocManager::install("GO.db")
BiocManager::valid()
> install.packages("BiocManager")
if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

BiocManager::install("preprocessCore")
BiocManager::install("WGCNA")


install.packages(c("dynamicTreeCut", "cluster", "flashClust", "Hmisc", "reshape", "foreach", "doParallel") ) 
source("http://bioconductor.org/biocLite.R") 
biocLite("impute")
install.packages("WGCNA")


source("https://horvath.genetics.ucla.edu/html/CoexpressionNetwork/GeneAnnotation/installAnRichment.R");
installAnRichment();

install.packages("path/to/anRichmentMethods", repos = NULL, type = "source"); install.packages("path/to/anRichment", repos = NULL, type = "source");


source("https://bioconductor.org/biocLite.R");
biocLite(c("AnnotationDBI", "GO.db", "org.Hs.eg.db", "org.Mm.eg.db",
  "XML", "WGCNA", "TxDb.Hsapiens.UCSC.hg19.knownGene",
  "TxDb.Mmusculus.UCSC.mm10.knownGene"));

install.packages("path/to/anRichmentMethods", repos = NULL, type = "source"); install.packages("path/to/anRichment", repos = NULL, type = "source");

BiocManager::install()

source("https://bioconductor.org/biocLite.R");
biocLite(c("AnnotationDBI", "GO.db", "org.Hs.eg.db", "org.Mm.eg.db",
  "XML", "WGCNA", "TxDb.Hsapiens.UCSC.hg19.knownGene",
  "TxDb.Mmusculus.UCSC.mm10.knownGene"));






if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")

BiocManager::install("impute")


str(all_fpkm)
table(all_fpkm)
names(all_fpkm)