Entering edit mode
3.1 years ago
Bioinfonext
▴
470
Hi, I am trying to plot the Network plot as suggested here (https://github.com/stefpeschel/NetCoMi#single-association-network-on-genus-level) by using igraph and NetCoMi.
But I am not getting the network plot as expected- I just want to label the hub genera and phyla. and want the network plot in spherical layout.
# Agglomerate to genus level
amgut_genus <- phyloseq::tax_glom(physeqN, taxrank = "Genus")
taxtab <- amgut_genus@tax_table@.Data
amgut_genus@tax_table@.Data <- taxtab
rownames(amgut_genus@otu_table@.Data) <- taxtab[, "Genus"]
net_single <- netConstruct(amgut_genus,
filtTax = "highestFreq",
filtTaxPar = list(highestFreq = 100),
filtSamp = "totalReads",
filtSampPar = list(totalReads = 1000),
measure = "spring",
measurePar = list(nlambda=10,
rep.num=10),
normMethod = "none",
zeroMethod = "none",
sparsMethod = "none",
dissFunc = "signed",
verbose = 3,
seed = 123456)
props_single3 <- netAnalyze(net_single,
centrLCC = TRUE,
clustMethod = "cluster_fast_greedy",
hubPar = "eigenvector",
weightDeg = FALSE, normDeg = FALSE)
graph3 <- igraph::graph_from_adjacency_matrix(net_single$adjaMat1, weighted = TRUE)
lay_fr <- igraph::layout.sphere(graph3)
rownames(lay_sphere) <- rownames(net_single$adjaMat1)
# Get phyla names from the taxonomic table created before
phyla <- as.factor(taxtab[, "Phylum"]))
names(phyla) <- taxtab[, "Genus"]
# Define phylum colors
phylcol <- c("cyan", "blue3", "red", "lawngreen", "yellow", "deeppink")
pdf("soil1.wet.pdf", width = 12, height = 12)
plot(props_single3,
layout = "layout_with_sphere",
shortenLabels = "simple",
labelLength = 10,
labelScale = FALSE,
rmSingles = TRUE,
nodeSize = "clr",
nodeColor = "cluster",
hubBorderCol = "darkgray",
cexNodes = 2,
cexLabels = 0,
featVecCol = phyla,
cexHubLabels = 1,
title1 = "Network on genus level with Pearson correlations",
showTitle = TRUE,
cexTitle = 2.3)
# Colors used in the legend should be equally transparent as in the plot
phylcol_transp <- NetCoMi:::colToTransp(phylcol, 60)
legend(-1.2, 1.2, cex = 2, pt.cex = 2.5, title = "Phylum:",
legend=levels(phyla), col = phylcol_transp, bty = "n", pch = 16)
legend(0.7, 1.1, cex = 2.2, title = "estimated correlation:",
legend = c("+","-"), lty = 1, lwd = 3, col = c("darkturquoise","orange"),
bty = "n", horiz = TRUE)
dev.off();
Many thanks
It has been a while since I used NetCoMi but in the function
plot
try adding the following arguments:repulsion = 0.84
andhighlightHubs = TRUE