We are interested in particular protein signaling activity that might give rise to specific immune phonetypes.
##now how do we bracket them?
##plot correlation distributions by cell type and method.
require(ggplot2)
p<-ggplot(corVals)+geom_boxplot(aes(x=cell_type,y=corVal,fill=method))+ theme(axis.text.x = element_text(angle = 45, hjust = 1))+ggtitle("Correlation of metaviper proteins with predicted cell type")
print(p)
There are some proteins that show up as highly correlated. By choosing a threshold, we can evaluate what they are in more detail.
corthresh=0.65
##now filter to the cell types with correlated proteins
cor_cell_types=subset(corVals,corVal>corthresh)%>%ungroup()%>%
select(cell_type,method)%>%unique()
print(paste('we found',nrow(cor_cell_types),'cell types with some protein correlation greater than',corthresh))
## [1] "we found 12 cell types with some protein correlation greater than 0.65"
apply(cor_cell_types,1,function(x){
ct=x[['cell_type']]
m=x[['method']]
#for each gene and cell type
genes=subset(corVals,cell_type==ct)%>%
subset(corVal>corthresh)%>%
subset(method==m)%>%arrange(desc(corVal))%>%
ungroup()
if(nrow(genes)>12){
new.corthresh=format(genes$corVal[15],digits=3)
genes=genes[1:12,]
}else{
new.corthresh=corthresh
}
scores=subset(combined,gene%in%genes$gene)%>%subset(cell_type==ct)%>%subset(method==m)
p2<- ggplot(scores)+
geom_point(aes(x=immScore,y=protScore,
col=gene,shape=conditions))+
scale_x_log10()+
ggtitle(paste(m,'predictions of',ct,'correlation >',new.corthresh))
print(p2)
# ggsave(paste0(m,'predictions of',gsub(" ","",gsub("/","",ct)),'cor',new.corthresh,'.pdf'))
})
## [[1]]
##
## [[2]]
##
## [[3]]
##
## [[4]]
##
## [[5]]
##
## [[6]]
##
## [[7]]
##
## [[8]]
##
## [[9]]
##
## [[10]]
##
## [[11]]
##
## [[12]]
#parentid='syn20710537'
#for(fi in list.files('.')[grep('tions',list.files('.'))])
# synapser::synStore(synapser::File(fi,parentId=parentid,annotations=list(resourceType='analysis',isMultiSpecimen='TRUE',isMultiIndividual='TRUE')),used=c(deconv_scores,metaviper_scores),executed=this.script)