##GeneExp: the Gene (mRNAs, TFs) Expression Data (the rows are Genes and the colomns are samples) ##miRNAExp: the miRNA Expression Data(the rows are miRNAs and the colomns are samples) ## miRNATFmRNA_network: the miRNA-TF-mRNA regulatory network [row(regulators)->colomn(tagagets)]. ## The number of row (column) is the sum of the genes (mRNAs, TFs) and miRNAs. ## The order of features in row (column) is corresponding to the order ## in Gene Expression data and miRNA expression data. ##beta: the tuning parameter for the importance of the miRNA-TF-mRNA regulatory network information. ##clusterNum: the clustering number for cancer subtypes WSNF<-function(GeneExp,miRNAExp,miRNATFmRNA_network,beta=0.8,clusterNum=3) { library("SNFtool") ####1. Modified google PageRank algorithm # To excute the PageRank algorithm with a high-dimensions netwok matrix in R is a # time-consuming work. However, this can be easily achieved in Matlab because Matlab has # a strong processing capacity for sparse matrix. # If you can't run this function in your computer, We recormmend to caculate the ranking of # PageRank in Matlab. Then use the "WSNF2" fuction below to get the result of cancer subtypes. # We have also provied the calculated result of the ranking of each feature. It can be used directly. colsum=colSums(miRNATFmRNA_network) colsum[which(colsum==0)]=1 dev=t(apply(miRNATFmRNA_network, 1, function(x) x/colsum)) num=nrow(dev) damping=0.85 A=diag(num)-damping*dev B=solve(A) e=rep(1,num) delta=(1-damping)/num ranking=B %*% e * delta ranking=ranking/sum(ranking) ####2. Normalise ranking and MAD ##### a.Normalise ranking Gene_pageRank=ranking[1:nrow(GeneExp)] Gene_pageRank=Gene_pageRank/sum(Gene_pageRank) miRNA_pageRank=ranking[(nrow(GeneExp)+1):length(ranking)] miRNA_pageRank=miRNA_pageRank/sum(miRNA_pageRank) ##### b.Normalise MAD Gene_MAD=as.vector(apply(GeneExp,1,mad)) Gene_MAD=Gene_MAD/sum(Gene_MAD) miRNA_MAD=as.vector(apply(miRNAExp,1,mad)) miRNA_MAD=miRNA_MAD/sum(miRNA_MAD) ##### c.combine ranking and MAD Gene_combineweight = Gene_pageRank*beta+Gene_MAD*(1-beta) miRNA_combineweight = miRNA_pageRank*beta+miRNA_MAD*(1-beta) ####3.Weighted similartiy fusion network ###weighted distance fuction distanceWeighted<-function(X,weight) ##X is the expression Matrix(Row is featrue, column is sample) { X_row = nrow(X) weight_diag<-diag(weight) X2<-(X^2)%*%weight_diag sumsqX = rowSums(X2) X1<-X%*%weight_diag XY = X1 %*% t(X) XX=matrix(rep(sumsqX, times = X_row), X_row, X_row) res=XX+t(XX)-2*XY res[res < 0] = 0 diag(res)=0 res<-sqrt(res) return(res) } Dist1=distanceWeighted(as.matrix(t(GeneExp)),Gene_combineweight) W1= affinityMatrix(Dist1, 20, 0.5) Dist2=distanceWeighted(as.matrix(t(miRNAExp)),miRNA_combineweight) W2=affinityMatrix(Dist2, 20, 0.5) W = SNF(list(W1,W2), 20, 20) group = spectralClustering(W,clusterNum) result=list(W=W,group=group,ranking=ranking) result } ##BRCA result=WSNF(BRCA_gene,BRCA_miRNA,BRCA_miRNA_TF_mRNA_network,beta=0.8,clusterNum=5) ##GBM result=WSNF(GBM_gene,GBM_miRNA,GBM_miRNA_TF_mRNA_network,beta=0.8,clusterNum=3) #################################################################################### ##GeneExp: the Gene (mRNAs, TFs) Expression Data (the rows are Genes and the colomns are samples) ##miRNAExp: the miRNA Expression Data (the rows are miRNAs and the colomns are samples) ##ranking: the ranking of each feature. The order of the ranking is corresponding to ## the order in Gene Expression data and miRNA expression data. ##beta: the tuning parameter for the importance of the miRNA-TF-mRNA regulatory network information. ##clusterNum: the clustering number for cancer subtypes WSNF2<-function(GeneExp,miRNAExp,ranking,beta=0.8,clusterNum=3) { library("SNFtool") #### Normalise ##### a.Normalise ranking Gene_pageRank=ranking[1:nrow(GeneExp)] Gene_pageRank=Gene_pageRank/sum(Gene_pageRank) miRNA_pageRank=ranking[(nrow(GeneExp)+1):length(ranking)] miRNA_pageRank=miRNA_pageRank/sum(miRNA_pageRank) ##### b.Normalise MAD Gene_MAD=as.vector(apply(GeneExp,1,mad)) Gene_MAD=Gene_MAD/sum(Gene_MAD) miRNA_MAD=as.vector(apply(miRNAExp,1,mad)) miRNA_MAD=miRNA_MAD/sum(miRNA_MAD) ##### c.combine ranking and MAD Gene_combineweight=Gene_pageRank*beta+Gene_MAD*(1-beta) miRNA_combineweight=miRNA_pageRank*beta+miRNA_MAD*(1-beta) ####Weighted similartiy fusion network ###weighted distance fuction distanceWeighted<-function(X,weight) ##X is the expression Matrix(Row is featrue, column is sample) { X_row = nrow(X) weight_diag<-diag(weight) X2<-(X^2)%*%weight_diag sumsqX = rowSums(X2) X1<-X%*%weight_diag XY = X1 %*% t(X) XX=matrix(rep(sumsqX, times = X_row), X_row, X_row) res=XX+t(XX)-2*XY res[res < 0] = 0 diag(res)=0 res<-sqrt(res) return(res) } Dist1=distanceWeighted(as.matrix(t(GeneExp)),Gene_combineweight) W1= affinityMatrix(Dist1, 20, 0.5) Dist2=distanceWeighted(as.matrix(t(miRNAExp)),miRNA_combineweight) W2=affinityMatrix(Dist2, 20, 0.5) W = SNF(list(W1,W2), 20, 20) group = spectralClustering(W,clusterNum) result=list(W=W,group=group,ranking=ranking) result } ##BRCA result=WSNF2(BRCA_gene,BRCA_miRNA,BRCA_ranking[,3],beta=0.8,clusterNum=5) ##GBM result=WSNF2(GBM_gene,GBM_miRNA,GBM_ranking[,3],beta=0.8,clusterNum=3) ############################################################################ # %%% This is Matlab code # %%% Calculating the ranking of features in the miRNA-TF-mRNA regulatory network # function ranking = FeatureRanking(Network); # %%% Network: the miRNA-TF-mRNA regulatory network[row(regulators)->colomn(tagagets)] # dumping=0.85; # [Num,aa]=size(Network); # delta=(1-dumping)/Num; # s=sum(Network); # index=find(s==0); # s(index)=1; # Deg=spdiags(1./s',0,Num,Num); # e =ones(Num,1); # w=(sparse(eye(Num))-dumping*Network*Deg)\e*delta; # ranking=w/sum(w);