---
title: "mut"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{mut}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(oncoPredict)

#Apply idwas() function.

#Determine the parameters of the idwas() function...
#Set the drug_prediction parameter.
#Make sure rownames() are samples, and colnames() are drugs. Also make sure this data is a data frame.
drug_prediction<-as.data.frame(read.table('DrugPredictions.txt', header=TRUE, row.names=1))
#In this example, I had to replace the '.' in the names of these TCGA samples with '-' so that they are of the same form as samples in the mutation  data (you may not have to do this).
colnames(drug_prediction)<-gsub(".", "-", colnames(drug_prediction), fixed=T)
#Make sure the sample identifiers in the 'drug prediction' data are of similar form as the sample identifiers in the 'data' parameter.
cols=colnames(drug_prediction)
colnames(drug_prediction)<-substring(cols, 3, nchar(cols))
drug_prediction<-as.data.frame(t(drug_prediction))

wd<-tempdir()
savedir<-setwd(wd)

```


This script *used to* provide an example of how to download mutation data from the GDC database for GBM (glioblastoma) and how to apply idwas() to test the drugs in your drug response dataset to each mutation to identify biomarkers that #enrich for drug response.

However, GDC updated how to get the MAF dataset, so we will just provide information so the readers can hopefully get it to run if they need. 

Download mutation data for your cancer of interest from GDC database.

https://bioconductor.org/packages/release/bioc/vignettes/TCGAbiolinks/inst/doc/mutation.html

https://rdrr.io/bioc/TCGAbiolinks/f/vignettes/mutation.Rmd


The code would look something like this: 
`library(TCGAbiolinks)`
`query_maf <- GDCquery(project = "TCGA-GBM",` 
                      `data.category = "Simple Nucleotide Variation",`
                      `access = "open",` 
                      `data.type = "Simple somatic mutation",` 
                      `legacy = TRUE)`


`GDCdownload(query)`
`maf <- GDCprepare(query)`

Then there is some light formatting to be done before running IDWAS. 

#Make sure this data is a data frame and that colnames() are samples.
data<-as.data.frame(maf)
samps<-data$Tumor_Sample_Barcode
data$Tumor_Sample_Barcode<-substr(samps,1,nchar(samps)-12) #Make sure these sample ids are of the same form as the sample ids in your prediction data.

#Determine the number of samples you want the CNVs to be amplified in. The default is 10.
n=10

#Indicate whether or not you would like to test cnv data. If TRUE, you will test cnv data. If FALSE, you will test mutation data.
cnv=FALSE
