rm(list = ls(all=TRUE))
library(miic)
library(bnlearn)
library(pcalg)
##
## Attachement du package : 'pcalg'
## Les objets suivants sont masqués depuis 'package:bnlearn':
##
## dsep, pdag2dag, shd, skeleton
library(igraph)
##
## Attachement du package : 'igraph'
## Les objets suivants sont masqués depuis 'package:bnlearn':
##
## as.igraph, compare, degree, subgraph
## Les objets suivants sont masqués depuis 'package:stats':
##
## decompose, spectrum
## L'objet suivant est masqué depuis 'package:base':
##
## union
library(qgraph)
data("cosmicCancer")
head(cosmicCancer)
dim(cosmicCancer)
## [1] 807 176
En appelant l’approche hill climbing sur les données initiales nous faisons face à deux problématiques : - La présence de lignes vides NA - La présence de colonnes constantes Afin de pouvoir appliquer l’approche HC nous supprimons ces dernières ce qui résout le problème.
cosmicCancer_hc = bnlearn::hc(cosmicCancer)
## Error in check.data(x): the data set contains NaN/NA values.
na_rows = cosmicCancer[!complete.cases(cosmicCancer),]
na_idx = as.integer(rownames(na_rows))
cosmicCancer_noNA = cosmicCancer[-na_idx,]
dim(cosmicCancer_noNA)
## [1] 799 176
cosmicCancer_noNA[, "Ploidy"] = as.factor(cosmicCancer_noNA[, "Ploidy"])
cosmicCancer_hc = bnlearn::hc(cosmicCancer_noNA)
## Error in check.data(x): variable esm1 must have at least two levels.
const_col = c()
for(iCol in c(1:ncol(cosmicCancer_noNA))){
if(length(unique(as.character(cosmicCancer_noNA[, iCol]))) < 2){
const_col = c(const_col, iCol)
}
}
cosmicCancer_noNACst = cosmicCancer_noNA[, -const_col]
cosmicCancer_hc = bnlearn::hc(cosmicCancer_noNACst)
cosmicCancer_hc_adj = amat(cosmicCancer_hc)
cosmicCancer_hc_net = igraph::graph_from_adjacency_matrix(cosmicCancer_hc_adj)
plot(cosmicCancer_hc_net, edge.arrow.size = .3,
edge.color = "orange", vertex.color = "orange",
vertex.frame.color ="#FFFFFF",
vertex.label.color = "black", vertex.label.cex = .6,
vertex.label = colnames(cosmicCancer),
layout = layout.fruchterman.reingold)
Isolated = which(igraph::degree(cosmicCancer_hc_net)==0)
cosmicCancer_hc_net_wo0d = delete.vertices(cosmicCancer_hc_net, Isolated)
e <- get.edgelist(cosmicCancer_hc_net_wo0d,names=FALSE)
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(cosmicCancer_hc_net_wo0d),
area=8*(vcount(cosmicCancer_hc_net_wo0d)^2),repulse.rad=(vcount(cosmicCancer_hc_net_wo0d)^3.1))
# Coloriage des genes comme spécifié
cosmicCancer_names <- V(cosmicCancer_hc_net_wo0d)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"green","red")
cosmicCancer_colors[143]<- "yellow"
#Affichage du Graphe
plot(cosmicCancer_hc_net_wo0d, edge.arrow.size = .3,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .5,
vertex.label = cosmicCancer_names,vertex.size = 10,
layout = l2)
## 1.5 Mutated Genes that are significantly related to gene expression
cosmicCancer_maj <- cosmicCancer_hc_adj[which(grepl("^[[:upper:]]+$", substr(rownames(cosmicCancer_hc_adj),1,1))),]
cosmicCancer_maj <- cosmicCancer_maj[,-which(grepl("^[[:upper:]]+$", substr(colnames(cosmicCancer_maj),1,1)))]
mutated_genes <- sort(colSums(cosmicCancer_maj),decreasing = TRUE)
mutated_genes[1:10]
## tp53 rb1 scube2 flt1 rassf7 gnaz mtdh lin9 nusap1 rundc1
## 3 2 1 1 1 1 1 1 1 1
sum_relations_rows <- rowSums(cosmicCancer_hc_adj)
sum_relations_cols <- colSums(cosmicCancer_hc_adj)
ploidy_relations <- sum_relations_rows['Ploidy'] + sum_relations_cols['Ploidy']
print(ploidy_relations)
## Ploidy
## 3
vertex_betws <- sort(betweenness(
cosmicCancer_hc_net_wo0d,
directed = TRUE,
weights = NULL,
nobigint = TRUE
),decreasing = TRUE)
vertex_betws[1:10]
## tp53 MCM6 dck rb1 chek1 bax CDCA7 NDRG1
## 424.1667 332.0000 300.0000 299.0000 294.0000 256.0000 252.7333 240.0000
## DIAPH3 gpr126
## 232.0000 221.0000
edges = as_edgelist(cosmicCancer_hc_net_wo0d)
edges_names = paste(edges[,1], edges[,2], sep="->")
edge_betws <- edge_betweenness(cosmicCancer_hc_net_wo0d,
e = E(cosmicCancer_hc_net_wo0d),
directed = TRUE,
weights = NULL)
names(edge_betws) <- edges_names
edge_betws <- sort(edge_betws,decreasing = T)
edge_betws[1:10]
## chek1->dck rb1->chek1 CDCA7->MCM6 dck->bax bax->gpr126
## 315.0 308.0 300.5 272.0 238.0
## GPR180->DIAPH3 AURKA->tp53 MCM6->rb1 RB1->GPR180 DIAPH3->NDRG1
## 235.0 230.5 212.0 209.0 191.5
data(cosmicCancer)
cosmicCancer_noNACst <- Filter(function(x)(length(unique(x))>1), cosmicCancer_noNACst)
cosmicCancer_pc_data = data.matrix(cosmicCancer_noNACst)
cosmicCancer_pc_data = cosmicCancer_pc_data-1
n_lev = rep(-1, ncol(cosmicCancer_pc_data))
for(iCol in 1:length(n_lev)){
n_lev[iCol] = length(unique(cosmicCancer_pc_data[,iCol]))
}
suffStat <- list(dm = cosmicCancer_pc_data, nlev = n_lev, adaptDF = FALSE)
pc.cancer_data <- pc(suffStat, indepTest = disCItest,
p = ncol(cosmicCancer_noNACst), alpha = 0.01,
verbose = TRUE)
pc.cancer_data_bn = as.bn(pc.cancer_data, check.cycles = FALSE)
pc.cancer_net = igraph::graph_from_adjacency_matrix(amat(pc.cancer_data_bn))
# suppression des sommets de degré 0
Isolated = which(igraph::degree(pc.cancer_net)==0)
V(pc.cancer_net)$name <- colnames(cosmicCancer_pc_data)
pc.cancer_net_wo0d = delete.vertices(pc.cancer_net, Isolated)
# Amelioration d'affichages ( sans overlapping )
e <- get.edgelist(pc.cancer_net_wo0d,names=FALSE)
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(pc.cancer_net_wo0d),
area=8*(vcount(pc.cancer_net_wo0d)^2),repulse.rad=(vcount(pc.cancer_net_wo0d)^3.1))
# Coloriage des genes comme spécifié
cosmicCancer_names <- V(pc.cancer_net_wo0d)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"green","red")
#length(cosmicCancer_names)
#cosmicCancer_names[63]
cosmicCancer_colors[63]<- "yellow"
#Affichage du Graphe
plot(pc.cancer_net_wo0d, edge.arrow.size = .3,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .5,
vertex.label = cosmicCancer_names,vertex.size = 10,
layout = l2)
# Mutated Genes that are significantly related to gene expression
pc.cancer_mat <- amat(pc.cancer_data_bn)
colnames(pc.cancer_mat) <- colnames(cosmicCancer_pc_data)
rownames(pc.cancer_mat) <- colnames(cosmicCancer_pc_data)
cosmicCancer_maj <- pc.cancer_mat[which(grepl("^[[:upper:]]+$", substr(rownames(pc.cancer_mat),1,1))),]
cosmicCancer_maj <- cosmicCancer_maj[,-which(grepl("^[[:upper:]]+$", substr(colnames(pc.cancer_mat),1,1)))]
mutated_genes <- sort(colSums(cosmicCancer_maj),decreasing = TRUE)
mutated_genes[1:10]
## bbc3 egln1 tgfb3 igfbp5 fgf18 scube2 wisp1 flt1 hrasls stk32b
## 0 0 0 0 0 0 0 0 0 0
# Number of Relations that includes "Ploidy" gene
sum_relations_rows <- rowSums(pc.cancer_mat)
sum_relations_cols <- colSums(pc.cancer_mat)
ploidy_relations <- sum_relations_rows['Ploidy'] + sum_relations_cols['Ploidy']
print(ploidy_relations)
## Ploidy
## 2
# Top 10 nodes in terms of betweenness centrality measure
vertex_betws <- sort(betweenness(
pc.cancer_net_wo0d,
directed = TRUE,
weights = NULL,
nobigint = TRUE
),decreasing = TRUE)
vertex_betws[1:10]
## PRC1 DIAPH3 GMPS FOXM1 ECT2 BRCA2 GPR180 RB1 RFC4 LIN9
## 93 88 83 76 52 46 28 17 15 11
# Top 10 edges in terms of betweenness centrality measure
edges = as_edgelist(pc.cancer_net_wo0d)
edges_names = paste(edges[,1], edges[,2], sep="->")
edge_betws <- edge_betweenness(pc.cancer_net_wo0d,
e = E(pc.cancer_net_wo0d),
directed = TRUE,
weights = NULL)
names(edge_betws) <- edges_names
edge_betws <- sort(edge_betws,decreasing = T)
edge_betws[1:10]
## PRC1->DIAPH3 FOXM1->PRC1 GMPS->FOXM1 ECT2->GMPS BRCA2->ECT2
## 103 86 77 62 56
## DIAPH3->GPR180 DIAPH3->BRCA2 GPR180->RB1 RFC4->GMPS LIN9->BRCA2
## 44 39 30 26 22
#### ALPHA = 0.005
pc.cancer_data <- pc(suffStat, indepTest = disCItest,
p = ncol(cosmicCancer_noNACst), alpha = 0.005,
verbose = TRUE)
pc.cancer_data_bn = as.bn(pc.cancer_data, check.cycles = FALSE)
pc.cancer_net = igraph::graph_from_adjacency_matrix(amat(pc.cancer_data_bn))
# suppression des sommets de degré 0
Isolated = which(igraph::degree(pc.cancer_net)==0)
V(pc.cancer_net)$name <- colnames(cosmicCancer_pc_data)
pc.cancer_net_wo0d = delete.vertices(pc.cancer_net, Isolated)
# Amelioration d'affichages ( sans overlapping )
e <- get.edgelist(pc.cancer_net_wo0d,names=FALSE)
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(pc.cancer_net_wo0d),
area=8*(vcount(pc.cancer_net_wo0d)^2),repulse.rad=(vcount(pc.cancer_net_wo0d)^3.1))
# Coloriage des genes comme spécifié
cosmicCancer_names <- V(pc.cancer_net_wo0d)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"green","red")
#cosmicCancer_names[length(cosmicCancer_names)]
cosmicCancer_colors[length(cosmicCancer_names)]<- "yellow"
#Affichage du Graphe
plot(pc.cancer_net_wo0d, edge.arrow.size = .3,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .5,
vertex.label = cosmicCancer_names,vertex.size = 10,
layout = l2)
# Mutated Genes that are significantly related to gene expression
pc.cancer_mat <- amat(pc.cancer_data_bn)
colnames(pc.cancer_mat) <- colnames(cosmicCancer_pc_data)
rownames(pc.cancer_mat) <- colnames(cosmicCancer_pc_data)
cosmicCancer_maj <- pc.cancer_mat[which(grepl("^[[:upper:]]+$", substr(rownames(pc.cancer_mat),1,1))),]
cosmicCancer_maj <- cosmicCancer_maj[,-which(grepl("^[[:upper:]]+$", substr(colnames(pc.cancer_mat),1,1)))]
mutated_genes <- sort(colSums(cosmicCancer_maj),decreasing = TRUE)
mutated_genes[1:10]
## bbc3 egln1 tgfb3 igfbp5 fgf18 scube2 wisp1 flt1 hrasls stk32b
## 0 0 0 0 0 0 0 0 0 0
# Number of Relations that includes "Ploidy" gene
sum_relations_rows <- rowSums(pc.cancer_mat)
sum_relations_cols <- colSums(pc.cancer_mat)
ploidy_relations <- sum_relations_rows['Ploidy'] + sum_relations_cols['Ploidy']
print(ploidy_relations)
## Ploidy
## 2
# Top 10 nodes in terms of betweenness centrality measure
vertex_betws <- sort(betweenness(
pc.cancer_net_wo0d,
directed = TRUE,
weights = NULL,
nobigint = TRUE
),decreasing = TRUE)
vertex_betws[1:10]
## DIAPH3 ECT2 MCM6 CDCA7 RB1 GPR180 BRCA2 AURKA CCNE2 NUSAP1
## 8 6 6 6 6 4 4 4 3 3
# Top 10 edges in terms of betweenness centrality measure
edges = as_edgelist(pc.cancer_net_wo0d)
edges_names = paste(edges[,1], edges[,2], sep="->")
edge_betws <- edge_betweenness(pc.cancer_net_wo0d,
e = E(pc.cancer_net_wo0d),
directed = TRUE,
weights = NULL)
names(edge_betws) <- edges_names
edge_betws <- sort(edge_betws,decreasing = T)
edge_betws[1:10]
## CDCA7->MCM6 ECT2->GMPS RB1->CDKN2A MCM6->RB1 GPR180->RB1
## 8 7 7 6 6
## DIAPH3->GPR180 DIAPH3->BRCA2 BRCA2->ECT2 CDCA7->FOXM1 GPR180->DIAPH3
## 6 6 6 5 5
### ALPHA = 0.001
pc.cancer_data <- pc(suffStat, indepTest = disCItest,
p = ncol(cosmicCancer_noNACst), alpha = 0.001,
verbose = TRUE)
pc.cancer_data_bn = as.bn(pc.cancer_data, check.cycles = FALSE)
pc.cancer_net = igraph::graph_from_adjacency_matrix(amat(pc.cancer_data_bn))
# suppression des sommets de degré 0
Isolated = which(igraph::degree(pc.cancer_net)==0)
V(pc.cancer_net)$name <- colnames(cosmicCancer_pc_data)
pc.cancer_net_wo0d = delete.vertices(pc.cancer_net, Isolated)
# Amelioration d'affichages ( sans overlapping )
e <- get.edgelist(pc.cancer_net_wo0d,names=FALSE)
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(pc.cancer_net_wo0d),
area=8*(vcount(pc.cancer_net_wo0d)^2),repulse.rad=(vcount(pc.cancer_net_wo0d)^3.1))
# Coloriage des genes comme spécifié
cosmicCancer_names <- V(pc.cancer_net_wo0d)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"green","red")
#cosmicCancer_names
#No Ploidy
#Affichage du Graphe
plot(pc.cancer_net_wo0d, edge.arrow.size = .3,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .5,
vertex.label = cosmicCancer_names,vertex.size = 10,
layout = l2)
# Mutated Genes that are significantly related to gene expression
pc.cancer_mat <- amat(pc.cancer_data_bn)
colnames(pc.cancer_mat) <- colnames(cosmicCancer_pc_data)
rownames(pc.cancer_mat) <- colnames(cosmicCancer_pc_data)
cosmicCancer_maj <- pc.cancer_mat[which(grepl("^[[:upper:]]+$", substr(rownames(pc.cancer_mat),1,1))),]
cosmicCancer_maj <- cosmicCancer_maj[,-which(grepl("^[[:upper:]]+$", substr(colnames(pc.cancer_mat),1,1)))]
mutated_genes <- sort(colSums(cosmicCancer_maj),decreasing = TRUE)
mutated_genes[1:10]
## bbc3 egln1 tgfb3 igfbp5 fgf18 scube2 wisp1 flt1 hrasls stk32b
## 0 0 0 0 0 0 0 0 0 0
# Number of Relations that includes "Ploidy" gene
sum_relations_rows <- rowSums(pc.cancer_mat)
sum_relations_cols <- colSums(pc.cancer_mat)
ploidy_relations <- sum_relations_rows['Ploidy'] + sum_relations_cols['Ploidy']
print(ploidy_relations)
## Ploidy
## 0
# Top 10 nodes in terms of betweenness centrality measure
vertex_betws <- sort(betweenness(
pc.cancer_net_wo0d,
directed = TRUE,
weights = NULL,
nobigint = TRUE
),decreasing = TRUE)
vertex_betws[1:10]
## ECT2 GMPS RFC4 CDCA7 AURKB EGLN1 CENPA MCM6 FOXM1 GPR180
## 8 8 5 4 3 2 2 2 2 1
# Top 10 edges in terms of betweenness centrality measure
edges = as_edgelist(pc.cancer_net_wo0d)
edges_names = paste(edges[,1], edges[,2], sep="->")
edge_betws <- edge_betweenness(pc.cancer_net_wo0d,
e = E(pc.cancer_net_wo0d),
directed = TRUE,
weights = NULL)
names(edge_betws) <- edges_names
edge_betws <- sort(edge_betws,decreasing = T)
edge_betws[1:10]
## GMPS->RFC4 ECT2->GMPS RFC4->HRASLS CCNE2->ECT2 NUSAP1->ECT2 CDCA7->MCM6
## 10 9 6 5 5 4
## CDCA7->FOXM1 AURKB->CENPA tp53->GMPS ECT2->BRCA2
## 4 4 3 3
data(cosmicCancer)
with MIIC.
# execute MIIC (reconstruct graph)
miic.res <- miic(
input_data = cosmicCancer, state_order = cosmicCancer_stateOrder, latent = "yes",
n_shuffles = 100, conf_threshold = 0.001
)
# plot graph
if(require(igraph)) {
plot(miic.res)
}
confidenceShuffle : représente le nombre de brassages du dataset originale dans le but d’évaluer le rapport de confiance spécifique aux bords de tous les bords inférés.
confidenceThreshold : Le seuil utilisé pour filtrer les arêtes les moins probables après l’étape du squelette.
# getting several network with different values of threshold and shuffles
miic.res1 <- miic(
input_data = cosmicCancer, state_order = cosmicCancer_stateOrder, latent = "yes",
n_shuffles = 200, conf_threshold = 0.025
)
miic.res2 <- miic(
input_data = cosmicCancer, state_order = cosmicCancer_stateOrder, latent = "yes",
n_shuffles = 50, conf_threshold = 0.1
)
miic.res3 <- miic(
input_data = cosmicCancer, state_order = cosmicCancer_stateOrder, latent = "yes",
n_shuffles = 50, conf_threshold = 0.001
)
miic_res_net = igraph::graph_from_adjacency_matrix(miic.res$adj_matrix,
mode="directed")
miic_res_net1 = igraph::graph_from_adjacency_matrix(miic.res1$adj_matrix,
mode="directed")
miic_res_net2 = igraph::graph_from_adjacency_matrix(miic.res2$adj_matrix,
mode="directed")
miic_res_net3 = igraph::graph_from_adjacency_matrix(miic.res3$adj_matrix,
mode="directed")
plot(miic_res_net, edge.arrow.size = .3,
edge.color = "orange", vertex.color = "orange",
vertex.frame.color ="#ffffff", edge.curved = 0,
vertex.label.color = "black", vertex.label.cex = .6,
vertex.label = colnames(cosmicCancer),
layout = layout.fruchterman.reingold)
## Removing 0 degrees variables and coloring differently
Isolated = which(igraph::degree(miic_res_net)==0)
Isolated1 = which(igraph::degree(miic_res_net1)==0)
Isolated2 = which(igraph::degree(miic_res_net2)==0)
Isolated3 = which(igraph::degree(miic_res_net3)==0)
miic_res_net_wo0d = delete.vertices(miic_res_net, Isolated)
miic_res_net_wo0d1 = delete.vertices(miic_res_net, Isolated1)
miic_res_net_wo0d2 = delete.vertices(miic_res_net, Isolated2)
miic_res_net_wo0d3 = delete.vertices(miic_res_net, Isolated3)
# Coloriage des genes comme spécifié
cosmicCancer_names <- V(miic_res_net_wo0d)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"purple","green")
#length(cosmicCancer_names)
#cosmicCancer_colors[69]<- "yellow"
e <- get.edgelist(miic_res_net_wo0d,names=FALSE)
l <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d))
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d),
area=8*(vcount(miic_res_net_wo0d1)^2),repulse.rad=(vcount(miic_res_net_wo0d)^3.1))
plot(miic_res_net_wo0d, edge.arrow.size = .1,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .4,
vertex.label = colnames(cosmicCancer),vertex.size = 10,
main="n_shuffles = 100 , threshold = 0.001 (from the doc) ",
layout = l2)
cosmicCancer_names <- V(miic_res_net_wo0d1)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"purple","green")
#length(cosmicCancer_names)
cosmicCancer_colors[117]<- "yellow"
e <- get.edgelist(miic_res_net_wo0d1,names=FALSE)
l <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d1))
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d1),
area=8*(vcount(miic_res_net_wo0d1)^2),repulse.rad=(vcount(miic_res_net_wo0d1)^3.1))
plot(miic_res_net_wo0d1, edge.arrow.size = .1,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .4,
vertex.label = colnames(cosmicCancer),vertex.size = 10,
main="n_shuffles = 200 , threshold = 0.025 ",
layout = l2)
cosmicCancer_names <- V(miic_res_net_wo0d2)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"purple","green")
#length(cosmicCancer_names)
cosmicCancer_colors[141]<- "yellow"
e <- get.edgelist(miic_res_net_wo0d2,names=FALSE)
l <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d2))
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d2),
area=8*(vcount(miic_res_net_wo0d2)^2),repulse.rad=(vcount(miic_res_net_wo0d2)^3.1))
plot(miic_res_net_wo0d2, edge.arrow.size = .1,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .4,
vertex.label = colnames(cosmicCancer),vertex.size = 10,
main="n_shuffles = 50 , threshold = 0.1 ",
layout = l2)
cosmicCancer_names <- V(miic_res_net_wo0d3)$name
cosmicCancer_colors <- ifelse(grepl("^[[:upper:]]+$", substr(cosmicCancer_names,1,1)),"purple","green")
#length(cosmicCancer_names)
cosmicCancer_colors[143]<- "yellow"
e <- get.edgelist(miic_res_net_wo0d3,names=FALSE)
l <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d3))
l2 <- qgraph.layout.fruchtermanreingold(e,vcount=vcount(miic_res_net_wo0d3),
area=8*(vcount(miic_res_net_wo0d3)^2),repulse.rad=(vcount(miic_res_net_wo0d3)^3.1))
plot(miic_res_net_wo0d3, edge.arrow.size = .1,
edge.color = "blue", vertex.color = cosmicCancer_colors,
vertex.frame.color ="blue",
vertex.label.color = "black", vertex.label.cex = .4,
vertex.label = colnames(cosmicCancer),vertex.size = 10,
main="n_shuffles = 50 , threshold = 0.001 ",
layout = l2)
sum_relations_rows <- rowSums(miic.res$adj_matrix)
sum_relations_cols <- colSums(miic.res$adj_matrix)
ploidy_relations <- sum_relations_rows['Ploidy'] + sum_relations_cols['Ploidy']
print(ploidy_relations)
## Ploidy
## 2
vertex_betws <- sort(betweenness(
miic_res_net_wo0d,
directed = TRUE,
weights = NULL,
nobigint = TRUE
),decreasing = TRUE)
vertex_betws[1:10]
## tp53 CENPA GMPS FOXM1 AURKA ECT2 CCNE2 NDRG1
## 486.33333 379.00000 310.66667 246.50000 227.66667 175.00000 158.00000 97.00000
## DIAPH3 CHEK1
## 70.66667 53.33333
edges = as_edgelist(miic_res_net_wo0d)
edges_names = paste(edges[,1], edges[,2], sep="->")
edge_betws <- edge_betweenness(miic_res_net_wo0d,
e = E(miic_res_net_wo0d),
directed = TRUE,
weights = NULL)
names(edge_betws) <- edges_names
edge_betws <- sort(edge_betws,decreasing = T)
edge_betws[1:10]
## CENPA->tp53 CENPA->tp53 tp53->GMPS tp53->GMPS AURKA->CENPA AURKA->CENPA
## 148.66667 148.66667 142.00000 142.00000 139.83333 139.83333
## ECT2->CCNE2 ECT2->CCNE2 GMPS->FOXM1 GMPS->FOXM1
## 87.50000 87.50000 79.08333 79.08333