#Supplementary Software 1: Immune cell weight script #--------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------- # Script that generates up- and down-regulated weight sets that specify the # specificity by which each gene is expressed by a given cell # # For best results, use an immune cell dataset that contains a wide variety of immune cell types # # Output of this file can be inputted directly into BASE (SuppSoftware2) as the "reg" variable #--------------------------------------------------------------------------------------------------- rm(list=ls()) myinf1 = #numeric matrix; Immune cell gene expression profiles, with genes as rows and cells as columns myoutf1 = #Output .txt file to store the combined dataset of up- and down-regulated weight sets myoutf2 = #Output .rda file to store the combined dataset of up- and down-regulated weight sets load(file=myinf1) data = mydata med = apply(data, 1, median) data = data-med avg = apply(data, 2, mean) std = apply(data, 2, sd) for(k in 1:ncol(data)) { data[,k] = (data[,k]-avg[k])/std[k] } res1 = data for(k in 1:ncol(res1)) { tmp = data[,k] tmp[tmp<0]=0 tmp = -log10(pnorm(-tmp)*2) tmp[tmp>10]=10 res1[,k] = tmp } colnames(res1) = paste(colnames(data), "_up", sep="") res2 = data for(k in 1:ncol(res2)) { tmp = data[,k] tmp[tmp>0]=0 tmp = -log10(pnorm(tmp)*2) tmp[tmp>10]=10 res2[,k] = tmp } colnames(res2) = paste(colnames(data), "_dn", sep="") res = cbind(res1, res2) minv = min(res) maxv= max(res) res = (res-minv)/(maxv-minv) colnames(res) = gsub(" ", "", colnames(res)) write.table(res, myoutf1, sep="\t", quote=F) mydata = res save(mydata, file= myoutf2)