merge_df(df_list, by, keep.common = TRUE, addNA = FALSE)
-
df_list: A list of dataframes to be merged
-
by: Character vector of column names to merge on. The key column in each dataframe should have the same name. If no columns are specified, the function will try to match the columns by name.
-
keep.common: Logical flag to control the merging of columns with the same name. If set to TRUE, columns with the same name will only be kept once. If set to FALSE, all columns will be kept separate, with an appendix indicating which dataframe they came from.
-
addNA: Logical flag to indicate whether missing values in the merged dataframes should be filled with NA. If set to TRUE, missing values in the merged dataframes will be filled with NA. If set to FALSE, missing values will not be filled.
Returns a single dataframe that is the result of merging the input dataframes. The columns will be merged based on the options specified by the by, keep.common, and addNA inputs.
collapse_taxa(physeq, ranks = NULL)
- Use all available ranks in the phyloseq object
physeq_taxa.list <- collapse_taxa(my_physeq)
The returned list have elements like:
- "physeq.kingdom", "physeq.phylum", "physeq.class", etc.
- "physeq.asv" (the original object)
- Specify only certain ranks
desired_ranks <- c("Phylum", "Class", "Order", "Family", "Genus", "Species") physeq_taxa.list <- collapse_taxa(my_physeq, ranks = desired_ranks)
Check what's in the returned list names(collapsed_subset) e.g. "physeq.phylum", "physeq.class", ..., "physeq.species", "physeq.asv"
- Inspect one of the collapsed objects
ntaxa(physeq_taxa.list[["physeq.genus"]])
This shows the number of taxa after collapsing at the genus level.
- If needed, continue downstream analysis For example, subset_samples or prune_taxa on each collapsed object