Landscape of immune cells

Interesting to plot all the tumors by immune score.

First get the tumor de-convolution results for NF1 tumors from synapse, combine non-standard tumor types and handle basic renaming of variables.

tab<-synapser::synTableQuery("select * from syn20710536")$asDataFrame()
## 
 [####################]100.00%   1/1   Done...    
Downloading  [####################]100.00%   1.1MB/1.1MB (2.4MB/s) Job-99120795986188254388168057.csv Done...
tab<-subset(tab,diagnosis=='Neurofibromatosis 1')

tab$tumorType[which(tab$tumorType%in%c("Ependymoma","Ganglioglioma"))]<-'Other'

tab$tumorType[which(tab$tumorType=="Malignant peripheral nerve sheath tumor")]<-"Malignant Peripheral Nerve Sheath Tumor"

tab<-subset(tab,!tumorType%in%c('Other','High Grade Glioma','Low Grade Glioma'))

Reshape the table

##now what do we see on a tissue level? 

annotes=tab%>%select(specimenID,tumorType,sex,study)%>%distinct()
rownames(annotes)<-annotes$specimenID

mat<-tab%>%subset(method!='xcell')%>%
  select(specimenID,score,method,cell_type)%>%
  spread(key=specimenID,value=score)

Plot the heatmaps

library(pheatmap)
## Warning: package 'pheatmap' was built under R version 3.5.2
annotes<-select(annotes,-specimenID)
for(meth in unique(mat$method)){
  sub.mat<-subset(mat,method==meth)%>%select(-method)
  rownames(sub.mat)<-sub.mat$cell_type
  sub.mat<-select(sub.mat,-cell_type)
  if(meth=='mcp_counter')
    sub.mat<-log10(0.01+sub.mat)
  pheatmap(sub.mat,cellwidth = 10,cellheight=10,annotation_col = annotes,filename=paste0(meth,'NFpreds.pdf'))
  
  pheatmap(sub.mat,cellwidth = 10,cellheight=10,annotation_col = annotes)
}