multi_fitteds: Get the fitted values from multiple linear models.

Description Usage Arguments Value Examples

Description

Get the fitted values from multiple linear models.

Usage

1
multi_fitteds(lms, lms_data = NULL, new_data = NULL)

Arguments

lms

A list of fitted linear models (the results of calls to stats::lm() or MASS::rlm()). Most likely, the output of a call to multi_lm().

lms_data

The data frame that was passed as the df argument to multi_lm(), if multi_lm() was used to create lms.

new_data

Rather than calculating the residuals on the data where the model was fit, you can pass a new dataset and calculate the residuals there.

Value

A data frame of the fitted values The variables in this data frame will have their original names. If lms_data is given, other columns (ones for which residuals were not calculated) of that data frame will be returned as is.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
if (rlang::is_installed("mirmisc")) {
  gars_data <- get_combined_cohort_data(c("ga", "rs"), log2 = TRUE) %>%
    dplyr::mutate(
      cohort = factor(
        dplyr::if_else(startsWith(mirvie_id, "RS"), "RS", "GA")
      ),
      meta_major_race = forcats::fct_drop(meta_major_race)
    ) %>%
    dplyr::filter(!is.na(meta_major_race), !is.na(meta_collectionga))
  xs <- c("cohort", "meta_major_race", "meta_collectionga")
  ys <- gars_data %>%
    dplyr::select(dplyr::any_of(mirmisc::get_gene_names())) %>%
    purrr::map_dbl(sum) %>%
    sort() %>%
    tail(100) %>%
    names() # ys are the highest expressed 100 genes
  lms <- multi_lm(gars_data, xs, ys)
  fitteds <- multi_fitteds(lms, gars_data)
}

mirvie/mirmodels documentation built on Jan. 14, 2022, 11:12 a.m.