stefpeschel / NetCoMi

Network construction, analysis, and comparison for microbial compositional data
GNU General Public License v3.0
143 stars 24 forks source link

rename labels node #91

Closed ZiliaMR closed 9 months ago

ZiliaMR commented 1 year ago

Hello,

I hope you are doing well. I am creating a network using qiime2 data. I have successfully generated the network, but the node names are assigned as ASV codes, as shown in the following image. What I would like is for the node names to be the corresponding genera.

Captura de Pantalla 2023-07-15 a la(s) 22 21 40

I have tried different ways to replace these ASV names without success. I am aware of a parameter called "labels," but I'm not sure what input is required.

plot(props_status,
          sameLayout = FALSE, 
          labels = names,
          nodeColor = "cluster",
          nodeSize = "mclr",
          labelScale = FALSE,
          cexNodes = 1.5, 
          cexLabels = 2.5,
          cexHubLabels = 3,
          cexTitle = 2.5,
          groupNames = c("Enfermo", "Sano"),
          charToRm = "g__",
          featVecCol = phyla, 
          colorVec =  phylcol,
          #posCol = "darkturquoise", 
          #negCol = "orange",
          hubBorderCol  = "gray40")

I have the association between ASV codes and genera (in the form of a data frame or other formats) in nodeLabels.txt.

Could you please provide me with an example or instructions on how to use this association to replace the ASV names with genera in the network? I would greatly appreciate your assistance.

Thank you for your help.

stefpeschel commented 1 year ago

Dear Zilia,

In the GitHub readme there is a tutorial on how to generate a network at genus level. However, in your case, it should be enough to replace the row names in your count matrix with the genus names, since your data is already agglomerated to genus level, right?

Best, Stefanie

ZiliaMR commented 1 year ago

yes, it is already agglomerated to genus level. But, I have resolved the issue, and I'm sharing the solution here in case it can be helpful to others. Previously, I was using the output from Qiime as the first input and converting it into the phyloseq format using the following method:

physeq <- qza_to_phyloseq(
  features = "table_fungi.qza",
  tree = "rooted-tree_fungi.qza",
  "taxonomy_fungi.qza",
  metadata = "sample-metadata_fungi.tsv"
)

Then I continued with this tutorial However, this method resulted in the node labels being displayed with ASV codes (using qiime2 version 2020.2 output). To overcome this, first I collapsed the data down to the genus level using Qiime2:

qiime taxa collapse \
 --i-table table.qza \
 --i-taxonomy taxonomy.qza \
 --p-level 6 \
 --o-collapsed-table level6-table.qza

With the resulting output file (level6-table.qza), I was able to calculate the network, and the labels corresponded to the desired genera. I hope this information proves useful to others."

This is the code that used to read the level6-table.qza

library(qiime2R)
genus <-read_qza("level6-table.qza")$data

class(genus)
[1] "matrix" "array"