-
Notifications
You must be signed in to change notification settings - Fork 10
/
Fig.6B.EPICON.cooccurnetwork.2019.04.06.Rmd
78 lines (63 loc) · 2.08 KB
/
Fig.6B.EPICON.cooccurnetwork.2019.04.06.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: "Fig.6B.EPICON.network.2019.04.06"
author: "Cheng Gao"
date: "4/6/2019"
output: html_document
---
```{r, message=FALSE, warning=FALSE, fig.height = 7, fig.width = 7}
setwd("/Users/chengg/Google Drive/EPICON/Mycobiome/Fungal ITS/statistic/Total.fungi")
library(reshape2)
library(ggplot2)
library(MASS)
library(splitstackshape)
library(colorRamps)
library(vegan)
library(picante)
library(MASS)
#library(compositions)
#library(zCompositions)
source("chunk/codaSeq_functions.R")
library(tidyverse)
library(corrr)
library(igraph)
library(ggraph)
library(plyr)
#library(ggtern)
source("sma.df.R")
source("multiplot.R")
load("EPICON.data.preparation.RC.bNTI.ghost.2019.03.17.Rdata")
fung.clr<-read.csv("fung.clr.csv", head= T, row.names =1)
d.n0.clr<-fung.clr
d.n0.sym.phi <- propr.phisym(d.n0.clr)
d.n0.sma <- sma.df(d.n0.clr)
lt <- which(col(d.n0.sma$b)<row(d.n0.sma$b), arr.ind=FALSE)
lt.ind <- which(col(d.n0.sma$b)<row(d.n0.sma$b), arr.ind=TRUE)
d.n0.phi.min <- lt.row.min(d.n0.sym.phi)
d.n0.sma.df <- data.frame(row=factor(rownames(d.n0.sma$b)[lt.ind[,"row"]]), col=factor(colnames(d.n0.sma$b)[lt.ind[,"col"]]))
d.n0.sma.df$b <- d.n0.sma$b[lt]
d.n0.sma.df$p <- d.n0.sma$p[lt]
d.n0.sma.df$r2 <- d.n0.sma$r2[lt]
d.n0.sma.df$phi <- d.n0.sym.phi[lt]
phi.cutoff <- 0.1
d.n0.sma.lo.phi <- subset(d.n0.sma.df, phi < phi.cutoff)
#igraph = graph_from_adjacency_matrix(d.n0.sma.lo.phi[,c(1,2,3)], mode="undirected",weighted=TRUE,diag=FALSE)
#igraph
g <- graph.data.frame(d.n0.sma.lo.phi, directed=FALSE)
igraph<-g
otu_pro = ID
# set vertices size
igraph.size = otu_pro[V(igraph)$name,] #
igraph.size1 = log((sqrt(igraph.size$abu.raw))) #
V(igraph)$size = igraph.size1
set.seed(333)
# set vertices color
igraph.col = otu_pro[V(igraph)$name,]
#droplevels(igraph.col)
levels(igraph.col$Guild) = c("green","blue","purple","black","chocolate", "red","grey")
V(igraph)$color = as.character(igraph.col$Guild)
plot(igraph,main="Co-occurrence network",
vertex.frame.color=NA,
vertex.label=NA,
layout=layout.fruchterman.reingold.grid(igraph, weight=0.05/E(igraph)$phi),
edge.lty=1,margin=c(0,0,0,0))
```