Skip to contents

lifecycle-experimental

Write the OTU table, the sample data, the taxonomy table and (if present) the reference sequences of a phyloseq object to a single multi-sheet .xlsx file, formatted for submission to the GBIF Metabarcoding Data Toolkit (MDT).

Each sheet gets a leading id column holding the row identifiers (taxa or samples names). The reference sequences, when available, are appended as a DNA_sequence column of the taxonomy sheet (Darwin Core DNA-derived-data extension term).

When check_dwc = TRUE (the default), a lightweight Darwin Core compliance check warns about recommended sample-level terms that are missing from sample_data (decimalLatitude, decimalLongitude, eventDate). This is a non-blocking helper, not a full validation of the GBIF MDT template.

Usage

phyloseq_to_MDT_excel(
  physeq,
  filename = "Phyloseq_Tables.xlsx",
  check_dwc = TRUE
)

Arguments

physeq

(required) a phyloseq-class object.

filename

(character, default "Phyloseq_Tables.xlsx") Path of the output .xlsx file.

check_dwc

(logical, default TRUE) If TRUE, warn about recommended Darwin Core sample-level terms missing from sample_data.

Value

Invisibly returns the path to the written file (filename).

Details

This function requires the writexl package. See the GBIF Metabarcoding Data Toolkit for the expected input format.

Author

Adrien Taudière

Examples

# \donttest{
if (requireNamespace("writexl")) {
  out <- file.path(tempdir(), "data_fungi_mini_MDT.xlsx")
  phyloseq_to_MDT_excel(clean_pq(data_fungi_mini), filename = out)
  file.exists(out)
  unlink(out)
}
#> Loading required namespace: writexl
#> Warning: ! Recommended Darwin Core sample terms missing from sample_data:
#>   "decimalLatitude", "decimalLongitude", and "eventDate".
#>  Add them before GBIF MDT submission if available.
#> Excel file written to /tmp/RtmpMeUGPY/data_fungi_mini_MDT.xlsx
# }