Skip to content
Permalink
c5d03d2a60
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
18 lines (16 sloc) 1.15 KB
#' Add Gene Expression
#' @description This function adds the gene expression values to each "case_id" of a gene in the data frame. It uses the expressionmatrix from organ_data.
#' @param cancer_data A large list created by multimodalR
#' @param nested_metadata A list of data frames made by >make.nested.metadata<
#' @param key Character or integer - Column name or index of unique identifier of nested_metadata, default = "case_id"
#' @importFrom magrittr %>%
#' @examples
#' lungMetaExpression <- add.expression(lungXY, lungMetaExpression)
#' @return Returns the same list but with data franes containing the expression values in a new colummn.
add.expression <- function(cancer_data, nested_metadata, key = "case_id") { #nested_metadata = List of metadata for each gene
for (gene in names(nested_metadata)) {
geneExpression <- cancer_data$Expressionmatrix[gene, c(nested_metadata[[gene]][[key]])] %>% as.numeric #[genename, case_id from the matrix]
nested_metadata[[gene]]$expression <- geneExpression #add the expression values to the data.table
}
return(nested_metadata)
}