We are interested in particular protein signaling activity that might give rise to specific immune phenotypes.
##now how do we bracket them?
##plot correlation distributions by cell type and method.
require(ggplot2)
p<-corVals%>%
ungroup()%>%
# mutate(LatentVariable = stringr::str_trim(as.character(latent_var), 20))%>%
ggplot()+geom_boxplot(aes(x=latent_var,y=corVal))+ theme(axis.text.x = element_text(angle = 45, hjust = 1))+ggtitle("Correlation of metaviper proteins with lv")
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(latent_var)%>%unique()
print(paste('we found',nrow(cor_cell_types),'cell types with some protein correlation greater than',corthresh))
## [1] "we found 95 cell types with some protein correlation greater than 0.65"
apply(cor_cell_types,1,function(x){
ct=x[['latent_var']]
# m=x[['method']]
#for each gene and cell type
genes=subset(corVals,latent_var==ct)%>%
subset(corVal>corthresh)%>%
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(latent_var==ct)
p2<- ggplot(scores)+
geom_point(aes(x=value,y=protScore,
col=gene,shape=conditions))+
scale_x_log10()+
ggtitle(paste(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]]
##
## [[13]]
##
## [[14]]
##
## [[15]]
##
## [[16]]
##
## [[17]]
##
## [[18]]
##
## [[19]]
##
## [[20]]
##
## [[21]]
##
## [[22]]
##
## [[23]]
##
## [[24]]
##
## [[25]]
##
## [[26]]
##
## [[27]]
##
## [[28]]
##
## [[29]]
##
## [[30]]
##
## [[31]]
##
## [[32]]
##
## [[33]]
##
## [[34]]
##
## [[35]]
##
## [[36]]
##
## [[37]]
##
## [[38]]
##
## [[39]]
##
## [[40]]
##
## [[41]]
##
## [[42]]
##
## [[43]]
##
## [[44]]
##
## [[45]]
##
## [[46]]
##
## [[47]]
##
## [[48]]
##
## [[49]]
##
## [[50]]
##
## [[51]]
##
## [[52]]
##
## [[53]]
##
## [[54]]
##
## [[55]]
##
## [[56]]
##
## [[57]]
##
## [[58]]
##
## [[59]]
##
## [[60]]
##
## [[61]]
##
## [[62]]
##
## [[63]]
##
## [[64]]
##
## [[65]]
##
## [[66]]
##
## [[67]]
##
## [[68]]
##
## [[69]]
##
## [[70]]
##
## [[71]]
##
## [[72]]
##
## [[73]]
##
## [[74]]
##
## [[75]]
##
## [[76]]
##
## [[77]]
##
## [[78]]
##
## [[79]]
##
## [[80]]
##
## [[81]]
##
## [[82]]
##
## [[83]]
##
## [[84]]
##
## [[85]]
##
## [[86]]
##
## [[87]]
##
## [[88]]
##
## [[89]]
##
## [[90]]
##
## [[91]]
##
## [[92]]
##
## [[93]]
##
## [[94]]
##
## [[95]]
#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)