Skip to content

Plot phyla colour in netCompare networks #148

Description

@Masoleno

Hi and thank you for a great package!
I have a question regarding how to plot phyla colours on two networks that are created in the same netConstruct call but for two separate groups.
I have a phyloseq object "genus_pseq_glom" that consists of fungal taxa that I have agglomerated at genus level.
I have then run the following code to construct the networks:

`high.int <- subset_samples(genus_pseq_glom, intensity == "High")
low.int <- subset_samples(genus_pseq_glom, intensity == "Low")
high.int
low.int

Construct and analyze networks
n_low <- phyloseq::nsamples(low.int)

net_int <- netConstruct(data = high.int,
data2 = low.int,
filtTax = "numbSamp",
filtTaxPar = list(numbSamp = 2),
filtSamp = "highestFreq",
filtSampPar = list(highestFreq = n_low),
measure = "spieceasi",
measurePar = list(nlambda = 20, lambda.min.ratio = 0.01,
pulsar.params = list(rep.num = 100)),
sparsMethod = "none",
dissFunc = "signed",
cores = 10)

out.int <- netAnalyze(net_int, clustMethod = "cluster_fast_greedy", centrLCC = FALSE) `

I then tried to define the phyla names and colours and use them as node colours like this:
`Get phyla names
tax.tab.low <- as(tax_table(low.int), "matrix")
ncol(tax.tab.low)
head(tax.tab.low)

phyla.low <- as.factor(tax.tab.low[, 2])
phyla.low
names(phyla.low) <- tax.tab.low[, 6]

tax.tab.high <- as(tax_table(high.int), "matrix")
ncol(tax.tab.high)
head(tax.tab.high)
phyla.high <- as.factor(tax.tab.high[, 2])
phyla.high
names(phyla.high) <- tax.tab.high[, 6]

Define phylum colors
phylcol.low <- c("cyan", "blue3", "red", "lawngreen","yellow", "deeppink", "darkgreen",
"brown", "grey")
phylcol.high <- c("cyan", "blue3", "red", "lawngreen","yellow", "deeppink", "darkgreen",
"brown", "grey")

plot(out.int,
sameLayout = FALSE,
repulsion = 0.8,
rmSingles = TRUE,
labelScale = FALSE,
shortenLabels = "intelligent",
nodeFilter = "highestDegree",
nodeFilterPar = 50,
nodeSize = "mclr",
nodeColor = "feature",
sameFeatCol = FALSE,
featVecCol = list(phyla.high, phyla.low),
colorVec = list(phylcol.high, phylcol.low),
hubBorderCol = "gray40",
cexNodes = 1.8,
edgeTranspHigh = 20,
title1 = "Network on genus using SPIEC-EASI",
groupNames = c("High Intensity", "Low Intensity"),
showTitle = TRUE,
cexTitle = 2.3,
mar = c(1, 3, 4, 8))`

But I get the following error message:
Error in plot.microNetProps(out.int, sameLayout = FALSE, repulsion = 0.8, :
all(colnames(adja1) %in% names(featVecCol)) is not TRUE

I would really appreciate any help with this! Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions