inst/extdata/tcell.R

library(magrittr)
library(gdata)
library(stringr)
# Read in the Sachs t-cell original raw data, relabel the variables, and save as list of data frames.
sample_names <- system('ls data-raw/tcell-raw-data-files',intern=T)[1:14] %>%#First 14 files are data sets
  {lapply(., function(filename) str_split(filename, "\\.")[[1]][2])} %>% # remove numbers
  str_replace_all(" ", "")
tcell_raw <- system('ls data-raw/tcell-raw-data-files',intern=T)[1:14] %>%
  {paste("data-raw/tcell-raw-data-files", ., sep="/")} %>% #add the full path from home directory
  lapply(read.xls) %>% #Read them in
  lapply(function(set){#name the set
    names(set) <- c("Raf", "Mek", "Plcg", "PIP2", "PIP3", "Erk", "Akt", "PKA", "PKC", "P38", "Jnk")
    set
  }) %>%
  `names<-`(sample_names)
# Read in Marco Scutari's processed data set
tcell_processed_data <- read.delim("data-raw/tcell-scutari-int.txt", sep=" ", stringsAsFactors = FALSE)
for(i in 1:11){
  tcell_processed_data[, i] <- factor(tcell_processed_data[, i])
}
names(tcell_processed_data) <- c("Raf", "Mek", "Plcg", "PIP2", "PIP3", "Erk", "Akt", "PKA", "PKC", "P38", "Jnk", "INT")
interventions <- sapply(tcell_processed_data$INT, function(i) {
  if(i == 0) {
    ("observational")
  }else{
    return(names(tcell_processed_data)[i])
  }
})
tcell_processed_data$INT <- NULL
tcells <- list(raw_data = tcell_raw, samples = names(tcell_raw), processed = list(.data = tcell_processed_data, interventions = interventions))
devtools::use_data(tcells, overwrite = TRUE)
robertness/bninfo documentation built on May 27, 2019, 10:32 a.m.