Spaghetti Plots

plot_spaghetti(
  x,
  plot.var = "by_taxa",
  select.taxa = NULL,
  xvar = NULL,
  group = NULL,
  line.bg.color = "#8d99ae",
  bg.opacity = 0.5,
  focus.color = "brown3",
  ncol = NULL,
  nrow = NULL,
  focus.line.size = 0.5,
  line.size = 1
)

Arguments

x

phyloseq-class object

plot.var

One of "by_sample":Many sample one taxa or "by_taxa":Many taxa one sample

select.taxa

a character list of taxa to be plotted. eg. select.taxa <- c("OTU-370251", "OTU-311173", "OTU-341024").

xvar

X-axis variable. This can be visit_number for participants in subject_id.

group

Column describing sample that have multiple measurements. For e.g. Subject_Ids which has all subject_ids listed.

line.bg.color

Line color for background. Default ="#8d99ae",

bg.opacity

Line opacity for background.

focus.color

Line color for focus being plotted.

ncol

if wrap, specify number of columns.

nrow

if wrap, specify number of rows.

focus.line.size

Line size for focus being plotted.

line.size

Line size for background.

Value

ggplot object. This can be further modified using ggpubr.

Examples

if (FALSE) {
# Example data
library(microbiomeutilities)
data("hmp2")
pseq <- hmp2 # Ren
pseq.rel <- microbiome::transform(pseq, "compositional")
pseq.relF <- format_to_besthit(pseq.rel)
# Choose one participant
phdf.s <- subset_samples(pseq.relF, subject_id ==
  "Participant_1")
# Choose top 12 taxa to visualize
ntax <- top_taxa(phdf.s, 12)
phdf.s <- prune_taxa(ntax, phdf.s)

plot_spaghetti(phdf.s,
  plot.var = "by_taxa",
  select.taxa = ntax,
  xvar = "visit_number",
  line.bg.color = "#8d99ae",
  focus.color = "#555b6e",
  ncol = 3,
  nrow = 4,
  line.size = 0.2
)

print(p)
}