R/utilities.R

Defines functions combine_multimodal_dataframes setNames

#' setNames
#'
#' My personal setNames function
#'
#' @param object the object to name
#' @param nm the names
#'
#' @return the named object
#' @noRd
setNames <- function(object, nm) {
  names(object) <- nm
  object
}


#' Combine multimodal dataframes
#'
#' @param df_list list of dfs
#' @param modality_names names of the modalities
#'
#' @return a combined dataframe containing all the cell-specific covariates
#' @noRd
combine_multimodal_dataframes <- function(df_list, modality_names) {
  new_names <- lapply(seq(1, length(modality_names)), function(i) {
    paste0(modality_names[i], "_", colnames(df_list[[i]]))
  }) %>% unlist()
  out <- do.call(what = cbind, args = df_list)
  colnames(out) <- new_names
  return(out)
}

Try the ondisc package in your browser

Any scripts or data that you put into this service are public.

ondisc documentation built on March 5, 2021, 5:07 p.m.