Automatically creates directories and adds compression based on file name.
write_biom()-According to BIOM format specification.
write_xlsx()-Raw data and summary tables in Excel file format. See details.
write_fasta()-Sequences only in fasta format.
biommay also be a named character vector.write_tree()-Phylogenetic tree only in newick format.
biommay also be a phylo object.write_counts(),write_metadata(),write_taxonomy()-Tab-separated values.
Usage
write_biom(biom, file, format = "json")
write_metadata(biom, file, quote = FALSE, sep = "\t", ...)
write_counts(biom, file, quote = FALSE, sep = "\t", ...)
write_taxonomy(biom, file, quote = FALSE, sep = "\t", ...)
write_fasta(biom, file = NULL)
write_tree(biom, file = NULL)
write_xlsx(biom, file, depth = 0.1, n = NULL, seed = 0, unc = "singly")Arguments
- biom
An rbiom object, such as from
as_rbiom(). Any value accepted byas_rbiom()can also be given here.- file
Path to the output file. File names ending in
.gzor.bz2will be compressed accordingly. Settingfile=NULLforwrite_fasta(),write_tree(), andwrite_biom(format='json'), and returns a string of the output which would have been written. Forwrite_biom(format='tab'),file=NULLreturns the tibble that would have been written.- format
Options are
"tab","json", and"hdf5", corresponding to classic tabular format, BIOM format version 1.0 and biom version 2.1, respectively. NOTE: to write HDF5 formatted BIOM files, the BioConductor R packagerhdf5must be installed. Default:"json"- quote, sep, ...
Parameters passed on to
write.table(). Default:quote=FALSE, sep="\t"- depth, n
Passed on to
rarefy_cols(). Forwrite_xlsx()only,depth=0disables rarefaction. Default:depth=0.1, n=NULL- seed
Random seed to use in rarefying. See
rarefy_cols()function for details. Must be a non-negative integer. Default:0- unc
How to handle unclassified, uncultured, and similarly ambiguous taxa names. Options are:
"singly"-Replaces them with the OTU name.
"grouped"-Replaces them with a higher rank's name.
"drop"-Excludes them from the result.
"asis"-To not check/modify any taxa names.
Abbreviations are allowed. Default:
"singly"
Value
The normalized filepath that was written to (invisibly), unless
file=NULL (see file argument above).
Details
For write_xlsx(), attributes(biom) are saved as additional worksheets if
the attribute is a data frame, matrix, or dist -class object. An attribute
named 'Reads Per Step' is treated specially and merged with the usual 'Reads
Per Sample' tab.
Examples
library(rbiom)
write_tree(hmp50) %>% substr(1, 50)
#> [1] "(((((((((((((EschC738:0.03627,(((Unc92490:0.05748,"
if (FALSE) {
hmp10 <- hmp50$clone()
hmp10$counts <- hmp10$counts[,1:10] %>% rarefy_cols()
attr(hmp10, "Weighted UniFrac") <- bdiv_distmat(hmp10, 'unifrac')
attr(hmp10, "Unweighted Jaccard") <- bdiv_distmat(hmp10, 'jaccard', weighted=FALSE)
outfile <- write_xlsx(hmp10, tempfile(fileext = ".xlsx"))
}
