Introduction

This is a first stab at checking immune annotation predictions to see if the presence/absence of immune cells is any different between sexes.

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 (1.6MB/s) Job-99119913981951030363043460.csv Done...
tab<-subset(tab,diagnosis=='Neurofibromatosis 1')

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

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

tab<-subset(tab,tumorType!='Other')

Check tumor-specific sex differences

##now what do we see on a tissue level? 
res.c<-tab%>%subset(method!='xcell')%>%
  spread(key=sex,value=score)%>%
  group_by(method,tumorType,cell_type)%>%
  mutate(pval=t.test(female,male)$p.value)%>%
  select(method,cell_type,pval,tumorType)%>%distinct()%>%
  group_by(method)%>%
  mutate(correctedP=p.adjust(pval))

sigs<-subset(res.c,pval<0.05)

DT::datatable(sigs)

There are numerous significant cell-type/tumor combinations.

library(ggpubr)
## Loading required package: magrittr
## 
## Attaching package: 'magrittr'
## The following object is masked from 'package:purrr':
## 
##     set_names
## The following object is masked from 'package:tidyr':
## 
##     extract
for(ct in unique(sigs$method)){
  sigs.t=subset(sigs,method==ct)
  for(tu in unique(sigs.t$tumorType)){
    sigs.tt=subset(sigs.t,tumorType==tu)
    tab.t=subset(tab,method=ct)%>%subset(tumorType==tu)%>%subset(cell_type%in%sigs.tt$cell_type)

  p<-ggboxplot(tab.t,x='sex',y='score',facet.by='cell_type',color='sex',palette='jco')+stat_compare_means(method='t.test')+ggtitle(paste(ct,tu,' significant differences'))
  print(p)
  
  #  tab.p<-subset(tab.t,method==meth)%>%subset(cell_type%in%(sigs.t$cell_type))
# p<-ggplot(tab.t,palette='jco')+geom_boxplot(aes(x=cell_type,fill=sex,y=score))+facet_grid(.~tumorType)+ theme(axis.text.x = element_text(angle = 90, hjust = 1))
 # p<-ggboxplot(subset(tab.t,cell_type=='Neutrophil'),x='tumorType',y='score',color='sex',palette='jco')+stat_compare_means(method='t.test')+ theme(axis.text.x = element_text(angle = 45, hjust = 1))
 # print(p)
}
  
}

There are some interesting tumor-specific differences, primarily in cNFs, but also some in MPNSTs (with their lone male)

res<-tab%>%spread(key=sex,value=score)%>%
  group_by(method,cell_type)%>%
    mutate(pval=t.test(female,male)$p.value)%>%
  select(method,cell_type,pval)%>%distinct()%>%
  group_by(method)%>%
  mutate(correctedP=p.adjust(pval))


sigs<-subset(res,pval<0.05)
sigs
## # A tibble: 4 x 4
## # Groups:   method [2]
##   method    cell_type                    pval correctedP
##   <chr>     <chr>                       <dbl>      <dbl>
## 1 xcell     B cell                    0.00653     0.111 
## 2 xcell     T cell regulatory (Tregs) 0.0236      0.378 
## 3 cibersort Macrophage M0             0.0459      0.963 
## 4 cibersort Mast cell activated       0.00385     0.0847

Pan-tumor sex differences

for(meth in unique(tab$method)){
  tab.p<-subset(tab,method==meth)%>%subset(cell_type%in%(sigs$cell_type))

  p<-ggboxplot(tab.p,x='sex',y='score',facet.by='cell_type',color='sex',palette='jco')+stat_compare_means(method='t.test')+ggtitle(paste(meth,'significant differences'))
  print(p)
}