The whole function is now restructured and improved. Even though the function was working, it was too complex to maintain I think. It was not easy to add the suggested things without refactoring the code. That is why the function is now mostly coded again, I think it is much simpler. Moreover, it has many additional capabilities that were not before which makes the function now rather flexible.
Main changes
The code is now simpler. However, all old functionalities are still fully supported.
User can choose manually the order of columns and rows.
Facets are supported now also for columns
Support for paired samples.
Because this has many new features and the Bioconductor release is coming soon, I think it is the wisest to keep this PR open and merge this to the next Bioconductor development version. I can also test this in one of my projects before merging.
# Plot with annotation bar
p <- plotAbundance(tse, col.var = "Gender", assay.type = "relabundance")
wrap_plots(p, ncol = 1, heights = c(0.95, 0.05))
# Plot with annotation bar and order
p <- plotAbundance(tse, col.var = "Gender", order.col.by = "Gender", assay.type = "relabundance")
wrap_plots(p, ncol = 1, heights = c(0.95, 0.05))
# Plot with facets for sample metadata variable
p <- plotAbundance(tse, col.var = "Gender", facet.cols = TRUE, scales = "free_x", assay.type = "relabundance")
p
# Plot with facets for multiple sample metadata variables (this requires an additional package that is not dependency)
p <- plotAbundance(tse, col.var = c("Nationality", "Gender"), facet.cols = TRUE, scales = "free_x", assay.type = "relabundance")
p
# Add own taxa order
order <- rownames(tse)
order <- c(order[!order%in%c("Bacteroides")], "Bacteroides")
p <- plotAbundance(tse, row.levels = order, assay.type = "relabundance")
p
# Prepare data
data("Tengeler2020")
tse <- Tengeler2020
tse <- agglomerateByPrevalence(tse, prevalence = 0.70)
tse <- tse[, 1:12]
colData(tse)[["patient"]] <- rep(paste0("patient", seq_len(4)), ncol(tse) / 4)
colData(tse)[["time_point"]] <- rep(paste0("time", seq_len(20)), each = 4)[1:12]
# Drop patient 1 from 1st time point, patient 2 from 2nd time point and patient 3 and 4 from time point 3
tse <- tse[ , c(2:5, 7:10)]
# Create a plot with paired data for comparison
p <- plotAbundance(
tse, col.var = "time_point", order.col.by = "patient", as.relative = TRUE,
paired = TRUE, facet.cols = TRUE, ncol = 1, scales = "free_x")
p
This PR implements the suggestions made in here: https://github.com/microbiome/miaViz/issues/132
The whole function is now restructured and improved. Even though the function was working, it was too complex to maintain I think. It was not easy to add the suggested things without refactoring the code. That is why the function is now mostly coded again, I think it is much simpler. Moreover, it has many additional capabilities that were not before which makes the function now rather flexible.
Main changes
Because this has many new features and the Bioconductor release is coming soon, I think it is the wisest to keep this PR open and merge this to the next Bioconductor development version. I can also test this in one of my projects before merging.
Here are few examples on the usage