You are on page 1of 6

3.5.

2 (2018-12-20) -- "Eggshell Igloo"


Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.


You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.


Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or


'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Workspace loaded from E:/SASIKALA NRCB/Drought/R/WGCNA/.RData]

> source("http://bioconductor.org/biocLite.R")
Bioconductor version 3.7 (BiocInstaller 1.30.0), ?biocLite for help
A newer version of Bioconductor is available for this version of R, ?BiocUpgrade
for help
> library(WGCNA)
Loading required package: dynamicTreeCut
Loading required package: fastcluster

Attaching package: ‘fastcluster’

The following object is masked from ‘package:stats’:

hclust

Attaching package: ‘WGCNA’

The following object is masked from ‘package:stats’:

cor

Warning message:
package ‘WGCNA’ was built under R version 3.5.3
> library(dynamicTreeCut)
> library(cluster)
Warning message:
package ‘cluster’ was built under R version 3.5.3
> library(ggplot2)
> library(impute)
> library(Hmisc)
Loading required package: lattice
Loading required package: survival
Loading required package: Formula

Attaching package: ‘Hmisc’

The following objects are masked from ‘package:base’:

format.pval, units
Warning message:
package ‘Hmisc’ was built under R version 3.5.3
> library(reshape)
Warning message:
package ‘reshape’ was built under R version 3.5.3
> library(fastcluster)
> library(foreach)
Warning message:
package ‘foreach’ was built under R version 3.5.3
> library(doParallel)
Loading required package: iterators
Loading required package: parallel
Warning messages:
1: package ‘doParallel’ was built under R version 3.5.3
2: package ‘iterators’ was built under R version 3.5.3
> biocLite("org.At.tair.db")
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.7 (BiocInstaller 1.30.0), R 3.5.2 (2018-12-20).
Installing package(s) ‘org.At.tair.db’
installing the source package ‘org.At.tair.db’

trying URL
'https://bioconductor.org/packages/3.7/data/annotation/src/contrib/org.At.tair.db_3
.6.0.tar.gz'
Content type 'application/x-gzip' length 41837760 bytes (39.9 MB)
downloaded 39.9 MB

* installing *source* package 'org.At.tair.db' ...


** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'org.At.tair.db'
finding HTML links ... done
org.At.tairARACYC html
org.At.tairARACYCENZYME html
org.At.tairBASE html
org.At.tairCHR html
org.At.tairCHRLENGTHS html
org.At.tairCHRLOC html
org.At.tairENTREZID html
org.At.tairENZYME html
org.At.tairENZYME2TAIR html
org.At.tairGENENAME html
org.At.tairGO html
org.At.tairGO2ALLTAIRS html
org.At.tairMAPCOUNTS html
org.At.tairORGANISM html
org.At.tairPATH html
org.At.tairPATH2TAIR html
org.At.tairPMID html
org.At.tairPMID2TAIR html
org.At.tairREFSEQ html
org.At.tairSYMBOL html
org.At.tair_dbconn html
** building package indices
** testing if installed package can be loaded
* DONE (org.At.tair.db)
In R CMD INSTALL

The downloaded source packages are in


‘C:\Users\Biotech\AppData\Local\Temp\RtmpuaVcqb\downloaded_packages’
installation path not writeable, unable to update packages: boot, class, cluster,
codetools, foreign, MASS, Matrix, mgcv, nlme, rpart, survival
> library(flashClust)

Attaching package: ‘flashClust’

The following object is masked from ‘package:fastcluster’:

hclust

The following object is masked from ‘package:stats’:

hclust

> datExpr = read.csv("Drought.csv")


> getwd()
[1] "E:/SASIKALA NRCB/Drought/R/WGCNA"
> head(datExpr)
Unique.Gene.ID US_UR CS_CR UR_CR US_CS
1 GSMUA_Achr7G17290_001 2.55658 0.1 0.10000 0.10000
2 GSMUA_Achr11G14010_001 4.01925 0.1 -2.93208 0.10000
3 GSMUA_Achr5G21410_001 4.29164 0.1 0.10000 0.10000
4 GSMUA_Achr8G04500_001 5.49195 0.1 0.10000 4.69666
5 GSMUA_Achr4G00090_001 2.48573 0.1 0.10000 0.10000
6 GSMUA_Achr4G04310_001 3.07382 0.1 0.10000 0.10000
> options(stringsAsFactors = FALSE)
> countdata <- read.csv('Drought.csv', header=TRUE)
> dim(countdata)
[1] 3552 5
> names(countdata)
[1] "Unique.Gene.ID" "US_UR" "CS_CR" "UR_CR"
[5] "US_CS"
> femData <- countdata
> names(femData)
[1] "Unique.Gene.ID" "US_UR" "CS_CR" "UR_CR"
[5] "US_CS"
> datExpr = as.data.frame(t(femData[, -c(1)]))
> View(datExpr)
> dim(datExpr)
[1] 4 3552
> names(datExpr) = femData$Unique.Gene.ID
> View(datExpr)
> rownames(datExpr) = names(femData)[-c(1)]
> dim(datExpr)
[1] 4 3552
> powers = c(1:10)
> sft=pickSoftThreshold(datExpr,powerVector=powers, networkType = "signed")
Power SFT.R.sq slope truncated.R.sq mean.k. median.k. max.k.
1 1 0.180 4.79 0.315 1740 1760 1850
2 2 0.353 8.51 0.653 1180 1160 1320
3 3 0.641 12.60 0.832 905 897 1060
4 4 0.753 13.60 0.784 740 749 910
5 5 0.734 13.80 0.712 633 649 808
6 6 0.803 13.50 0.738 558 550 736
7 7 0.825 12.00 0.844 503 503 691
8 8 0.781 9.12 0.968 463 471 658
9 9 0.716 8.69 0.893 432 448 634
10 10 0.634 3.75 0.702 407 422 615
There were 11 warnings (use warnings() to see them)
> sft=pickSoftThreshold(datExpr,dataIsExpr = TRUE,powerVector = powers,corFnc =
cor,corOptions = list(use = 'p'),networkType = "signed")
Power SFT.R.sq slope truncated.R.sq mean.k. median.k. max.k.
1 1 0.180 4.79 0.315 1740 1760 1850
2 2 0.353 8.51 0.653 1180 1160 1320
3 3 0.641 12.60 0.832 905 897 1060
4 4 0.753 13.60 0.784 740 749 910
5 5 0.734 13.80 0.712 633 649 808
6 6 0.803 13.50 0.738 558 550 736
7 7 0.825 12.00 0.844 503 503 691
8 8 0.781 9.12 0.968 463 471 658
9 9 0.716 8.69 0.893 432 448 634
10 10 0.634 3.75 0.702 407 422 615
There were 11 warnings (use warnings() to see them)
> win.graph()
> sizeGrWindow(9, 5)
NULL
> par(mfrow = c(1,2))
> cex1 = 0.9
> win.graph()
> plot(sft$fitIndices[,1], -sign(sft$fitIndices[,3])*sft$fitIndices[,2],xlab="Soft
Threshold (power)",ylab="Scale Free Topology Model Fit, signed R^2",type="n", main
= paste("Scale independence"))
> text(sft$fitIndices[,1],
-sign(sft$fitIndices[,3])*sft$fitIndices[,2],labels=powers,cex=cex1,col="red")
> abline(h = -0.60, col="red")
> plot(sft$fitIndices[,1], sft$fitIndices[,5],xlab="Soft Threshold
(power)",ylab="Mean Connectivity", type="n",main = paste("Mean connectivity"))
> text(sft$fitIndices[,1], sft$fitIndices[,5], labels=powers, cex=cex1,col="red")
> softPower = 9
> adj= adjacency(datExpr,type = "signed", power = softPower)
> TOM=TOMsimilarityFromExpr(datExpr,networkType = "unsigned", TOMType = "signed",
power = softPower)
TOM calculation: adjacency..
..will not use multithreading.
Fraction of slow calculations: 0.000000
..connectivity..
..matrix multiplication (system BLAS)..
..normalization..
..done.
> colnames(TOM) =rownames(TOM) = datExpr
#######> dissTOM=1-TOM
######> geneTree = flashClust(as.dist(dissTOM),method="average")
######Error in hclust(d, method, members) :
###### NA/NaN/Inf in foreign function call (arg 11)
###### geneTree = flashClust(as.dist(dissTOM),method="average", members = NULL)
######Error in hclust(d, method, members) :
###### NA/NaN/Inf in foreign function call (arg 11)
######> View(dissTOM)
> dissTOM = TOMdist(adj)
..connectivity..
..matrix multiplication (system BLAS)..
..normalization..
..done.
> View(dissTOM)
> geneTree = flashClust(as.dist(dissTOM), method = "average")
> moduleLabelsManual1 = cutreeDynamic(dendro = geneTree, distM = dissTOM, method =
"hybrid", deepSplit = 2, pamRespectsDendro = F, minClusterSize = 30)
..cutHeight not given, setting it to 0.991 ===> 99% of the (truncated) height
range in dendro.
..done.
> moduleLabelsManual2 = matchLabels(moduleLabelsManual1, moduleLabelsAutomatic)
Error in matchLabels(moduleLabelsManual1, moduleLabelsAutomatic) :
object 'moduleLabelsAutomatic' not found
> plot(geneTree, xlab="", sub="",cex=0.3)
> minModuleSize = 20
> ds = 3
> cutHeight = 0.99999
> dynamicMods = cutreeDynamic(dendro = geneTree, method="tree", minClusterSize =
minModuleSize)
Error in cutree(dendro, h = heightcutoff) :
the 'height' component of 'tree' is not sorted (increasingly)
> minModuleSize = 4
> dynamicMods = cutreeDynamic(dendro = geneTree, method="tree", minClusterSize =
minModuleSize)
Error in cutree(dendro, h = heightcutoff) :
the 'height' component of 'tree' is not sorted (increasingly)
> moduleLabelsManual1 = cutreeDynamic(dendro = geneTree, distM = dissTOM, method =
"hybrid", deepSplit = 2, pamRespectsDendro = F, minClusterSize = 4)
..cutHeight not given, setting it to 0.991 ===> 99% of the (truncated) height
range in dendro.
..done.
> table(moduleLabelsManual1)
moduleLabelsManual1
0 1 2 3 4 5 6 7 8 9 10 11 12
38 632 516 429 409 321 248 231 185 161 160 125 97
> dynamicColors = labels2colors(moduleLabelsManual1)
> table(dynamicColors)
dynamicColors
black blue brown green greenyellow grey
231 516 429 321 125 38
magenta pink purple red tan turquoise
161 185 160 248 97 632
yellow
409
> plotDendroAndColors(geneTree, dynamicColors, "Dynamic Tree Cut", dendroLabels =
FALSE, hang = 0.03, addGuide = TRUE, guideHang = 0.05, main = "Gene dendrogram and
module colors")
> restGenes= (dynamicColors != "grey")
> diss1=1-TOMsimilarityFromExpr(datExpr[,restGenes], power = softPower)
TOM calculation: adjacency..
..will not use multithreading.
Fraction of slow calculations: 0.000000
..connectivity..
..matrix multiplication (system BLAS)..
..normalization..
..done.
> colnames(diss1) =rownames(diss1) = datExpr[restGenes]
> hier1=flashClust(as.dist(diss1), method="average" )
> plotDendroAndColors(hier1, dynamicColors[restGenes], "Dynamic Tree Cut",
dendroLabels = FALSE, hang = 0.03, addGuide = TRUE, guideHang = 0.05, main = "Gene
dendrogram and module colors")
> diag(diss1) = NA
> sizeGrWindow(7,7)
NULL
> win.graph()
> diag(diss1) = NA
> TOMplot(diss1, hier1, as.character(dynamicColors[restGenes]))
> module_colors= setdiff(unique(dynamicColors), "grey")
> for (color in module_colors){
+ module=SubGeneNames[which(dynamicColors==color)]
+ write.table(module, paste("module_",color, ".txt",sep=""), sep="\t",
row.names=FALSE, col.names=FALSE,quote=FALSE)
+ }
Error in SubGeneNames : object 'SubGeneNames' not found
> for (color in module_colors){
module=datExpr[which(dynamicColors==color)]
write.table(module, paste("module_",color, ".txt",sep=""), sep="\t",
row.names=TRUE, col.names=TRUE,quote=FALSE)}
> module.order <- unlist(tapply(1:ncol(datExpr),as.factor(dynamicColors),I))
> m<-t(t(datExpr[,module.order])/apply(datExpr[,module.order],2,max))
>
heatmap(t(m),zlim=c(0,1),col=gray.colors(100),Rowv=NA,Colv=NA,labRow=NA,scale="none
",RowSideColors=dynamicColors[module.order])
> MEList = moduleEigengenes(datExpr, colors = dynamicColors)
> MEs = MEList$eigengenes
> plotEigengeneNetworks(MEs, "", marDendro = c(0,4,1,2), marHeatmap = c(3,4,1,2))
#####> modules = c("blue","brown")
#####> inModule=is.finite(match(dynamicColors,modules))
#####> probes = names(datExpr)
#####> modProbes=probes[inModule]

You might also like