This function adjusts for confounders in the expression data of a mass_dataset object. The function takes a list of confounders from the sample_info data and performs a linear regression adjustment on the expression data for each specified confounder.

adjust_confounder(object, confounder_name_list)

Arguments

object

A mass_dataset object that contains expression data and sample information.

confounder_name_list

A character vector specifying the names of the confounders to adjust for. These names should be columns in the sample_info slot of the mass_dataset object.

Value

A modified mass_dataset object with adjusted expression data where confounders have been accounted for.

Details

This function performs a linear model regression for each feature in the expression data against the specified confounders from the sample information. The residuals of the model are used as the adjusted expression data. If any NA values are present in the confounders or if the confounder names are not found in the sample_info, the function will stop and return an error.

Errors

  • The function will stop if confounder_name_list is empty.

  • The function will stop if any of the confounder names in confounder_name_list are not present in the sample_info.

  • The function will stop if any NA values are present in the specified confounders.

Examples

if (FALSE) { # \dontrun{
# Assuming `mass_object` is a valid mass_dataset object and `confounders` is a vector
# of column names from the sample_info slot.
adjusted_object <- adjust_confounder(object = mass_object, confounder_name_list = confounders)
} # }