R/make-oncoprint-dat.R
dat.oncoPrint.Rd
dat.oncoPrint Enables creation of a matrix used to generate an OncoPrint heatmap.
dat.oncoPrint(gen.dat, clin.dat = NULL)
gen.dat | A binary matrix or dataframe, with patients as rows and features as columns. Note that the names of the columns must end in ".Del" or ".Amp" to recognize copy number alterations. (see create.bin.matrix for more details on this format). |
---|---|
clin.dat | An optional clinical file, including only the features the user wishes to add to the plot. Default is NULL. |
mat : a matrix ready to be plotted using plot.Oncoprint().
library(gnomeR) library(dplyr) library(dtplyr) patients <- as.character(unique(mut$Tumor_Sample_Barcode)) bin.mut <- binmat(patients = patients,maf = mut,mut.type = "SOMATIC", SNP.only = FALSE,include.silent = FALSE, specify.plat = FALSE)#> Warning: MUTATION DATA: To ensure gene with multiple names/aliases are correctly grouped together, the #> following genes in your maf dataframe have been recoded. You can supress this with recode.aliases = FALSE #> #> AMER1 recoded to FAM123Bgen.dat <- bin.mut[1:500, names(sort(apply(bin.mut,2, sum),decreasing = TRUE))[1:15]] dat <- dat.oncoPrint(gen.dat) ## adding clinical ## clin.patients.dat <- clin.patients[match(abbreviate(rownames(gen.dat), strict = TRUE, minlength = 9), clin.patients$X.Patient.Identifier),] %>% dplyr::rename(DMPID = X.Patient.Identifier, Smoker = Smoking.History) %>% dplyr::select(DMPID, Sex,Smoker) %>% dplyr::filter(!is.na(DMPID)) %>% dplyr::distinct(DMPID,.keep_all = TRUE) gen.dat <- gen.dat[match(clin.patients.dat$DMPID, abbreviate(rownames(gen.dat),strict = TRUE, minlength = 9)),] clin.patients.dat <- clin.patients.dat %>% dplyr::mutate(DMPID = as.character(DMPID)) %>% tibble::rownames_to_column("to_rm") %>% select(-one_of("to_rm")) %>% tibble::column_to_rownames('DMPID') rownames(gen.dat) <- rownames(clin.patients.dat) dat <- dat.oncoPrint(gen.dat = gen.dat,clin.dat = clin.patients.dat)