Closed Valentin-Bio-zz closed 1 year ago
Hi Valentín,
I think the colorVec
argument is what you're looking for.
Here's an example with the amgut data:
library(NetCoMi)
library(phyloseq)
data("amgut2.filt.phy")
# Split the phyloseq object into two groups
amgut_split <- metagMisc::phyloseq_sep_variable(amgut2.filt.phy,
"SEASONAL_ALLERGIES")
# Network construction
net_season <- netConstruct(data = amgut_split$no,
data2 = amgut_split$yes,
filtTax = "highestVar",
filtTaxPar = list(highestVar = 50),
measure = "spieceasi",
measurePar = list(method = "mb",
pulsar.params = list(rep.num = 10),
symBetaMode = "ave"),
normMethod = "none",
zeroMethod = "none",
sparsMethod = "none",
dissFunc = "signed",
verbose = 3,
seed = 123456)
adjma_oral_AR <- net_season$adjaMat1
adjma_oral_NO <- net_season$adjaMat2
oral_NO_AR_comp <- netAnalyze(oral_NO_AR_net,
centrLCC = FALSE,
avDissIgnoreInf = TRUE,
clustMethod = "cluster_fast_greedy",
hubPar = c("between", "degree", "eigenvector"),
hubQuant = 0.90,
normDeg = TRUE,
normBetw = TRUE,
normEigen = TRUE)
hubs_col_oral_AR <- ifelse(rownames(adjma_oral_AR) %in%
oral_NO_AR_comp$hubs$hubs1, "blue", "orange")
names(hubs_col_oral_AR) <- rownames(adjma_oral_AR)
hubs_col_oral_NO <- ifelse(rownames(adjma_oral_NO) %in%
oral_NO_AR_comp$hubs$hubs2, "blue", "orange")
names(hubs_col_oral_NO) <- rownames(adjma_oral_NO)
colhubs_list <- list(hubs_col_oral_AR, hubs_col_oral_NO)
plot(oral_NO_AR_comp,
groupNames = c("Rhinitis asthmatic", "Healthy"),
cexNodes = 0.6,
cexHubLabels = 2 ,
cexLabels = 1,
cexTitle = 2,
nodeColor = "colorVec",
colorVec = colhubs_list,
sameColThresh = 3,
cexHubs = 1.7,
layoutGroup = "union",
rmSingles = "inboth",
nodeFilter = "highestEigen",
nodeFilterPar = 50,
repulsion = 1,
#labels = labs_bh_ARNO_oral,
layout = "spring")
Hello Stefanie,
sorry for the late response, it worked. thanks a lot!
Hello Stefanie,
I'm trying to plot two nets with different number of OTUs:
On the visualization with
plot()
What I'm trying to do is to add a different colour to the hubs. Let's say I want hubs coloured in blue and the other nodes coloured in orange for two different networks with unequal numbers of ASVs/OTUs. For that purpose I created a list of two named vectors as follows:Finally, I run the
plot()
function adding thecolhubs_list
named list to thefeatVecCol
argument and I got the following error message:Is It possible to add a named list to the
featVecCol
argument?Best,
Valentín.