getSampleMetaData: Get sample meta data

View source: R/addSampleMetaData.R

getSampleMetaDataR Documentation

Get sample meta data

Description

This function retrieves the metadata for samples in an object. It allows for various options to format the output, remove missing values, and provide warnings for class mismatches.

Usage

getSampleMetaData(
  object,
  as_list = TRUE,
  source_only = FALSE,
  na_rm = TRUE,
  warn = TRUE
)

Arguments

object

An object of class SPATA2.

as_list

Logical, if TRUE, the output will be a list. Default is TRUE.

source_only

Logical, if TRUE, only meta slots that fit to a column of the source data.frame will be included.

na_rm

Logical, if TRUE, removes columns with NA values - missing values. Default is TRUE.

warn

Logical, if TRUE, warnings will be issued for class mismatches between the expected class as defined in the source data.frame and the object's metadata. Default is TRUE.

Value

A data frame or list containing the sample metadata.

## Not run: # Assuming 'sample_object' is your SPATA2 object metadata <- getSampleMetaData(sample_object) metadata_list <- getSampleMetaData(sample_object, as_list = TRUE) metadata_df <- getSampleMetaData(sample_object, as_list = FALSE) metadata_source_only <- getSampleMetaData(sample_object, source_only = TRUE) metadata_no_na <- getSampleMetaData(sample_object, na_rm = TRUE) ## End(Not run)

Note

Only meta slots of one dimension (vectors) are returned. If your SPATA2 object contains meta data that has multiple dimensions (e.g. data.frames, matrices) extract via object@meta_sample.

Examples

# example code

library(SPATA2)
data("example_data")

object <- example_data$object_UKF275T_diet

meta_list <- list(donor_id = "UKF275", organ = "Cerebrum", hist_class = "Glioblastoma")

# prior
getSampleMetaData(object)

# add meta data
object <- addSampleMetaData(object, meta_data = meta_list)

# afterwards
getSampleMetaData(object)

getSampleMetaData(object, as_list = FALSE) # return as data.frame

getSampleMetaData(object, na_rm = FALSE) # return all source_df slots


theMILOlab/SPATAData documentation built on Aug. 27, 2024, 5:04 p.m.