R/cgClinic.R

Defines functions cgClinic

#' get clinical data from patients with specific data about genes
#'
#' Imports:
#' cgdsr
#'
#' @param cgds object, output from the cgBase() function
#' @param cancer_study_id string, the ID as given in the first column of the cgBase() printout
#' @param caselist_name string, caselist name (not ID) to be used (obtained from the printout of the cgStudy() function)
#' @param mergedata data.frame, output from cgData or cgMutation
#' @return data.frame, clinical data of the patients plus the input mergedata
#' @examples
#' cgds <- cgBbase()
#' mystudy <- "laml_tcga"
#' myMutations <- cgData(cgds, mystudy, genes=c("FLT3","TP53"))
#' myClinic <- cgClinic(cgds, mystudy, myMutations)
#' @export
cgClinic <- function(cgds, cancer_study_id, mergedata, caselist_name="All samples"){
  #==get clinical data (patient info) for the data==#
  caselistTable <- cgdsr::getCaseLists(cgds, cancer_study_id)
  caselistId <- subset(caselistTable, case_list_name %in% caselist_name)$case_list_id
  clinic <- cgdsr::getClinicalData(cgds,caselistId)
  clinic <- transform(merge(clinic, mergedata, by=0, sort=F), row.names=Row.names, Row.names=NULL)
  #==output==#
  clinic
}
Solatar/cgAnalyzR documentation built on Feb. 15, 2021, 12:18 a.m.