stefpeschel / NetCoMi

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

Labelling only certain taxa of interest #113

Closed devarajarun closed 4 months ago

devarajarun commented 5 months ago

Hi! I have a basic question on how to label only the taxa that I am interested in visualising. Can you show it with the example data ?

stefpeschel commented 5 months ago

Hi, Here is an example for the Network on genus level tutorial:

# Store plot object
p <- plot(props_genus,
     repulsion = 0.84,
     shortenLabels = "none",
     labelScale = FALSE,
     rmSingles = FALSE, #important to not remove singles here
     doPlot = FALSE)

# Store labels vector and assign taxa labels
labs <- p$labels$labels1
names(labs) <- colnames(net_genus$adjaMat1)

# Remove certain labels
labs[1:20] <- ""

# Plot with predefined labels
plot(props_genus,
     labels = labs,
     repulsion = 0.84,
     shortenLabels = "none",
     labelScale = FALSE,
     rmSingles = TRUE)

This simply removes the first 20 labels. You can change this to suit your needs.