writeCombinedMetadataToTsvFromLsObj: Combine Metadata from a list of Seurat objects and Write to...

View source: R/Seurat.Utils.Metadata.R

writeCombinedMetadataToTsvFromLsObjR Documentation

Combine Metadata from a list of Seurat objects and Write to TSV

Description

Formerly writeMetadataToTsv. writeCombinedMetadataToTsvFromLsObj takes a list of ls.Obj, extracts their ⁠@meta.data⁠ slots, removes specified columns, checks for column consistency, creates a barplot showing the number of rows per object, and finally merges these into one large data frame.

Usage

writeCombinedMetadataToTsvFromLsObj(
  ls.Obj,
  cols.remove = character(),
  save_as_qs = TRUE,
  save_as_tsv = TRUE,
  ...
)

Arguments

ls.Obj

A list of objects, each containing a ⁠@meta.data⁠ slot.

cols.remove

A character vector of column names to be removed from each metadata data frame. Default is an empty character vector, meaning no columns will be removed.

save_as_qs

A logical indicating whether to save the merged metadata as a .qs object.

save_as_tsv

A logical indicating whether to save the merged metadata as a .tsv file.

...

Additional arguments to be passed to write.table.

Details

The function starts by validating the input to ensure it's a list. It then extracts the ⁠@meta.data⁠ from each object, removing the specified columns. It checks if all data frames have the same columns and issues a warning if not. A barplot is created to visualize the number of rows (cells) per object. Finally, it merges all the metadata into one large data frame and prints its dimensions.

Value

A large data frame that is the row-wise merge of all ⁠@meta.data⁠ data frames.

Note

This function is intended for use with S4 objects that have a ⁠@meta.data⁠ slot. The function currently contains a browser() call for debugging purposes, which should be removed in production.

Examples

# Assuming a list of Seurat objects with meta.data
mergedMetaData <- writeMetadataToTsv(seuratObjectsList, cols.remove = c("column1", "column2"))


vertesy/Seurat.utils documentation built on Dec. 4, 2024, 5:20 p.m.